aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2021-04-16 03:55:27 +0300
committerYigit Sever2021-04-16 03:55:27 +0300
commit004b069ed31fcada5172ee351800979d91d578c0 (patch)
treee8f039de2b35cb2ef58f01e931e050be438c648e
parent752b05888c3309538a9a8fd3b87b8dd6b510e37e (diff)
downloadgradecoin-004b069ed31fcada5172ee351800979d91d578c0.tar.gz
gradecoin-004b069ed31fcada5172ee351800979d91d578c0.tar.bz2
gradecoin-004b069ed31fcada5172ee351800979d91d578c0.zip
Writing auth test
-rw-r--r--src/handlers.rs1
-rw-r--r--tests/route_tests.rs19
2 files changed, 19 insertions, 1 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index 88f9a80..3b62ef8 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -139,6 +139,7 @@ pub async fn authenticate_user(
139 } 139 }
140 }; 140 };
141 141
142 // TODO: request iv is coming with base64 encoding <16-04-21, yigit> //
142 let cipher = match Aes128Cbc::new_var(&temp_key, &request.iv.as_bytes()) { 143 let cipher = match Aes128Cbc::new_var(&temp_key, &request.iv.as_bytes()) {
143 Ok(c) => c, 144 Ok(c) => c,
144 Err(err) => { 145 Err(err) => {
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index 59483d3..a1531bb 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -1,6 +1,8 @@
1#[cfg(test)] 1#[cfg(test)]
2mod tests { 2mod tests {
3 use gradecoin::schema::{create_database, AuthRequest, Block, Db, MetuId, Transaction, User}; 3 use gradecoin::schema::{
4 create_database, AuthRequest, Block, Db, InitialAuthRequest, MetuId, Transaction, User,
5 };
4 6
5 use gradecoin::routes::consensus_routes; 7 use gradecoin::routes::consensus_routes;
6 use warp::http::StatusCode; 8 use warp::http::StatusCode;
@@ -406,6 +408,21 @@ FQIDAQAB
406 #[tokio::test] 408 #[tokio::test]
407 async fn user_authentication() { 409 async fn user_authentication() {
408 let db = mocked_db(); 410 let db = mocked_db();
411 let filter = consensus_routes(db);
412
413 let res = warp::test::request()
414 .method("POST")
415 .json(&InitialAuthRequest {
416 c: "llqkPAX8oGxBLFHGMNzwrCAP2WmsGZlOcm3mCp7+ZnX9p7BPffRvGcYHpif4htwU5RyR3fLo/VWERXqddVQkxhfuum0dFn1cpPfYTokc2BHpi61i4SXCaCHlJDxCtCKnujfEzMnS5hAKMQSyrwq/DPBwOSQ/XQeeMB0YF+l+ZfVJ8e6sQ5FfSK9rSInv+TokA7az6vR7Ky5fGjQ0GxKkO+SKLd5eHuGKgQ19JUQrj3k19GJn1h1cmWW1PYqVKFDp/RfWFL9weG8VynRND6xGK5fQarjdG0uMAk8Cy8ItOCAeMnBhUv/P2a721u3tA7L496r4E3ZwdgsiHe4iYzFiAdvWDWsLRlxXS+6Q2vUYSLgcFVsv2jyQ28c/ay3F1hYAHaqN4HiDhKz6bFCiyow1Doya2V24VQm5eUGxXErjEnLY1FWE5sqRn6DUnES3FT8VJoMtnhCFtZhO4Jk0cjh15p9r+vK6uJv0PUCKOOYhghFi5bLL34OpmzoV7u7Fj6tSc/e9UujbCfYc3r9g0oUQ+QKxw6R5Fcqf21TbffxX/i1tKElIhkatfWCaZ+c0scLNL4Jg3KbNqbensOFqzErr12pXHFy7QKXH1usnCJyC+9D7NncxKZ9JuVFJL19Ayq90o/IYWhtVlkhZs/F5UPIhl3G7f8OQ1tUgfdCfiXZ5qgg=".to_owned(),
417 iv: "RbZzPxu1IL+f+PZ/SJzi/Q==".to_owned(),
418 key: "baz".to_owned(),
419 })
420 .path("/register")
421 .reply(&filter)
422 .await;
423
424 println!("{:?}", res);
425 assert_eq!(res.status(), StatusCode::CREATED);
409 } 426 }
410} 427}
411 428