diff --git a/benches/impl_path_string_for_evaluation_context.rs b/benches/impl_path_string_for_evaluation_context.rs index e25532c028..acc32d0a32 100644 --- a/benches/impl_path_string_for_evaluation_context.rs +++ b/benches/impl_path_string_for_evaluation_context.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; use std::collections::BTreeMap; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; use std::time::Duration; use async_graphql::{Name, Value}; @@ -258,7 +258,8 @@ fn request_context() -> RequestContext { } pub fn bench_main(c: &mut Criterion) { - let mut req_ctx = request_context().allowed_headers(TEST_HEADERS.clone()); + let mut req_ctx = + request_context().allowed_headers(Arc::new(RwLock::new(TEST_HEADERS.clone()))); req_ctx.server.vars = TEST_VARS.clone(); let eval_ctx = EvalContext::new(&req_ctx, &MockGraphqlContext); diff --git a/src/core/auth/basic.rs b/src/core/auth/basic.rs index 391541cc78..908c2ca3e3 100644 --- a/src/core/auth/basic.rs +++ b/src/core/auth/basic.rs @@ -65,11 +65,11 @@ testuser3:{SHA}Y2fEjdGT1W6nsLqtJbGUVeUp9e4= } pub fn create_basic_auth_request(username: &str, password: &str) -> RequestContext { - let mut req_context = RequestContext::default(); + let req_context = RequestContext::default(); req_context .allowed_headers - .read() + .write() .unwrap() .typed_insert(Authorization::basic(username, password)); @@ -122,8 +122,8 @@ testuser3:{SHA}Y2fEjdGT1W6nsLqtJbGUVeUp9e4= #[tokio::test] async fn verify_auth_failure() { let provider = setup_provider(); - let mut req_ctx = RequestContext::default(); - req_ctx.allowed_headers.lock().unwrap().insert( + let req_ctx = RequestContext::default(); + req_ctx.allowed_headers.write().unwrap().insert( "Authorization", HeaderValue::from_static("Basic dGVzdHVzZXIyOm15cGFzc3dvcmQ"), ); diff --git a/src/core/auth/jwt/jwt_verify.rs b/src/core/auth/jwt/jwt_verify.rs index be9a183bd3..126fc72cf6 100644 --- a/src/core/auth/jwt/jwt_verify.rs +++ b/src/core/auth/jwt/jwt_verify.rs @@ -166,11 +166,11 @@ pub mod tests { } pub fn create_jwt_auth_request(token: &str) -> RequestContext { - let mut req_context = RequestContext::default(); + let req_context = RequestContext::default(); req_context .allowed_headers - .read() + .write() .unwrap() .typed_insert(Authorization::bearer(token).unwrap()); diff --git a/src/core/path.rs b/src/core/path.rs index f475319ea0..60b5cb59aa 100644 --- a/src/core/path.rs +++ b/src/core/path.rs @@ -134,7 +134,7 @@ mod tests { mod evaluation_context { use std::borrow::Cow; use std::collections::BTreeMap; - use std::sync::Arc; + use std::sync::{Arc, RwLock}; use async_graphql_value::{ConstValue as Value, Name, Number}; use hyper::header::HeaderValue; @@ -242,7 +242,8 @@ mod tests { } static REQ_CTX: Lazy = Lazy::new(|| { - let mut req_ctx = RequestContext::default().allowed_headers(TEST_HEADERS.clone()); + let mut req_ctx = RequestContext::default() + .allowed_headers(Arc::new(RwLock::new(TEST_HEADERS.clone()))); req_ctx.server.vars = TEST_VARS.clone(); req_ctx.runtime.env = Arc::new(Env::init(TEST_ENV_VARS.clone()));