Update ANGLE
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-create-failure-local-silent.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[create]] silent failure cases with a mock local 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     (async function() {
8         const userhandleBase64 = generateUserhandleBase64();
9         const privateKeyBase64 = await generatePrivateKeyBase64();
10         const credentialID = await calculateCredentialID(privateKeyBase64);
11         // Default mock configuration. Tests need to override if they need different configuration.
12         if (window.internals)
13             internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: false, acceptAttestation: false } });
14
15         promise_test(t => {
16             const options = {
17                 publicKey: {
18                     rp: {
19                         name: "example.com"
20                     },
21                     user: {
22                         name: "John Appleseed",
23                         id: Base64URL.parse(testUserhandleBase64),
24                         displayName: "John",
25                     },
26                     challenge: asciiToUint8Array("123456"),
27                     pubKeyCredParams: [{ type: "public-key", alg: -35 }, { type: "public-key", alg: -257 }], // ES384, RS256
28                     timeout: 10
29                 }
30             };
31             return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
32         }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator.");
33
34         promise_test(t => {
35             const options = {
36                 publicKey: {
37                     rp: {
38                         name: "example.com"
39                     },
40                     user: {
41                         name: "John Appleseed",
42                         id: Base64URL.parse(userhandleBase64),
43                         displayName: "John",
44                     },
45                     challenge: asciiToUint8Array("123456"),
46                     pubKeyCredParams: [{ type: "public-key", alg: -7 }],
47                     excludeCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }],
48                     timeout: 10
49                 }
50             };
51             if (window.testRunner)
52                 testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
53             return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.").then(() => {
54                 if (window.testRunner)
55                     testRunner.cleanUpKeychain(testRpId, userhandleBase64);
56             });
57         }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator. 2");
58
59         promise_test(t => {
60             const options = {
61                 publicKey: {
62                     rp: {
63                         name: "example.com"
64                     },
65                     user: {
66                         name: "John Appleseed",
67                         id: Base64URL.parse(userhandleBase64),
68                         displayName: "John",
69                     },
70                     challenge: asciiToUint8Array("123456"),
71                     pubKeyCredParams: [{ type: "public-key", alg: -7 }],
72                     excludeCredentials: [
73                         { type: "public-key", id: credentialID, transports: ["usb"] },
74                         { type: "public-key", id: credentialID, transports: ["nfc"] },
75                         { type: "public-key", id: credentialID, transports: ["ble"] },
76                         { type: "public-key", id: credentialID, transports: ["internal"] }
77                     ],
78                     timeout: 10
79                 }
80             };
81             if (window.testRunner)
82                 testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
83             return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.").then(() => {
84                 if (window.testRunner)
85                     testRunner.cleanUpKeychain(testRpId, userhandleBase64);
86             });
87         }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator. 3");
88
89         promise_test(t => {
90             const options = {
91                 publicKey: {
92                     rp: {
93                         name: "example.com"
94                     },
95                     user: {
96                         name: "John Appleseed",
97                         id: Base64URL.parse(testUserhandleBase64),
98                         displayName: "John",
99                     },
100                     challenge: asciiToUint8Array("123456"),
101                     pubKeyCredParams: [{ type: "public-key", alg: -7 }],
102                     timeout: 10
103                 }
104             };
105             return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
106         }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator. 4");
107
108         promise_test(t => {
109             const options = {
110                 publicKey: {
111                     rp: {
112                         name: "example.com"
113                     },
114                     user: {
115                         name: "John Appleseed",
116                         id: Base64URL.parse(testUserhandleBase64),
117                         displayName: "John",
118                     },
119                     challenge: asciiToUint8Array("123456"),
120                     pubKeyCredParams: [{ type: "public-key", alg: -7 }],
121                     timeout: 10
122                 }
123             };
124             if (window.internals)
125                 internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: true, acceptAttestation: false } });
126             return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.");
127         }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator. 5");
128
129         promise_test(t => {
130             const options = {
131                 publicKey: {
132                     rp: {
133                         name: "example.com"
134                     },
135                     user: {
136                         name: "John Appleseed",
137                         id: Base64URL.parse(userhandleBase64),
138                         displayName: "John",
139                     },
140                     challenge: asciiToUint8Array("123456"),
141                     pubKeyCredParams: [{ type: "public-key", alg: -7 }],
142                     timeout: 10
143                 }
144             };
145             if (window.internals) {
146                 internals.setMockWebAuthenticationConfiguration({ silentFailure: true, local: { acceptAuthentication: true, acceptAttestation: false } });
147                 testRunner.addTestKeyToKeychain(privateKeyBase64, testRpId, userhandleBase64);
148             }
149             return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Operation timed out.").then(() => {
150                 if (window.testRunner)
151                     assert_false(testRunner.keyExistsInKeychain(testRpId, userhandleBase64));
152             });
153         }, "PublicKeyCredential's [[create]] with silent failure in a mock local authenticator. 6");
154     })();
155 </script>