import-jwk-expected.txt 4.32 KB
Newer Older
1 2 3 4 5
Test error handling for JWK import.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


ap@apple.com's avatar
ap@apple.com committed
6 7 8 9 10 11 12 13
PASS crypto.subtle.importKey("jwk", asciiToUint8Array(''), null) threw exception TypeError: Invalid JWK serialization.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{'), null) threw exception TypeError: Invalid JWK serialization.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('null'), null) threw exception TypeError: Invalid JWK serialization.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('undefined'), null) threw exception TypeError: Invalid JWK serialization.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{}'), null) threw exception TypeError: Neither key nor function argument has crypto algorithm specified.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{}'), "aes-cbc") threw exception TypeError: Required JWK "kty" member is missing.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "foobar", "alg": "HS256", "use": "sig", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Unsupported JWK key type foobar.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "foobar", "use": "sig", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Unsupported JWK algorithm foobar.
14 15
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), "aes-cbc") threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), { name: "hmac", hash: "sha-1" }) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.
ap@apple.com's avatar
ap@apple.com committed
16 17
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256" }'), null) threw exception TypeError: Secret key data is not present is JWK.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC" }'), null) threw exception TypeError: Secret key data is not present is JWK.
18 19 20 21 22 23 24 25 26
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "1234" }'), null) threw exception TypeError: Key size is not valid for HS256.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext": false, "k": "1234" }'), null) threw exception TypeError: Key size is not valid for A128CBC.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Key size is not valid for A128CBC.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Cannot decode base64url key data in JWK.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": 1, "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "kty" JSON key.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": 1, "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "alg" JSON key.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": 1, "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "use" JSON key.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": "false", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a boolean value for "ext" JSON key.
PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": 1 }'), null) threw exception TypeError: Expected a string value for "k" JSON key.
27 28 29 30
PASS successfullyParsed is true

TEST COMPLETE