diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-06-17 23:22:07 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-06-17 23:22:07 -0400 |
commit | a1a820f60999c7db81731c0c92efcbb90932c0f6 (patch) | |
tree | af72d115ba1595344b6e78890db8fc56da3482c8 /src/auth | |
parent | 9bd1a176e4eb83ee54efc462b319537a5efe1603 (diff) |
fix: Authentication unit test.
Diffstat (limited to 'src/auth')
-rw-r--r-- | src/auth/mod.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/auth/mod.rs b/src/auth/mod.rs index 2f4c313..723427c 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -19,9 +19,6 @@ pub fn encode(salt: &str, pw: &str) -> HashedPassword { } pub fn validate(pw: &str, enc: &HashedPassword) -> bool { - // let cs = enc.split('$'); - // println("{:?}", cs.len()); - // let enc_pw = cs[3]; encode(enc.salt.as_str(), pw) == *enc } @@ -30,7 +27,12 @@ mod tests { use super::*; #[test] fn it_validates() { - assert_eq!(false, validate("hello", "123", "123")); - assert_eq!(true, validate("hello", "123", &encode("hello", "123"))); + assert_eq!(false, + validate("hello", + &HashedPassword { + salt: String::from("123"), + enc: String::from("123"), + })); + assert_eq!(true, validate("123", &encode("hello", "123"))); } } |