mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-12 08:00:07 +01:00
fix: responses collect into bytes with BodyExt trait
This commit is contained in:
parent
41f38d8db5
commit
e1e5874347
4 changed files with 15 additions and 13 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1076,6 +1076,7 @@ dependencies = [
|
|||
"futures-util",
|
||||
"headers",
|
||||
"http 1.0.0",
|
||||
"http-body-util",
|
||||
"hyper 1.0.1",
|
||||
"jsonwebtoken",
|
||||
"lazy_static",
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ tracing = "0.1"
|
|||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
tonic = { version = "0.10", optional = true }
|
||||
time = { version = "0.3", optional = true }
|
||||
http-body-util = "0.1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
hyper = { version = "1.0.1", features = ["full"] }
|
||||
|
|
|
|||
|
|
@ -77,11 +77,8 @@ fn run_jwks_server() -> String {
|
|||
.route("/jwks", get(jwks));
|
||||
|
||||
tokio::spawn(async move {
|
||||
axum::Server::from_tcp(listener)
|
||||
.unwrap()
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
let listener: tokio::net::TcpListener = tokio::net::TcpListener::from_std(listener).unwrap();
|
||||
axum::serve(listener, app.into_make_service()).await.unwrap();
|
||||
});
|
||||
|
||||
url
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ mod tests {
|
|||
use tower::{util::MapErrLayer, ServiceExt};
|
||||
|
||||
use crate::common;
|
||||
use http_body_util::BodyExt;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
struct User {
|
||||
|
|
@ -102,7 +103,9 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
|
||||
assert_eq!(&body[..], b"hello: b@b.com");
|
||||
|
||||
// ECDSA PEM
|
||||
|
|
@ -112,14 +115,14 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
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();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
assert_eq!(&body[..], b"hello: b@b.com");
|
||||
|
||||
// JWKS
|
||||
|
|
@ -129,7 +132,7 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
assert_eq!(&body[..], b"hello: b@b.com");
|
||||
|
||||
let response = make_proteced_request(
|
||||
|
|
@ -138,7 +141,7 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
assert_eq!(&body[..], b"hello: b@b.com");
|
||||
|
||||
let response = make_proteced_request(
|
||||
|
|
@ -147,7 +150,7 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
assert_eq!(&body[..], b"hello: b@b.com");
|
||||
|
||||
// JWKS TEXT
|
||||
|
|
@ -158,7 +161,7 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
assert_eq!(&body[..], b"hello: b@b.com");
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +237,7 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
|
||||
let body = response.into_body().collect().await.unwrap().to_bytes();
|
||||
assert_eq!(&body[..], b"option: true");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue