blob: b17f726f6c068ae1abff5cc4fa1d08af5417555b [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.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", payloadBase64: [testAssertionMessageLongBase64, testCtapErrNotAllowedResponseBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Unknown internal error. Error code: 48");
}, "PublicKeyCredential's [[get]] with getNextAssertion failed in a mock hid authenticator.");
</script>