Add test for decode without validating signature
This commit is contained in:
parent
410499e6b6
commit
50d676865f
|
@ -2,7 +2,6 @@
|
|||
//!
|
||||
#![recursion_limit = "300"]
|
||||
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
#[macro_use]
|
||||
|
@ -29,3 +28,10 @@ pub use crypto::{
|
|||
decode,
|
||||
};
|
||||
pub use validation::Validation;
|
||||
|
||||
// To consider:
|
||||
//pub mod prelude {
|
||||
// pub use crypto::{Algorithm, encode, decode};
|
||||
// pub use validation::Validation;
|
||||
// pub use header::Header;
|
||||
//}
|
||||
|
|
|
@ -95,3 +95,11 @@ fn decode_token_with_shuffled_header_fields() {
|
|||
let claims = decode::<Claims>(token, "secret".as_ref(), Algorithm::HS256, Validation::default());
|
||||
assert!(claims.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decode_without_validating_signature() {
|
||||
let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb21wYW55IjoiMTIzNDU2Nzg5MCIsInN1YiI6IkpvaG4gRG9lIn0.S";
|
||||
let claims = decode::<Claims>(token, "secret".as_ref(), Algorithm::HS256, Validation {validate_signature: false, ..Validation::default()});
|
||||
assert!(claims.is_ok());
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue