Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion committed Jan 19, 2024
1 parent 10d050e commit e02baef
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,20 @@ test_and_get_keyset("https://www.googleapis.com/oauth2/v3/certs")
test_signing_symmetric_keys("file://" * joinpath(@__DIR__, "keys", "oct", "jwkkey.json"))
test_in_mem_keyset(joinpath(@__DIR__, "keys", "oct", "jwkkey.json"))
test_signing_asymmetric_keys("file://" * joinpath(@__DIR__, "keys", "rsa", "jwkkey.json"))
test_with_valid_jwt("file://" * joinpath(@__DIR__, "keys", "oct", "jwkkey.json"))
test_with_valid_jwt("file://" * joinpath(@__DIR__, "keys", "oct", "jwkkey.json"))

@testset "alg" begin
rsakey = MbedTLS.parse_keyfile(joinpath(@__DIR__, "keys", "rsa", "rsakey1.private.pem"))
@test JWTs.alg(JWKRSA(MbedTLS.MD_SHA256, rsakey)) == "RS256"
@test JWTs.alg(JWKRSA(MbedTLS.MD_SHA384, rsakey)) == "RS384"
@test JWTs.alg(JWKRSA(MbedTLS.MD_SHA, rsakey)) == "RS512"

@test JWTs.alg(JWKSymmetric(MbedTLS.MD_SHA256, UInt8[])) == "HS256"
@test JWTs.alg(JWKSymmetric(MbedTLS.MD_SHA384, UInt8[])) == "HS384"
@test JWTs.alg(JWKSymmetric(MbedTLS.MD_SHA, UInt8[])) == "HS512"

for kind in (MbedTLS.MD_SHA1, MbedTLS.MD_SHA224)
@test_throws ArgumentError JWTs.alg(JWKRSA(kind, rsakey))
@test_throws ArgumentError JWTs.alg(JWKSymmetric(kind, UInt8[]))
end
end

0 comments on commit e02baef

Please sign in to comment.