Skip to content

Commit

Permalink
jwt-cli.bats: 2 more tests with claims
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Collins <[email protected]>
  • Loading branch information
benmcollins committed Feb 11, 2025
1 parent c830d69 commit 74c9267
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/jwt-cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ HS256_KEY="../tests/keys/oct_key_256.json"
@test "Verify a JWT with alg HS256" {
./tools/jwt-verify -q -k ${HS256_KEY} ${HS256_RES}
}

CLAIM_RES="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6ZmFsc2UsImV4cCI6MTgzOTMxNzU2MiwiZ3JvdXAiOiJzdGFmZiIsImlzcyI6ImRpc2suc3dpc3NkaXNrLmNvbSIsInVzZXIiOiJiY29sbGlucyJ9.83VR9A9jbQxp6KRq8iXHihIxe9LkAjnMAz3L0GdKlPI"

@test "Generate a JWT with alg HS256 and claims" {
result="$(./tools/jwt-generate -q -n \
-k ${HS256_KEY} \
-c s:group=staff \
-c b:admin=false \
-c s:iss=disk.swissdisk.com \
-c s:user=bcollins \
-c i:exp=1839317562)"
[ "$result" = ${CLAIM_RES} ]
}

@test "Verify a JWT with alg HS256 with claims" {
./tools/jwt-verify -q -k ${HS256_KEY} ${CLAIM_RES}
}

0 comments on commit 74c9267

Please sign in to comment.