[
{ "fn": "base64Encode", "name": "RFC 4648 section 10: the empty string", "args": [[]], "expect": "" },
{ "fn": "base64Encode", "name": "RFC 4648 section 10: \"f\", two padding characters", "args": [[102]], "expect": "Zg==" },
{ "fn": "base64Encode", "name": "RFC 4648 section 10: \"fo\", one padding character", "args": [[102, 111]], "expect": "Zm8=" },
{ "fn": "base64Encode", "name": "RFC 4648 section 10: \"foo\", no padding", "args": [[102, 111, 111]], "expect": "Zm9v" },
{ "fn": "base64Encode", "name": "RFC 4648 section 10: \"foob\"", "args": [[102, 111, 111, 98]], "expect": "Zm9vYg==" },
{ "fn": "base64Encode", "name": "RFC 4648 section 10: \"fooba\"", "args": [[102, 111, 111, 98, 97]], "expect": "Zm9vYmE=" },
{ "fn": "base64Encode", "name": "RFC 4648 section 10: \"foobar\"", "args": [[102, 111, 111, 98, 97, 114]], "expect": "Zm9vYmFy" },
{ "fn": "base64Encode", "name": "high bytes use the + and / characters of the standard alphabet", "args": [[251, 255, 191]], "expect": "+/+/" },
{ "fn": "base64Encode", "name": "zero bytes are A, not dropped", "args": [[0, 0, 0, 0]], "expect": "AAAAAA==" },
{ "fn": "base64Encode", "name": "256 is not a byte", "args": [[256]], "expectError": "bytes must be a list of integers from 0 to 255" },
{ "fn": "base64Encode", "name": "a fraction is not a byte", "args": [[1.5]], "expectError": "bytes must be a list of integers from 0 to 255" },
{ "fn": "base64Encode", "name": "a string inside the list is not a byte", "args": [["f"]], "expectError": "bytes must be a list of integers from 0 to 255" },
{ "fn": "base64Decode", "name": "the empty string", "args": [""], "expect": [] },
{ "fn": "base64Decode", "name": "RFC 4648 section 10: \"Zg==\" is \"f\"", "args": ["Zg=="], "expect": [102] },
{ "fn": "base64Decode", "name": "RFC 4648 section 10: \"Zm8=\" is \"fo\"", "args": ["Zm8="], "expect": [102, 111] },
{ "fn": "base64Decode", "name": "RFC 4648 section 10: \"Zm9vYg==\" is \"foob\"", "args": ["Zm9vYg=="], "expect": [102, 111, 111, 98] },
{ "fn": "base64Decode", "name": "RFC 4648 section 10: \"Zm9vYmFy\" is \"foobar\"", "args": ["Zm9vYmFy"], "expect": [102, 111, 111, 98, 97, 114] },
{ "fn": "base64Decode", "name": "the + and / characters", "args": ["+/+/"], "expect": [251, 255, 191] },
{ "fn": "base64Decode", "name": "missing padding is refused in standard base64", "args": ["Zg"], "expectError": "base64 text must be a multiple of 4 characters long, received 2" },
{ "fn": "base64Decode", "name": "non-zero bits after the last byte, which a lenient decoder reads as \"f\"", "args": ["Zh=="], "expectError": "base64 text has non-zero bits after its last byte" },
{ "fn": "base64Decode", "name": "non-zero bits after the last of two bytes", "args": ["Zm9="], "expectError": "base64 text has non-zero bits after its last byte" },
{ "fn": "base64Decode", "name": "three padding characters", "args": ["Z==="], "expectError": "base64 text has too much = padding" },
{ "fn": "base64Decode", "name": "padding in the middle", "args": ["Zg==Zg=="], "expectError": "base64 text may only contain A-Z, a-z, 0-9, + and /, with = padding at the end" },
{ "fn": "base64Decode", "name": "a trailing newline is not skipped", "args": ["Zm9v\n"], "expectError": "base64 text may only contain A-Z, a-z, 0-9, + and /, with = padding at the end" },
{ "fn": "base64Decode", "name": "base64url characters in standard text", "args": ["-_-_"], "expectError": "base64 text may only contain A-Z, a-z, 0-9, + and /, with = padding at the end" },
{ "fn": "base64Decode", "name": "a non-ASCII letter", "args": ["Zm9é"], "expectError": "base64 text may only contain A-Z, a-z, 0-9, + and /, with = padding at the end" },
{ "fn": "base64UrlEncode", "name": "the empty string", "args": [[]], "expect": "" },
{ "fn": "base64UrlEncode", "name": "\"f\" without its padding", "args": [[102]], "expect": "Zg" },
{ "fn": "base64UrlEncode", "name": "\"fo\" without its padding", "args": [[102, 111]], "expect": "Zm8" },
{ "fn": "base64UrlEncode", "name": "\"foobar\" needs no padding in either alphabet", "args": [[102, 111, 111, 98, 97, 114]], "expect": "Zm9vYmFy" },
{ "fn": "base64UrlEncode", "name": "- and _ replace + and /", "args": [[251, 255, 191]], "expect": "-_-_" },
{ "fn": "base64UrlEncode", "name": "- and _ with padding removed", "args": [[251, 255]], "expect": "-_8" },
{ "fn": "base64UrlEncode", "name": "RFC 7515 appendix A.1: the example JWS header", "args": [[123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125]], "expect": "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9" },
{ "fn": "base64UrlEncode", "name": "300 is not a byte", "args": [[300]], "expectError": "bytes must be a list of integers from 0 to 255" },
{ "fn": "base64UrlEncode", "name": "a negative value is not a byte", "args": [[-5]], "expectError": "bytes must be a list of integers from 0 to 255" },
{ "fn": "base64UrlDecode", "name": "the empty string", "args": [""], "expect": [] },
{ "fn": "base64UrlDecode", "name": "unpadded, as a JWT writes it", "args": ["Zg"], "expect": [102] },
{ "fn": "base64UrlDecode", "name": "correct padding is accepted too", "args": ["Zg=="], "expect": [102] },
{ "fn": "base64UrlDecode", "name": "- and _", "args": ["-_-_"], "expect": [251, 255, 191] },
{ "fn": "base64UrlDecode", "name": "- and _ in an unpadded tail", "args": ["-_8"], "expect": [251, 255] },
{ "fn": "base64UrlDecode", "name": "RFC 7515 appendix A.1: the example JWS header", "args": ["eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9"], "expect": [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] },
{ "fn": "base64UrlDecode", "name": "standard-alphabet characters are refused", "args": ["+/+/"], "expectError": "base64url text may only contain A-Z, a-z, 0-9, - and _, with optional = padding at the end" },
{ "fn": "base64UrlDecode", "name": "one character past a multiple of four encodes nothing", "args": ["Zm9vY"], "expectError": "base64url text cannot be 5 characters long; no number of bytes encodes to that" },
{ "fn": "base64UrlDecode", "name": "padding that is present must be complete", "args": ["Zg="], "expectError": "base64url text has the wrong amount of = padding" },
{ "fn": "base64UrlDecode", "name": "non-zero bits after the last byte", "args": ["Zh"], "expectError": "base64 text has non-zero bits after its last byte" },
{ "fn": "base64UrlDecode", "name": "a space inside the text", "args": ["Zm9v YmFy"], "expectError": "base64url text may only contain A-Z, a-z, 0-9, - and _, with optional = padding at the end" }
]