6491378284eb67a19e7d605e687000da641ebde6
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-get-failure-u2f.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[get]] failure cases with a mock u2f 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     promise_test(function(t) {
8         const options = {
9             publicKey: {
10                 challenge: asciiToUint8Array("123456"),
11                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }]
12             }
13         };
14
15         if (window.testRunner)
16             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
17         return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Couldn't parse the U2F sign response.");
18     }, "PublicKeyCredential's [[get]] with malformed sign response in a mock hid authenticator.");
19
20     promise_test(function(t) {
21         const options = {
22             publicKey: {
23                 challenge: asciiToUint8Array("123456"),
24                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }]
25             }
26         };
27
28         if (window.testRunner)
29             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64] } });
30         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
31     }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator.");
32
33     promise_test(function(t) {
34         const options = {
35             publicKey: {
36                 challenge: asciiToUint8Array("123456"),
37                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }, { type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }]
38             }
39         };
40
41         if (window.testRunner)
42             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
43         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
44     }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2");
45
46     // With AppID extension
47     promise_test(function(t) {
48         const options = {
49             publicKey: {
50                 challenge: asciiToUint8Array("123456"),
51                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }],
52                 extensions: { appid: "" }
53             }
54         };
55
56         if (window.testRunner)
57             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
58         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
59     }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. (AppID)");
60
61     promise_test(function(t) {
62         const options = {
63             publicKey: {
64                 challenge: asciiToUint8Array("123456"),
65                 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }, { type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }],
66                 extensions: { appid: "" }
67             }
68         };
69
70         if (window.testRunner)
71             testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64] } });
72         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
73     }, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2 (AppID)");
74 </script>