-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare for Hyper 1.0.0 Upgrade: Enable Deprecated Features and Resolve Deprecations #1938
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,11 @@ mod needs_docker { | |
let response = app.post_user("test-user-basic", "basic").await; | ||
assert_eq!(response.status(), StatusCode::OK); | ||
// Extract the API key from the response so we can use it in a future request. | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: consider handling the unwrap() case more gracefully since this is a test that could fail |
||
.to_bytes(); | ||
|
||
let user: Value = serde_json::from_slice(&body).unwrap(); | ||
let basic_user_key = user["key"].as_str().unwrap(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,10 @@ impl TestApp { | |
|
||
pub async fn get_user_typed(&self, user_id: &str) -> user::UserResponse { | ||
let response = self.get_user(user_id).await; | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
serde_json::from_slice(&body).unwrap() | ||
} | ||
|
@@ -174,7 +177,10 @@ impl TestApp { | |
} | ||
|
||
pub async fn claim_from_response(&self, res: Response) -> Claim { | ||
let body = hyper::body::to_bytes(res.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(res.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let convert: Value = serde_json::from_slice(&body).unwrap(); | ||
let token = convert["token"].as_str().unwrap(); | ||
|
||
|
@@ -188,7 +194,10 @@ impl TestApp { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let public_key = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let public_key = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
Comment on lines
+197
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: consider extracting body collection logic into a helper method to avoid repetition |
||
|
||
Claim::from_token(token, &public_key).unwrap() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,10 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
Comment on lines
+49
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: This pattern is repeated throughout the file. Consider extracting this common body collection logic into a helper function to reduce duplication and make future API changes easier. |
||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
let user_id1 = user.id.clone(); | ||
|
||
|
@@ -60,7 +63,10 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
let user_id2 = user.id.clone(); | ||
|
||
|
@@ -88,7 +94,11 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let post_body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let post_body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
let user: user::UserResponse = serde_json::from_slice(&post_body).unwrap(); | ||
let user_id = user.id; | ||
|
||
|
@@ -123,7 +133,10 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let get_body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let get_body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
assert_eq!(post_body, get_body); | ||
} | ||
|
@@ -137,7 +150,10 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
let user_id = &user.id; | ||
|
||
|
@@ -160,7 +176,10 @@ mod needs_docker { | |
.await; | ||
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let pro_user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
|
||
assert_eq!(user.name, pro_user.name); | ||
|
@@ -187,7 +206,10 @@ mod needs_docker { | |
// POST user first so one exists in the database. | ||
let response = app.post_user("test-user", "basic").await; | ||
assert_eq!(response.status(), StatusCode::OK); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
let user_id = &user.id; | ||
|
||
|
@@ -214,7 +236,10 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let actual_user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
|
||
assert_eq!(actual_user.account_tier, AccountTier::PendingPaymentPro); | ||
|
@@ -238,7 +263,10 @@ mod needs_docker { | |
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
// Extract the API key from the response so we can use it in a future request. | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
let user_id = &user.id; | ||
let basic_user_key = &user.key; | ||
|
@@ -330,7 +358,10 @@ mod needs_docker { | |
// Create user with basic tier | ||
let response = app.post_user("test-user", "basic").await; | ||
assert_eq!(response.status(), StatusCode::OK); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
let user_id = &user.id; | ||
|
||
|
@@ -364,7 +395,11 @@ mod needs_docker { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
assert_eq!(user.account_tier, AccountTier::CancelledPro); | ||
|
||
|
@@ -379,7 +414,11 @@ mod needs_docker { | |
.await; | ||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
let user: user::UserResponse = serde_json::from_slice(&body).unwrap(); | ||
|
||
assert_eq!(user.account_tier, AccountTier::Basic); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,31 +97,45 @@ mod tests { | |
.await | ||
.unwrap(); | ||
assert_eq!(response.status(), StatusCode::OK); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
assert_eq!(&body[..], b"test123"); | ||
|
||
let response = app | ||
.call(Request::get("/__test123").body(Body::empty()).unwrap()) | ||
.await | ||
.unwrap(); | ||
assert_eq!(response.status(), StatusCode::BAD_REQUEST); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
Comment on lines
+112
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: consider extracting this repeated body collection pattern into a helper function to reduce duplication |
||
|
||
assert!(&body[..].starts_with(br#"{"message":"Invalid project name"#)); | ||
|
||
let response = app | ||
.call(Request::get("/test123/123").body(Body::empty()).unwrap()) | ||
.await | ||
.unwrap(); | ||
assert_eq!(response.status(), StatusCode::OK); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
assert_eq!(&body[..], b"test123 123"); | ||
|
||
let response = app | ||
.call(Request::get("/test123/asdf").body(Body::empty()).unwrap()) | ||
.await | ||
.unwrap(); | ||
assert_eq!(response.status(), StatusCode::BAD_REQUEST); | ||
let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
assert!(&body[..].starts_with(br#"{"message":"Invalid URL"#)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,7 +213,6 @@ mod tests { | |
body::Body, extract::Path, http::Request, http::StatusCode, middleware::from_extractor, | ||
response::IntoResponse, routing::get, Router, | ||
}; | ||
use hyper::body; | ||
use tower::ServiceExt; | ||
use tracing::field; | ||
use tracing_fluent_assertions::{AssertionRegistry, AssertionsLayer}; | ||
|
@@ -269,7 +268,10 @@ mod tests { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
Comment on lines
+271
to
+274
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: This change replaces deprecated |
||
|
||
assert_eq!(&body[..], b"hello"); | ||
request_span.assert(); | ||
|
@@ -315,7 +317,10 @@ mod tests { | |
|
||
assert_eq!(response.status(), StatusCode::OK); | ||
|
||
let body = body::to_bytes(response.into_body()).await.unwrap(); | ||
let body = hyper::body::HttpBody::collect(response.into_body()) | ||
.await | ||
.unwrap() | ||
.to_bytes(); | ||
|
||
assert_eq!(&body[..], b"hello ferries"); | ||
request_span.assert(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Using a git dependency for hyper-reverse-proxy could cause build instability. Consider pinning to a specific commit hash rather than branch, or better yet, wait for the WebSocket changes to be merged and use a released version.