8d22e544d4ab950995257fa6b9e0e5f02c86155d
[WebKit-https.git] / LayoutTests / http / wpt / webauthn / public-key-credential-create-success-nfc.https.html
1 <!DOCTYPE html>
2 <title>Web Authentication API: PublicKeyCredential's [[create]] success cases with a mock nfc 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 src="./resources/cbor.js"></script>
7 <script>
8     // Default mock configuration. Tests need to override if they need different configuration.
9     if (window.testRunner)
10         testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64] } });
11
12     promise_test(t => {
13         const options = {
14             publicKey: {
15                 rp: {
16                     name: "localhost",
17                 },
18                 user: {
19                     name: "John Appleseed",
20                     id: Base64URL.parse(testUserhandleBase64),
21                     displayName: "Appleseed",
22                 },
23                 challenge: Base64URL.parse("MTIzNDU2"),
24                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
25                 timeout: 100
26             }
27         };
28
29         return navigator.credentials.create(options).then(credential => {
30             checkCtapMakeCredentialResult(credential);
31         });
32     }, "PublicKeyCredential's [[create]] with minimum options in a mock nfc authenticator.");
33
34     promise_test(t => {
35         const options = {
36             publicKey: {
37                 rp: {
38                     name: "localhost",
39                 },
40                 user: {
41                     name: "John Appleseed",
42                     id: Base64URL.parse(testUserhandleBase64),
43                     displayName: "Appleseed",
44                 },
45                 challenge: Base64URL.parse("MTIzNDU2"),
46                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
47                 authenticatorSelection: { authenticatorAttachment: "cross-platform" },
48                 timeout: 100
49             }
50         };
51
52         return navigator.credentials.create(options).then(credential => {
53             checkCtapMakeCredentialResult(credential);
54         });
55     }, "PublicKeyCredential's [[create]] with authenticatorSelection { 'cross-platform' } in a mock nfc authenticator.");
56
57     promise_test(t => {
58         const options = {
59             publicKey: {
60                 rp: {
61                     name: "localhost",
62                 },
63                 user: {
64                     name: "John Appleseed",
65                     id: Base64URL.parse(testUserhandleBase64),
66                     displayName: "Appleseed",
67                 },
68                 challenge: Base64URL.parse("MTIzNDU2"),
69                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
70                 timeout: 100
71             }
72         };
73
74         if (window.testRunner)
75             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64], multipleTags: true } });
76         return navigator.credentials.create(options).then(credential => {
77             checkCtapMakeCredentialResult(credential);
78         });
79     }, "PublicKeyCredential's [[create]] with multiple tags in a mock nfc authenticator.");
80
81     promise_test(t => {
82         const options = {
83             publicKey: {
84                 rp: {
85                     name: "localhost",
86                 },
87                 user: {
88                     name: "John Appleseed",
89                     id: Base64URL.parse(testUserhandleBase64),
90                     displayName: "Appleseed",
91                 },
92                 challenge: Base64URL.parse("MTIzNDU2"),
93                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
94                 timeout: 100
95             }
96         };
97
98         if (window.testRunner)
99             testRunner.setWebAuthenticationMockConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fRegisterResponse] } });
100         return navigator.credentials.create(options).then(credential => {
101             checkU2fMakeCredentialResult(credential);
102         });
103     }, "PublicKeyCredential's [[create]] with U2F in a mock nfc authenticator.");
104 </script>