diff --git a/jwt-authorizer/src/authorizer.rs b/jwt-authorizer/src/authorizer.rs index 1af2a79..1c24989 100644 --- a/jwt-authorizer/src/authorizer.rs +++ b/jwt-authorizer/src/authorizer.rs @@ -74,14 +74,14 @@ where } } KeySourceType::EC(path) => { - let key = DecodingKey::from_ec_der(&read_data(path.as_str())?); + let key = DecodingKey::from_ec_pem(&read_data(path.as_str())?)?; Authorizer { key_source: KeySource::DecodingKeySource(key), claims_checker, } } KeySourceType::ED(path) => { - let key = DecodingKey::from_ed_der(&read_data(path.as_str())?); + let key = DecodingKey::from_ed_pem(&read_data(path.as_str())?)?; Authorizer { key_source: KeySource::DecodingKeySource(key), claims_checker, @@ -208,14 +208,14 @@ mod tests { #[tokio::test] async fn build_jwks_url_error() { - let a = Authorizer::::build(&&KeySourceType::Jwks("://xxxx".to_owned()), None, None).await; + let a = Authorizer::::build(&KeySourceType::Jwks("://xxxx".to_owned()), None, None).await; println!("{:?}", a.as_ref().err()); assert!(a.is_err()); } #[tokio::test] async fn build_discovery_url_error() { - let a = Authorizer::::build(&&KeySourceType::Discovery("://xxxx".to_owned()), None, None).await; + let a = Authorizer::::build(&KeySourceType::Discovery("://xxxx".to_owned()), None, None).await; println!("{:?}", a.as_ref().err()); assert!(a.is_err()); } diff --git a/jwt-authorizer/src/jwks/key_store_manager.rs b/jwt-authorizer/src/jwks/key_store_manager.rs index 27975bb..8d31ce2 100644 --- a/jwt-authorizer/src/jwks/key_store_manager.rs +++ b/jwt-authorizer/src/jwks/key_store_manager.rs @@ -265,7 +265,7 @@ mod tests { // FAIL, NO LOAD let ks = KeyStore { jwks: jsonwebtoken::jwk::JwkSet { keys: vec![] }, - fail_time: Some(Instant::now() - Duration::from_secs(5)), + fail_time: Instant::now().checked_sub(Duration::from_secs(5)), load_time: None, }; assert!(ks.can_refresh(Duration::from_secs(0), Duration::from_secs(4))); @@ -275,7 +275,7 @@ mod tests { let ks = KeyStore { jwks: jsonwebtoken::jwk::JwkSet { keys: vec![] }, fail_time: None, - load_time: Some(Instant::now() - Duration::from_secs(5)), + load_time: Instant::now().checked_sub(Duration::from_secs(5)), }; assert!(ks.can_refresh(Duration::from_secs(4), Duration::from_secs(0))); assert!(!ks.can_refresh(Duration::from_secs(6), Duration::from_secs(0))); @@ -283,8 +283,8 @@ mod tests { // FAIL, LOAD let ks = KeyStore { jwks: jsonwebtoken::jwk::JwkSet { keys: vec![] }, - fail_time: Some(Instant::now() - Duration::from_secs(5)), - load_time: Some(Instant::now() - Duration::from_secs(10)), + fail_time: Instant::now().checked_sub(Duration::from_secs(5)), + load_time: Instant::now().checked_sub(Duration::from_secs(10)), }; assert!(ks.can_refresh(Duration::from_secs(6), Duration::from_secs(4))); assert!(!ks.can_refresh(Duration::from_secs(11), Duration::from_secs(4))); @@ -324,7 +324,7 @@ mod tests { .and(path("/")) .respond_with(ResponseTemplate::new(200).set_body_json(&jwks)) .expect(1) - .mount(&mock_server) + .mount(mock_server) .await; } @@ -333,7 +333,7 @@ mod tests { .and(path("/")) .respond_with(ResponseTemplate::new(500)) .expect(1) - .mount(&mock_server) + .mount(mock_server) .await; } diff --git a/jwt-authorizer/tests/integration_tests.rs b/jwt-authorizer/tests/integration_tests.rs index 3445506..2494852 100644 --- a/jwt-authorizer/tests/integration_tests.rs +++ b/jwt-authorizer/tests/integration_tests.rs @@ -91,7 +91,7 @@ impl Stats { fn discovery(uri: &str) -> Json { Arc::clone(&DISCOVERY_COUNTER).fetch_add(1, Ordering::Relaxed); - let d = serde_json::json!({ "jwks_uri": format!("{}/jwks", uri) }); + let d = serde_json::json!({ "jwks_uri": format!("{uri}/jwks") }); Json(d) } @@ -287,7 +287,6 @@ async fn scenario4() { strategy: RefreshStrategy::NoRefresh, refresh_interval: Duration::from_millis(0), retry_interval: Duration::from_millis(0), - ..Default::default() }; let auth: JwtAuthorizer = JwtAuthorizer::from_oidc(&url).refresh(refresh); let mut app = app(auth).await;