[WebAuthN] Import a JS CBOR coder
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-get-failure-local.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[get]] failure cases.</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     // Default mock configuration. Tests need to override if they need different configuration.
8     if (window.testRunner)
9         testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false } });
10
11     promise_test(t => {
12         const options = {
13             publicKey: {
14                 challenge: asciiToUint8Array("123456"),
15                 allowCredentials: [
16                     { type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["usb"] },
17                     { type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["nfc"] },
18                     { type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["ble"] },
19                     { type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["internal"] }
20                 ]
21             }
22         };
23
24         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.");
25     }, "PublicKeyCredential's [[get]] with no matched credentials in a mock local authenticator.");
26
27     promise_test(t => {
28         const options = {
29             publicKey: {
30                 challenge: asciiToUint8Array("123456"),
31                 allowCredentials: [
32                     { type: "public-key", id: Base64URL.parse(testUserhandleBase64) }
33                 ]
34             }
35         };
36
37         if (window.testRunner)
38             testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
39         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.").then(() => {
40                 if (window.testRunner)
41                     testRunner.cleanUpKeychain(testRpId);
42             });
43     }, "PublicKeyCredential's [[get]] with no matched credentials in a mock local authenticator. 2nd");
44
45     promise_test(t => {
46         const options = {
47             publicKey: {
48                 challenge: asciiToUint8Array("123456")
49             }
50         };
51
52         if (window.testRunner)
53             testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
54         return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Couldn't get user consent.").then(() => {
55             if (window.testRunner)
56                 testRunner.cleanUpKeychain(testRpId);
57         });
58     }, "PublicKeyCredential's [[get]] without user consent in a mock local authenticator.");
59 </script>