From 4cabc9777deb9ef1e639140378705161672411ce Mon Sep 17 00:00:00 2001 From: cduvray Date: Thu, 12 Oct 2023 07:45:32 +0200 Subject: [PATCH] test: add a test of from_jwks_text --- jwt-authorizer/tests/tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jwt-authorizer/tests/tests.rs b/jwt-authorizer/tests/tests.rs index 298dbdc..603be1d 100644 --- a/jwt-authorizer/tests/tests.rs +++ b/jwt-authorizer/tests/tests.rs @@ -94,6 +94,7 @@ mod tests { #[tokio::test] async fn protected_with_jwt() { + // ED PEM let response = make_proteced_request( JwtAuthorizer::from_ed_pem("../config/ed25519-public2.pem"), common::JWT_ED2_OK, @@ -103,18 +104,21 @@ mod tests { let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); assert_eq!(&body[..], b"hello: b@b.com"); + // ECDSA PEM let response = make_proteced_request(JwtAuthorizer::from_ec_pem("../config/ecdsa-public2.pem"), common::JWT_EC2_OK).await; assert_eq!(response.status(), StatusCode::OK); let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); assert_eq!(&body[..], b"hello: b@b.com"); + // RSA PEM let response = make_proteced_request(JwtAuthorizer::from_rsa_pem("../config/rsa-public2.pem"), common::JWT_RSA2_OK).await; assert_eq!(response.status(), StatusCode::OK); let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); assert_eq!(&body[..], b"hello: b@b.com"); + // JWKS let response = make_proteced_request(JwtAuthorizer::from_jwks("../config/public1.jwks"), common::JWT_RSA1_OK).await; assert_eq!(response.status(), StatusCode::OK); let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); @@ -129,6 +133,16 @@ mod tests { assert_eq!(response.status(), StatusCode::OK); let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); assert_eq!(&body[..], b"hello: b@b.com"); + + // JWKS TEXT + let response = make_proteced_request( + JwtAuthorizer::from_jwks_text(include_str!("../../config/public1.jwks")), + common::JWT_ED1_OK, + ) + .await; + assert_eq!(response.status(), StatusCode::OK); + let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + assert_eq!(&body[..], b"hello: b@b.com"); } #[tokio::test]