aboutsummaryrefslogtreecommitdiffstats
path: root/tests/route_tests.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-16 02:02:47 +0300
committerYigit Sever2021-04-16 02:02:47 +0300
commit52b8bbff667c87465dfb18b99a65618ef1750fff (patch)
tree7b40908299e28b0e2c6cd06935f6cdfdde6d7c5f /tests/route_tests.rs
parentd45c5de41dcaa44fc0e65ed103fa62f48c1c40dc (diff)
downloadgradecoin-52b8bbff667c87465dfb18b99a65618ef1750fff.tar.gz
gradecoin-52b8bbff667c87465dfb18b99a65618ef1750fff.tar.bz2
gradecoin-52b8bbff667c87465dfb18b99a65618ef1750fff.zip
Add correct /register test stub
Diffstat (limited to 'tests/route_tests.rs')
-rw-r--r--tests/route_tests.rs68
1 files changed, 36 insertions, 32 deletions
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index 09aa10e..74ebebc 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -313,42 +313,42 @@ sQIDAQAB
313 /// 313 ///
314 /// Should accept the json request, create a new user and 314 /// Should accept the json request, create a new user and
315 /// add it to the user hashmap in the db 315 /// add it to the user hashmap in the db
316 #[tokio::test] 316 // #[tokio::test]
317 async fn post_register_priviliged_user() { 317 // async fn post_register_priviliged_user() {
318 let db = mocked_db(); 318 // let db = mocked_db();
319 let filter = consensus_routes(db.clone()); 319 // let filter = consensus_routes(db.clone());
320 320
321 let res = warp::test::request() 321 // let res = warp::test::request()
322 .method("POST") 322 // .method("POST")
323 .json(&priviliged_mocked_user()) 323 // .json(&priviliged_mocked_user())
324 .path("/register") 324 // .path("/register")
325 .reply(&filter) 325 // .reply(&filter)
326 .await; 326 // .await;
327 327
328 println!("{:?}", res.body()); 328 // println!("{:?}", res.body());
329 assert_eq!(res.status(), StatusCode::CREATED); 329 // assert_eq!(res.status(), StatusCode::CREATED);
330 assert_eq!(db.users.read().len(), 2); 330 // assert_eq!(db.users.read().len(), 2);
331 } 331 // }
332 332
333 /// Test a POST request to /transaction, an endpoint that exists 333 /// Test a POST request to /transaction, an endpoint that exists
334 /// https://tools.ietf.org/html/rfc7231#section-6.3.2 334 /// https://tools.ietf.org/html/rfc7231#section-6.3.2
335 /// Should NOT accept the json request as the user is unpriviliged 335 /// Should NOT accept the json request as the user is unpriviliged
336 #[tokio::test] 336 // #[tokio::test]
337 async fn post_register_unpriviliged_user() { 337 // async fn post_register_unpriviliged_user() {
338 let db = mocked_db(); 338 // let db = mocked_db();
339 let filter = consensus_routes(db.clone()); 339 // let filter = consensus_routes(db.clone());
340 340
341 let res = warp::test::request() 341 // let res = warp::test::request()
342 .method("POST") 342 // .method("POST")
343 .json(&unpriviliged_mocked_user()) 343 // .json(&unpriviliged_mocked_user())
344 .path("/register") 344 // .path("/register")
345 .reply(&filter) 345 // .reply(&filter)
346 .await; 346 // .await;
347 347
348 println!("{:?}", res.body()); 348 // println!("{:?}", res.body());
349 assert_eq!(res.status(), StatusCode::BAD_REQUEST); 349 // assert_eq!(res.status(), StatusCode::BAD_REQUEST);
350 assert_eq!(db.users.read().len(), 1); 350 // assert_eq!(db.users.read().len(), 1);
351 } 351 // }
352 352
353 /// Test a POST request to /transaction, an endpoint that exists with a longer than expected 353 /// Test a POST request to /transaction, an endpoint that exists with a longer than expected
354 /// payload 354 /// payload
@@ -370,6 +370,10 @@ sQIDAQAB
370 370
371 assert_eq!(res.status(), StatusCode::PAYLOAD_TOO_LARGE); 371 assert_eq!(res.status(), StatusCode::PAYLOAD_TOO_LARGE);
372 } 372 }
373
374 /// Test the User Authentication Process
375 #[tokio::test]
376 async fn user_authentication() {}
373} 377}
374 378
375// TODO: POST block without correct transactions test <09-04-21, yigit> // 379// TODO: POST block without correct transactions test <09-04-21, yigit> //