mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2026-02-02 01:15:11 +01:00
test: add a test of from_jwks_text
This commit is contained in:
parent
ef8ac07271
commit
4cabc9777d
1 changed files with 14 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ mod tests {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn protected_with_jwt() {
|
async fn protected_with_jwt() {
|
||||||
|
// ED PEM
|
||||||
let response = make_proteced_request(
|
let response = make_proteced_request(
|
||||||
JwtAuthorizer::from_ed_pem("../config/ed25519-public2.pem"),
|
JwtAuthorizer::from_ed_pem("../config/ed25519-public2.pem"),
|
||||||
common::JWT_ED2_OK,
|
common::JWT_ED2_OK,
|
||||||
|
|
@ -103,18 +104,21 @@ mod tests {
|
||||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||||
assert_eq!(&body[..], b"hello: b@b.com");
|
assert_eq!(&body[..], b"hello: b@b.com");
|
||||||
|
|
||||||
|
// ECDSA PEM
|
||||||
let response =
|
let response =
|
||||||
make_proteced_request(JwtAuthorizer::from_ec_pem("../config/ecdsa-public2.pem"), common::JWT_EC2_OK).await;
|
make_proteced_request(JwtAuthorizer::from_ec_pem("../config/ecdsa-public2.pem"), common::JWT_EC2_OK).await;
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||||
assert_eq!(&body[..], b"hello: b@b.com");
|
assert_eq!(&body[..], b"hello: b@b.com");
|
||||||
|
|
||||||
|
// RSA PEM
|
||||||
let response =
|
let response =
|
||||||
make_proteced_request(JwtAuthorizer::from_rsa_pem("../config/rsa-public2.pem"), common::JWT_RSA2_OK).await;
|
make_proteced_request(JwtAuthorizer::from_rsa_pem("../config/rsa-public2.pem"), common::JWT_RSA2_OK).await;
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||||
assert_eq!(&body[..], b"hello: b@b.com");
|
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;
|
let response = make_proteced_request(JwtAuthorizer::from_jwks("../config/public1.jwks"), common::JWT_RSA1_OK).await;
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||||
|
|
@ -129,6 +133,16 @@ mod tests {
|
||||||
assert_eq!(response.status(), StatusCode::OK);
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||||
assert_eq!(&body[..], b"hello: b@b.com");
|
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]
|
#[tokio::test]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue