[WebAuthN] Use a real nonce for CTAPHID_INIT
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / ctap-hid-failure.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: CTAP HID failure cases with a mock hid authenticator.</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="./resources/util.js"></script>
6 <script>
7     const defaultOptions = {
8         publicKey: {
9             rp: {
10                 name: "example.com"
11             },
12             user: {
13                 name: "John Appleseed",
14                 id: asciiToUint8Array("123456"),
15                 displayName: "John",
16             },
17             challenge: asciiToUint8Array("123456"),
18             pubKeyCredParams: [{ type: "public-key", alg: -7 }],
19             timeout: 10
20         }
21     };
22
23     promise_test(function(t) {
24         if (window.testRunner)
25             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "data-not-sent" } });
26         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
27     }, "CTAP HID with init sub stage data not sent error in a mock hid authenticator.");
28
29     promise_test(function(t) {
30         if (window.testRunner)
31             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report" } });
32         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
33     }, "CTAP HID with init sub stage empty report error in a mock hid authenticator.");
34
35     promise_test(function(t) {
36         if (window.testRunner)
37             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id" } });
38         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
39     }, "CTAP HID with init sub stage wrong channel id error in a mock hid authenticator.");
40
41     promise_test(function(t) {
42         if (window.testRunner)
43             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-nonce" } });
44         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
45     }, "CTAP HID with init sub stage wrong nonce error in a mock hid authenticator.");
46
47     promise_test(function(t) {
48         if (window.testRunner)
49             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "msg", error: "data-not-sent" } });
50         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
51     }, "CTAP HID with msg sub stage data not sent error in a mock hid authenticator.");
52
53     promise_test(function(t) {
54         if (window.testRunner)
55             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "msg", error: "empty-report" } });
56         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
57     }, "CTAP HID with msg sub stage empty report error in a mock hid authenticator.");
58
59     promise_test(function(t) {
60         if (window.testRunner)
61             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "info", subStage: "msg", error: "wrong-channel-id" } });
62         return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
63     }, "CTAP HID with msg sub stage wrong channel id error in a mock hid authenticator.");
64
65     promise_test(function(t) {
66         if (window.testRunner)
67             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "wrong-channel-id", payloadBase64:testDummyMessagePayloadBase64 } });
68         return promiseRejects(t, "UnknownError", navigator.credentials.create(defaultOptions), "Unknown internal error. Error code: -1");
69     }, "CTAP HID with request::msg stage wrong channel id error in a mock hid authenticator.");
70 </script>