79
80 // With AppID extension
81 promise_test(t => {
82 const options = {
83 publicKey: {
84 challenge: Base64URL.parse("MTIzNDU2"),
85 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
86 timeout: 100,
87 extensions: { }
88 }
89 };
90
91 if (window.testRunner)
92 testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
93 return navigator.credentials.get(options).then(credential => {
94 return checkResult(credential);
95 });
96 }, "PublicKeyCredential's [[get]] with empty extensions in a mock hid authenticator.");
97
98 promise_test(t => {
99 const options = {
100 publicKey: {
101 challenge: Base64URL.parse("MTIzNDU2"),
102 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
103 timeout: 100,
104 extensions: { appid: "https://localhost:666/appid" }
105 }
106 };
107
108 if (window.testRunner)
109 testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fSignResponse] } });
110 return navigator.credentials.get(options).then(credential => {
111 return checkResult(credential);
112 });
113 }, "PublicKeyCredential's [[get]] with same site AppID but not used in a mock hid authenticator.");
114
115 promise_test(t => {
116 const options = {
117 publicKey: {
118 challenge: Base64URL.parse("MTIzNDU2"),
119 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
120 timeout: 100,
121 extensions: { appid: "" }
122 }
123 };
124
125 if (window.testRunner)
126 testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
127 return navigator.credentials.get(options).then(credential => {
128 return checkResult(credential, true);
129 });
130 }, "PublicKeyCredential's [[get]] with empty AppID in a mock hid authenticator.");
131
132 // FIXME: Sub domains need to be tested as well. However, localhost has no sub domains.
133 promise_test(t => {
134 const options = {
135 publicKey: {
136 challenge: Base64URL.parse("MTIzNDU2"),
137 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
138 timeout: 100,
139 extensions: { appid: "https://localhost:666/appid" }
140 }
141 };
142
143 if (window.testRunner)
144 testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
145 return navigator.credentials.get(options).then(credential => {
146 return checkResult(credential, true, "7eabc5cc3251bdc59115ef87b5f7ee74cb03747e39ba8341748565cc129c0719");
147 });
148 }, "PublicKeyCredential's [[get]] with an AppID in a mock hid authenticator.");
149
150 promise_test(t => {
151 const options = {
152 publicKey: {
153 challenge: Base64URL.parse("MTIzNDU2"),
154 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }, { type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
155 timeout: 100,
156 extensions: { appid: "" }
157 }
158 };
159
160 if (window.testRunner)
161 testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
162 return navigator.credentials.get(options).then(credential => {
163 return checkResult(credential);
164 });
165 }, "PublicKeyCredential's [[get]] with multiple credentials and AppID is not used in a mock hid authenticator.");
166
167 promise_test(t => {
168 const options = {
169 publicKey: {
170 challenge: Base64URL.parse("MTIzNDU2"),
171 allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }, { type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
172 timeout: 100,
173 extensions: { appid: "" }
174 }
175 };
176
177 if (window.testRunner)
178 testRunner.setWebAuthenticationMockConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fSignResponse] } });
179 return navigator.credentials.get(options).then(credential => {
180 return checkResult(credential, true);
181 });
182 }, "PublicKeyCredential's [[get]] with multiple credentials and AppID is used in a mock hid authenticator.");
183