blob: ac52383cccefcb20e0d6001dd0ede49099e73d95 [file] [edit]
<!DOCTYPE html><!-- webkit-test-runner [ WebAuthenticationModernEnabled=true allowTestOnlyIPC=true ] -->
<title>Web Authentication API: PublicKeyCredential's [[get]] failure cases with a mock u2f authenticator.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/util.js"></script>
<script>
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }]
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduNoErrorOnlyResponseBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.get(options), "Couldn't parse the U2F sign response.");
}, "PublicKeyCredential's [[get]] with malformed sign response in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }]
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
}, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator.");
promise_test(function(t) {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }, { type: "public-key", id: Base64URL.parse(testCredentialIdBase64) }]
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fApduWrongDataOnlyResponseBase64, testU2fApduWrongDataOnlyResponseBase64, testU2fApduNoErrorOnlyResponseBase64] } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No credentials from the allowCredentials list is found in the authenticator.");
}, "PublicKeyCredential's [[get]] with no matched allow credentials in a mock hid authenticator. 2");
promise_test(t => {
const options = {
publicKey: {
challenge: Base64URL.parse("MTIzNDU2"),
allowCredentials: [{ type: "public-key", id: Base64URL.parse(testU2fCredentialIdBase64) }],
extensions: { appid: "" }
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "malicious-payload", isU2f: true, payloadBase64: [testU2fSignResponse] } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Empty appid in create request.");
}, "PublicKeyCredential's [[get]] with empty appid");
</script>