blob: f447ed6ef479da5de5068b232d7018818a316302 [file] [log] [blame]
<!DOCTYPE html><!-- webkit-test-runner [ WebAuthenticationModernEnabled=true ] -->
<title>Web Authentication API: CTAP HID 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>
const defaultOptions = {
publicKey: {
rp: {
name: "example.com"
},
user: {
name: "John Appleseed",
id: asciiToUint8Array("123456"),
displayName: "John",
},
challenge: asciiToUint8Array("123456"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
timeout: 10
}
};
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "data-not-sent" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with init sub stage data not sent error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "empty-report" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with init sub stage empty report error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-channel-id" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with init sub stage wrong channel id error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "init", error: "wrong-nonce" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with init sub stage wrong nonce error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "msg", error: "data-not-sent" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with msg sub stage data not sent error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "msg", error: "empty-report" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with msg sub stage empty report error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "info", subStage: "msg", error: "wrong-channel-id" } });
return promiseRejects(t, "NotAllowedError", navigator.credentials.create(defaultOptions), "Operation timed out.");
}, "CTAP HID with msg sub stage wrong channel id error in a mock hid authenticator.");
promise_test(function(t) {
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "wrong-channel-id", payloadBase64:[testDummyMessagePayloadBase64] } });
return promiseRejects(t, "UnknownError", navigator.credentials.create(defaultOptions), "Unknown internal error. Error code: 18");
}, "CTAP HID with request::msg stage wrong channel id error in a mock hid authenticator.");
</script>