blob: 68e3ce20a7518ee52d2e189fa7e25a24c5895c0e [file] [log] [blame]
<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[get]] failure cases with a mock hid authenticator.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/util.js"></script>
<script>
// Default mock configuration. Tests need to override if they need different configuration.
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload" } });
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["nfc"] },
{ type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["ble"] },
{ type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["internal"] }
],
timeout: 10
}
};
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
}, "PublicKeyCredential's [[get]] with timeout in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 255");
}, "PublicKeyCredential's [[get]] with malicious payload in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
userVerification: "required"
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "unsupported-options" } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 43");
}, "PublicKeyCredential's [[get]] with unsupported options in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 34");
}, "PublicKeyCredential's [[get]] with authenticator downgrade failed in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 34");
}, "PublicKeyCredential's [[get]] with authenticator downgrade failed in a mock hid authenticator. 2");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", canDowngrade: true, payloadBase64: [testCtapErrInvalidCredentialResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 34");
}, "PublicKeyCredential's [[get]] with authenticator downgrade succeeded and then U2F failed in a mock hid authenticator.");
</script>