Functional Weave
Code in Rust

auth.bearer-token@1.0.0

vectors.json

1,722 bytes · view raw

[
  { "name": "a JWT after Bearer", "args": ["Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2lnbmF0dXJl"], "expect": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2lnbmF0dXJl" },
  { "name": "RFC 6750 section 2.1's example token", "args": ["Bearer mF_9.B5f-4.1JqM"], "expect": "mF_9.B5f-4.1JqM" },
  { "name": "the scheme is case-insensitive", "args": ["bearer abc"], "expect": "abc" },
  { "name": "upper-case scheme", "args": ["BEARER abc"], "expect": "abc" },
  { "name": "several spaces after the scheme (1*SP)", "args": ["Bearer   abc"], "expect": "abc" },
  { "name": "spaces around the whole value are ignored", "args": ["  Bearer abc  "], "expect": "abc" },
  { "name": "trailing = padding and the + / ~ characters are allowed", "args": ["Bearer a+b/c~d=="], "expect": "a+b/c~d==" },
  { "name": "no header at all", "args": [null], "expect": null },
  { "name": "an empty header", "args": [""], "expect": null },
  { "name": "the scheme with no token", "args": ["Bearer"], "expect": null },
  { "name": "the scheme and a space but no token", "args": ["Bearer   "], "expect": null },
  { "name": "another scheme", "args": ["Basic dXNlcjpwYXNz"], "expect": null },
  { "name": "no space between scheme and token", "args": ["Bearerabc"], "expect": null },
  { "name": "a tab is not the space RFC 6750 requires after the scheme", "args": ["Bearer\tabc"], "expect": null },
  { "name": "a space inside the token", "args": ["Bearer abc def"], "expect": null },
  { "name": "= in the middle of the token", "args": ["Bearer ab=c"], "expect": null },
  { "name": "a token that is only padding", "args": ["Bearer =="], "expect": null },
  { "name": "a non-ASCII character in the token", "args": ["Bearer abcé"], "expect": null }
]