blob: 29bb7f4b4ce884f2689a06d6886cde01953d8fa9 [file] [log] [blame]
<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[get]] failure cases.</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.testRunner)
testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: false, acceptAttestation: false } });
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["usb"] },
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["nfc"] },
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["ble"] },
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["internal"] }
]
}
};
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.");
}, "PublicKeyCredential's [[get]] with no matched credentials in a mock local authenticator.");
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: Base64URL.parse(testUserhandleBase64) }
]
}
};
if (window.testRunner)
testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.").then(() => {
if (window.testRunner)
testRunner.cleanUpKeychain(testRpId);
});
}, "PublicKeyCredential's [[get]] with no matched credentials in a mock local authenticator. 2nd");
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456")
}
};
if (window.testRunner)
testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Couldn't get user consent.").then(() => {
if (window.testRunner)
testRunner.cleanUpKeychain(testRpId);
});
}, "PublicKeyCredential's [[get]] without user consent in a mock local authenticator.");
promise_test(t => {
const options = {
publicKey: {
challenge: asciiToUint8Array("123456"),
allowCredentials: [
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["usb"] },
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["nfc"] },
{ type: "public-key", id: Base64URL.parse(testCredentialIdBase64), transports: ["ble"] }
],
timeout: 10
}
};
return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Operation timed out.");
}, "PublicKeyCredential's [[get]] with timeout in a mock local authenticator.");
</script>