@@ -5,13 +5,23 @@ test_that("Headers work for hmac", {
5
5
privkey <- openssl :: rsa_keygen()
6
6
pubkey <- privkey $ pubkey
7
7
claim1 <- jwt_claim(" test" , exp = Sys.time())
8
- claim2 <- jwt_claim(" test" , exp = Sys.time()- 100 )
8
+ claim2 <- jwt_claim(" test" , exp = Sys.time() - 100 )
9
+ claim3 <- jwt_claim(" test" , nbf = Sys.time())
10
+ claim4 <- jwt_claim(" test" , nbf = Sys.time() + 100 )
9
11
jwth1 <- jwt_encode_hmac(claim1 , secret = secret )
10
12
jwth2 <- jwt_encode_hmac(claim2 , secret = secret )
13
+ jwth3 <- jwt_encode_hmac(claim3 , secret = secret )
14
+ jwth4 <- jwt_encode_hmac(claim4 , secret = secret )
11
15
jwtr1 <- jwt_encode_sig(claim1 , privkey )
12
16
jwtr2 <- jwt_encode_sig(claim2 , privkey )
17
+ jwtr3 <- jwt_encode_sig(claim3 , privkey )
18
+ jwtr4 <- jwt_encode_sig(claim4 , privkey )
13
19
expect_equal(jwt_decode_hmac(jwth1 , secret )$ iss , " test" )
14
20
expect_error(jwt_decode_hmac(jwth2 , secret ), " expired" )
21
+ expect_equal(jwt_decode_hmac(jwth3 , secret )$ iss , " test" )
22
+ expect_error(jwt_decode_hmac(jwth4 , secret ), " before" )
15
23
expect_equal(jwt_decode_sig(jwtr1 , pubkey )$ iss , " test" )
16
24
expect_error(jwt_decode_sig(jwtr2 , pubkey ), " expired" )
25
+ expect_equal(jwt_decode_sig(jwtr3 , pubkey )$ iss , " test" )
26
+ expect_error(jwt_decode_sig(jwtr4 , pubkey ), " before" )
17
27
})
0 commit comments