From a1a820f60999c7db81731c0c92efcbb90932c0f6 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 17 Jun 2017 23:22:07 -0400 Subject: fix: Authentication unit test. --- src/auth/mod.rs | 12 +++++++----- 1 file 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"))); } } -- cgit v1.2.3