createcredential-badargs-rp.https.html (2257B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>WebAuthn navigator.credentials.create() rp Tests</title> 4 <meta name="timeout" content="long"> 5 <link rel="author" title="Adam Powers" href="mailto:adam@fidoalliance.org"> 6 <link rel="help" href="https://w3c.github.io/webauthn/#iface-credential"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src=helpers.js></script> 12 <body></body> 13 <script> 14 standardSetup(function() { 15 "use strict"; 16 17 // rp bad values 18 new CreateCredentialsTest({path: "options.publicKey.rp", value: undefined}).runTest("Bad rp: rp missing", TypeError); 19 new CreateCredentialsTest({ path: "options.publicKey.rp", value: null }).runTest("Bad rp: rp null", TypeError); 20 new CreateCredentialsTest("options.publicKey.rp", "hi mom").runTest("Bad rp: rp is string", TypeError); 21 new CreateCredentialsTest("options.publicKey.rp", {}).runTest("Bad rp: rp is empty object", TypeError); 22 23 // // rp.id 24 new CreateCredentialsTest("options.publicKey.rp.id", null).runTest("Bad rp: id is null", "SecurityError"); 25 new CreateCredentialsTest("options.publicKey.rp.id", "").runTest("Bad rp: id is empty String", "SecurityError"); 26 new CreateCredentialsTest("options.publicKey.rp.id", "invalid domain.com").runTest("Bad rp: id is invalid domain (has space)", "SecurityError"); 27 new CreateCredentialsTest("options.publicKey.rp.id", "-invaliddomain.com").runTest("Bad rp: id is invalid domain (starts with dash)", "SecurityError"); 28 new CreateCredentialsTest("options.publicKey.rp.id", "0invaliddomain.com").runTest("Bad rp: id is invalid domain (starts with number)", "SecurityError"); 29 30 let hostAndPort = window.location.host; 31 if (!hostAndPort.match(/:\d+$/)) { 32 hostAndPort += ":443"; 33 } 34 new CreateCredentialsTest("options.publicKey.rp.id", hostAndPort).runTest("Bad rp id: id is host + port", "SecurityError"); 35 36 // // rp.name 37 new CreateCredentialsTest({path: "options.publicKey.rp.name", value: undefined}).runTest("rp missing name", TypeError); 38 }); 39 40 /* JSHINT */ 41 /* globals standardSetup, CreateCredentialsTest */ 42 </script>