()
| 178 | #[test] |
| 179 | #[wasm_bindgen_test] |
| 180 | fn decode_token_custom_headers() { |
| 181 | let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImtpZCIsImN1c3RvbTEiOiJoZWFkZXIxIiwiY3VzdG9tMiI6ImhlYWRlcjIifQ.eyJzdWIiOiJiQGIuY29tIiwiY29tcGFueSI6IkFDTUUiLCJleHAiOjI1MzI1MjQ4OTF9.FtOHsoKcNH3SriK3tnR-uWJg4UV4FkOzvq_JCfLngfU"; |
| 182 | let claims = decode::<Claims>( |
| 183 | token, |
| 184 | &DecodingKey::from_secret(b"secret"), |
| 185 | &Validation::new(Algorithm::HS256), |
| 186 | ) |
| 187 | .unwrap(); |
| 188 | let my_claims = |
| 189 | Claims { sub: "b@b.com".to_string(), company: "ACME".to_string(), exp: 2532524891 }; |
| 190 | assert_eq!(my_claims, claims.claims); |
| 191 | assert_eq!("kid", claims.header.kid.unwrap()); |
| 192 | let extras = claims.header.extras; |
| 193 | assert_eq!(Some("header1".to_string()), extras.get("custom1").unwrap()); |
| 194 | assert_eq!(Some("header2".to_string()), extras.get("custom2").unwrap()); |
| 195 | } |
| 196 | |
| 197 | #[test] |
| 198 | #[wasm_bindgen_test] |
nothing calls this directly
no outgoing calls
no test coverage detected