Switch to failure (#6)

* Switch to failure

* Bump version
This commit is contained in:
Thomas Gideon 2018-11-16 17:28:01 -05:00 committed by GitHub
parent 1b594ff60e
commit 7fcae534f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 118 deletions

View file

@ -1,6 +1,5 @@
use super::Result;
use base64::{decode_config, encode_config, URL_SAFE_NO_PAD};
use error::Error;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_json;
@ -68,7 +67,7 @@ impl<T: Serialize + DeserializeOwned> Payload<T> {
let enc = encode_config((&*s).as_bytes(), URL_SAFE_NO_PAD);
Ok(enc)
} else {
Err(Error::Custom("Could not access custom claims.".to_owned()))
Err(format_err!("Could not access custom claims."))
}
}
None => {
@ -78,9 +77,7 @@ impl<T: Serialize + DeserializeOwned> Payload<T> {
}
}
} else {
Err(Error::Custom(
"Could not access standard claims.".to_owned(),
))
Err(format_err!("Could not access standard claims.",))
}
}
@ -234,10 +231,10 @@ mod tests {
fn create_default() -> DefaultPayload {
DefaultPayload {
aud: Some("login_service".into()),
iat: Some(1302317100),
iat: Some(1_302_317_100),
iss: Some("example.com".into()),
exp: Some(1302319100),
nbf: Some(1302317100),
exp: Some(1_302_319_100),
nbf: Some(1_302_317_100),
sub: Some("Random User".into()),
..Default::default()
}
@ -246,8 +243,8 @@ mod tests {
fn create_custom() -> Payload<CustomClaims> {
Payload {
iss: Some("example.com".into()),
iat: Some(1302317100),
exp: Some(1302319100),
iat: Some(1_302_317_100),
exp: Some(1_302_319_100),
claims: Some(CustomClaims {
user_id: "123456".into(),
is_admin: false,