mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-11 23:50:07 +01:00
fix: from_ec, from_ed (#3)
* fix: from_ec, from_ed * chore: fix clippy warnings
This commit is contained in:
parent
1579676948
commit
28c7eedcd5
3 changed files with 11 additions and 12 deletions
|
|
@ -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::<Value>::build(&&KeySourceType::Jwks("://xxxx".to_owned()), None, None).await;
|
||||
let a = Authorizer::<Value>::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::<Value>::build(&&KeySourceType::Discovery("://xxxx".to_owned()), None, None).await;
|
||||
let a = Authorizer::<Value>::build(&KeySourceType::Discovery("://xxxx".to_owned()), None, None).await;
|
||||
println!("{:?}", a.as_ref().err());
|
||||
assert!(a.is_err());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ impl Stats {
|
|||
|
||||
fn discovery(uri: &str) -> Json<Value> {
|
||||
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<User> = JwtAuthorizer::from_oidc(&url).refresh(refresh);
|
||||
let mut app = app(auth).await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue