#![cfg(feature = "sso")]
use adk_auth::sso::JwtValidator;
#[test]
fn hmac_algorithms_are_refused_for_jwks_validation() {
let Err(error) = JwtValidator::builder()
.issuer("https://issuer.example.com")
.jwks_uri("https://issuer.example.com/.well-known/jwks.json")
.algorithm(jsonwebtoken::Algorithm::HS256)
.build()
else {
panic!("HS256 cannot be validated with a public key");
};
assert!(error.to_string().contains("not supported"), "{error}");
}
#[test]
fn asymmetric_algorithms_remain_accepted() {
let accepted = JwtValidator::builder()
.issuer("https://issuer.example.com")
.jwks_uri("https://issuer.example.com/.well-known/jwks.json")
.algorithm(jsonwebtoken::Algorithm::RS256)
.algorithm(jsonwebtoken::Algorithm::ES256)
.build()
.is_ok();
assert!(accepted, "RS256 and ES256 are the intended JWKS algorithms");
}