Skip to content

Commit

Permalink
tests/jwt-cli.bats: Start of new cli testing framework for tools
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 14a9d43 commit 58bac47
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/jwt-cli.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bats

BASIC_RES="eyJhbGciOiJub25lIn0.e30."

@test "Generate a JWT with alg none" {
result="$(./tools/jwt-generate -a none -q -n)"
[ "$result" = ${BASIC_RES} ]
}

@test "Verify a JWT with alg none" {
./tools/jwt-verify -q ${BASIC_RES}
}

HS256_RES="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.CM4dD95Nj0vSfMGtDas432AUW1HAo7feCiAbt5Yjuds"
HS256_KEY="../tests/keys/oct_key_256.json"

@test "Generate a JWT with alg HS256" {
result="$(./tools/jwt-generate -a HS256 -q -n -k ${HS256_KEY})"
[ "$result" = ${HS256_RES} ]
}

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

0 comments on commit 58bac47

Please sign in to comment.