Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 07c9989

Browse files
committed
Upgrade async-graphql, fix mas-handlers & mas-axum-utils tests
This also replaces the init_tracing test helper with a general setup test helper, so that it also initializes the rustls crypto backend.
1 parent e7f50a9 commit 07c9989

File tree

23 files changed

+152
-145
lines changed

23 files changed

+152
-145
lines changed

Cargo.lock

Lines changed: 49 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ oauth2-types = { path = "./crates/oauth2-types/", version = "=0.9.0" }
5757

5858
# GraphQL server
5959
[workspace.dependencies.async-graphql]
60-
version = "6.0.11"
60+
version = "7.0.6"
6161
features = ["chrono", "url", "tracing"]
6262

6363
# Utility to write and implement async traits

crates/axum-utils/src/client_authorization.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ where
489489

490490
#[cfg(test)]
491491
mod tests {
492-
use axum::body::{Bytes, Full};
492+
use axum::body::Body;
493493
use http::{Method, Request};
494494

495495
use super::*;
@@ -502,7 +502,7 @@ mod tests {
502502
http::header::CONTENT_TYPE,
503503
mime::APPLICATION_WWW_FORM_URLENCODED.as_ref(),
504504
)
505-
.body(Full::<Bytes>::new("client_id=client-id&foo=bar".into()))
505+
.body(Body::new("client_id=client-id&foo=bar".to_owned()))
506506
.unwrap();
507507

508508
assert_eq!(
@@ -530,7 +530,7 @@ mod tests {
530530
http::header::AUTHORIZATION,
531531
"Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=",
532532
)
533-
.body(Full::<Bytes>::new("foo=bar".into()))
533+
.body(Body::new("foo=bar".to_owned()))
534534
.unwrap();
535535

536536
assert_eq!(
@@ -557,7 +557,7 @@ mod tests {
557557
http::header::AUTHORIZATION,
558558
"Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=",
559559
)
560-
.body(Full::<Bytes>::new("client_id=client-id&foo=bar".into()))
560+
.body(Body::new("client_id=client-id&foo=bar".to_owned()))
561561
.unwrap();
562562

563563
assert_eq!(
@@ -584,7 +584,7 @@ mod tests {
584584
http::header::AUTHORIZATION,
585585
"Basic Y2xpZW50LWlkOmNsaWVudC1zZWNyZXQ=",
586586
)
587-
.body(Full::<Bytes>::new("client_id=mismatch-id&foo=bar".into()))
587+
.body(Body::new("client_id=mismatch-id&foo=bar".to_owned()))
588588
.unwrap();
589589

590590
assert!(matches!(
@@ -600,7 +600,7 @@ mod tests {
600600
mime::APPLICATION_WWW_FORM_URLENCODED.as_ref(),
601601
)
602602
.header(http::header::AUTHORIZATION, "Basic invalid")
603-
.body(Full::<Bytes>::new("foo=bar".into()))
603+
.body(Body::new("foo=bar".to_owned()))
604604
.unwrap();
605605

606606
assert!(matches!(
@@ -617,8 +617,8 @@ mod tests {
617617
http::header::CONTENT_TYPE,
618618
mime::APPLICATION_WWW_FORM_URLENCODED.as_ref(),
619619
)
620-
.body(Full::<Bytes>::new(
621-
"client_id=client-id&client_secret=client-secret&foo=bar".into(),
620+
.body(Body::new(
621+
"client_id=client-id&client_secret=client-secret&foo=bar".to_owned(),
622622
))
623623
.unwrap();
624624

@@ -640,7 +640,7 @@ mod tests {
640640
async fn client_assertion_test() {
641641
// Signed with client_secret = "client-secret"
642642
let jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjbGllbnQtaWQiLCJzdWIiOiJjbGllbnQtaWQiLCJhdWQiOiJodHRwczovL2V4YW1wbGUuY29tL29hdXRoMi9pbnRyb3NwZWN0IiwianRpIjoiYWFiYmNjIiwiZXhwIjoxNTE2MjM5MzIyLCJpYXQiOjE1MTYyMzkwMjJ9.XTaACG_Rww0GPecSZvkbem-AczNy9LLNBueCLCiQajU";
643-
let body = Bytes::from(format!(
643+
let body = Body::new(format!(
644644
"client_assertion_type={JWT_BEARER_CLIENT_ASSERTION}&client_assertion={jwt}&foo=bar",
645645
));
646646

@@ -650,7 +650,7 @@ mod tests {
650650
http::header::CONTENT_TYPE,
651651
mime::APPLICATION_WWW_FORM_URLENCODED.as_ref(),
652652
)
653-
.body(Full::new(body))
653+
.body(body)
654654
.unwrap();
655655

656656
let authz = ClientAuthorization::<serde_json::Value>::from_request(req, &())

crates/handlers/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ tower-http.workspace = true
3434
axum.workspace = true
3535
axum-macros = "0.4.1"
3636
axum-extra.workspace = true
37+
rustls.workspace = true
3738

3839
async-graphql.workspace = true
3940

crates/handlers/src/compat/login.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use axum::{extract::State, response::IntoResponse, Json, TypedHeader};
15+
use axum::{extract::State, response::IntoResponse, Json};
16+
use axum_extra::typed_header::TypedHeader;
1617
use chrono::Duration;
1718
use hyper::StatusCode;
1819
use mas_axum_utils::sentry::SentryEventID;
@@ -433,12 +434,12 @@ mod tests {
433434
use sqlx::PgPool;
434435

435436
use super::*;
436-
use crate::test_utils::{init_tracing, RequestBuilderExt, ResponseExt, TestState};
437+
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
437438

438439
/// Test that the server advertises the right login flows.
439440
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
440441
async fn test_get_login(pool: PgPool) {
441-
init_tracing();
442+
setup();
442443
let state = TestState::from_pool(pool).await.unwrap();
443444

444445
// Now let's get the login flows
@@ -470,7 +471,7 @@ mod tests {
470471
/// manager is disabled
471472
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
472473
async fn test_password_disabled(pool: PgPool) {
473-
init_tracing();
474+
setup();
474475
let state = {
475476
let mut state = TestState::from_pool(pool).await.unwrap();
476477
state.password_manager = PasswordManager::disabled();
@@ -518,7 +519,7 @@ mod tests {
518519
/// compatibility API.
519520
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
520521
async fn test_user_password_login(pool: PgPool) {
521-
init_tracing();
522+
setup();
522523
let state = TestState::from_pool(pool).await.unwrap();
523524

524525
// Let's provision a user and add a password to it. This part is hard to test
@@ -633,7 +634,7 @@ mod tests {
633634
/// Test the response of an unsupported login flow.
634635
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
635636
async fn test_unsupported_login(pool: PgPool) {
636-
init_tracing();
637+
setup();
637638
let state = TestState::from_pool(pool).await.unwrap();
638639

639640
// Try to login with an unsupported login flow.
@@ -650,7 +651,7 @@ mod tests {
650651
/// Test `m.login.token` login flow.
651652
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
652653
async fn test_login_token_login(pool: PgPool) {
653-
init_tracing();
654+
setup();
654655
let state = TestState::from_pool(pool).await.unwrap();
655656

656657
// Provision a user

crates/handlers/src/compat/logout.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use axum::{response::IntoResponse, Json, TypedHeader};
15+
use axum::{response::IntoResponse, Json};
16+
use axum_extra::typed_header::TypedHeader;
1617
use headers::{authorization::Bearer, Authorization};
1718
use hyper::StatusCode;
1819
use mas_axum_utils::sentry::SentryEventID;

0 commit comments

Comments
 (0)