Fix license, use more generic test names
This commit is contained in:
parent
6f584f42c8
commit
65e9f336f2
3 changed files with 8 additions and 7 deletions
1
LICENSE
1
LICENSE
|
@ -1,6 +1,7 @@
|
||||||
(The MIT License)
|
(The MIT License)
|
||||||
|
|
||||||
Copyright (c) 2015 Michael Yang <mikkyangg@gmail.com>
|
Copyright (c) 2015 Michael Yang <mikkyangg@gmail.com>
|
||||||
|
Copyright (c) 2017 Thomas Gideon <cmdln@thecommandline.net>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|
|
@ -43,9 +43,9 @@ fn login(token: &str) -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let token = new_token("Michael Yang", "password").unwrap();
|
let token = new_token("Random User", "password").unwrap();
|
||||||
|
|
||||||
let logged_in_user = login(&*token).unwrap();
|
let logged_in_user = login(&*token).unwrap();
|
||||||
|
|
||||||
assert_eq!(logged_in_user, "Michael Yang");
|
assert_eq!(logged_in_user, "Random User");
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,26 +73,26 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from_base64() {
|
fn from_base64() {
|
||||||
let enc = "ew0KICAiaXNzIjogIm1pa2t5YW5nLmNvbSIsDQogICJleHAiOiAxMzAyMzE5MTAwLA0KICAibmFtZSI6ICJNaWNoYWVsIFlhbmciLA0KICAiYWRtaW4iOiB0cnVlDQp9";
|
let enc = "eyJpc3MiOiJleGFtcGxlLmNvbSIsImV4cCI6MTMwMjMxOTEwMH0";
|
||||||
let claims: Claims<EmptyClaim> = Claims::from_base64(enc).unwrap();
|
let claims: Claims<EmptyClaim> = Claims::from_base64(enc).unwrap();
|
||||||
|
|
||||||
assert_eq!(claims.reg.iss.unwrap(), "mikkyang.com");
|
assert_eq!(claims.reg.iss.unwrap(), "example.com");
|
||||||
assert_eq!(claims.reg.exp.unwrap(), 1302319100);
|
assert_eq!(claims.reg.exp.unwrap(), 1302319100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_types() {
|
fn multiple_types() {
|
||||||
let enc = "ew0KICAiaXNzIjogIm1pa2t5YW5nLmNvbSIsDQogICJleHAiOiAxMzAyMzE5MTAwLA0KICAibmFtZSI6ICJNaWNoYWVsIFlhbmciLA0KICAiYWRtaW4iOiB0cnVlDQp9";
|
let enc = "eyJpc3MiOiJleGFtcGxlLmNvbSIsImV4cCI6MTMwMjMxOTEwMH0";
|
||||||
let claims = Registered::from_base64(enc).unwrap();
|
let claims = Registered::from_base64(enc).unwrap();
|
||||||
|
|
||||||
assert_eq!(claims.iss.unwrap(), "mikkyang.com");
|
assert_eq!(claims.iss.unwrap(), "example.com");
|
||||||
assert_eq!(claims.exp.unwrap(), 1302319100);
|
assert_eq!(claims.exp.unwrap(), 1302319100);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn roundtrip() {
|
fn roundtrip() {
|
||||||
let mut claims: Claims<EmptyClaim> = Default::default();
|
let mut claims: Claims<EmptyClaim> = Default::default();
|
||||||
claims.reg.iss = Some("mikkyang.com".into());
|
claims.reg.iss = Some("example.com".into());
|
||||||
claims.reg.exp = Some(1302319100);
|
claims.reg.exp = Some(1302319100);
|
||||||
let enc = claims.to_base64().unwrap();
|
let enc = claims.to_base64().unwrap();
|
||||||
assert_eq!(claims, Claims::from_base64(&*enc).unwrap());
|
assert_eq!(claims, Claims::from_base64(&*enc).unwrap());
|
||||||
|
|
Loading…
Reference in a new issue