@@ -293,9 +293,8 @@ impl PartialVapidSignatureBuilder {
293293mod tests {
294294 use ct_codecs:: { Base64UrlSafeNoPadding , Decoder , Encoder } ;
295295 use http:: Uri ;
296- use jsonwebtoken:: { Algorithm , DecodingKey , EncodingKey , Validation , dangerous:: insecure_decode, decode} ;
297296 use jwt_simple:: {
298- algorithms:: { ES256KeyPair , PS256KeyPair } ,
297+ algorithms:: { ECDSAP256PublicKeyLike , ES256KeyPair , PS256KeyPair } ,
299298 reexports:: coarsetime:: UnixTimeStamp ,
300299 } ;
301300
@@ -379,16 +378,9 @@ mod tests {
379378 ) ;
380379
381380 let keypair = ES256KeyPair :: from_bytes ( & sec1_decode:: parse_pem ( PRIVATE_PEM . as_bytes ( ) ) . unwrap ( ) . key ) . unwrap ( ) ;
382- let public_key = DecodingKey :: from_ec_der ( & keypair. public_key ( ) . to_bytes ( ) ) ;
383-
384- let mut validator = Validation :: new ( Algorithm :: ES256 ) ;
385- let endpoint: Uri = subscription_info. endpoint . parse ( ) . unwrap ( ) ;
386- let audience = format ! ( "{}://{}" , endpoint. scheme_str( ) . unwrap( ) , endpoint. host( ) . unwrap( ) ) ;
387- validator. set_audience ( & [ audience] ) ;
388- let token = decode :: < Claims > ( signature. auth_t , & public_key, & validator) . unwrap ( ) ;
389- let header = serde_json:: to_string ( & token. header ) . unwrap ( ) ;
390- assert_eq ! ( & header, r#"{"typ":"JWT","alg":"ES256"}"# ) ;
391- let claims = serde_json:: to_string ( & token. claims ) . unwrap ( ) ;
381+
382+ let decoded_claims: Claims = keypair. public_key ( ) . verify_token ( & signature. auth_t , None ) . unwrap ( ) ;
383+ let claims = serde_json:: to_string ( & decoded_claims) . unwrap ( ) ;
392384 assert_eq ! (
393385 & claims,
394386 r#"{"iat":1787080601,"exp":1787123801,"nbf":1787080601,"sub":"mailto:example@example.com","aud":"https://updates.push.services.mozilla.com"}"#
0 commit comments