Skip to content

Commit

Permalink
test: test tokens without with and without audiences
Browse files Browse the repository at this point in the history
- prepares for jsonwebtoken update
  • Loading branch information
cduvray committed Nov 7, 2023
1 parent c5f73d4 commit 4a29bdf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 7 additions & 5 deletions jwt-authorizer/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ lazy_static! {
});
}

pub const JWT_RSA1_OK: &str = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6InJzYTAxIn0.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjMwMDEiLCJzdWIiOiJiQGIuY29tIiwiYXVkIjoiYXVkMSIsImV4cCI6MjAwMDAwMDAwMCwibmJmIjoxNTE2MjM5MDIyfQ.d29YS5U-Cfur1DDxOeiYBxlEzRFQrVovuFdyIlrMpAfLLWudtpqiMxHKfTEM0ohHrk4ahf7nWhMamuiQUOEZSYpx7ze-4f47FGU4RxFLVSZw7VUWFrNYKkmRlgFsCbpdRLb5in6YDIaqrUnr2tqF9c3vUo_15lLgNn__xDG9_49A8UvbNFGvDm_z53aYGBPdgWVmwrRU5lmHH0tYcLMyiqQKfnM4jr__klIeVGBpJ2V_2qZyHvvevEtiiV7EGWZxaA-cYzeaO-_24nVBvPYrcdib84pz-a4JWhmnUobfzvtbdKEy12abxB2TvpzikBbX5etiDx92cPP_9Kf_51BncmwC_anRIwCSEe5TEgduihYS9yucOGgjP09sjlPPvdGAE6vcl35eR2fizJo7KU6Ol8DoUSDMhuPS-KQ_bFpCDK1iPtsXw514WZQZL1qXF61yd5QZ3wvckR8s_pV0XcFHWg_TpupNC3Yn6zlYU9l8NLkWiIudJVAM2pe-MSu292FyR2ytLISrNqHtk-e4_MIoviqyswvmtHZivoFWkq_CE2V9RyLX4WXaVEJLf4FihfCMFGZVfON2B8N2PfoPMuAlE1otQerbKwwR_TYjOFJRG1HdIDqvNDQ-LeJDKKX0Nz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E1MTYyMzkwMjJ9.UMdAP1cJJmP7Bc-Um0-6oB4Bn52MwlhAzCTd5_-CiL6DjcJFzDq4rhBFz3HZbX4k0K228cCQosY9K8YfRWpjBQ";
8 changes: 4 additions & 4 deletions jwt-authorizer/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ mod tests {
#[tokio::test]
async fn validate_aud() {
let response = make_proteced_request(
JwtAuthorizer::from_ed_pem("../config/ed25519-public1.pem").validation(Validation::new().aud(&["bad-aud"])),
common::JWT_ED1_OK,
JwtAuthorizer::from_rsa_pem("../config/rsa-public1.pem").validation(Validation::new().aud(&["bad-aud"])),
common::JWT_RSA1_AUD1_OK,
)
.await;
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
Expand All @@ -283,8 +283,8 @@ mod tests {
assert_eq!(response.status(), StatusCode::OK);

let response = make_proteced_request(
JwtAuthorizer::from_ed_pem("../config/ed25519-public1.pem").validation(Validation::new().aud(&["aud1"])),
common::JWT_ED1_OK,
JwtAuthorizer::from_ec_pem("../config/ecdsa-public1.pem").validation(Validation::new().aud(&["aud1"])),
common::JWT_EC1_AUD1_OK,
)
.await;
assert_eq!(response.status(), StatusCode::OK);
Expand Down

0 comments on commit 4a29bdf

Please sign in to comment.