diff options
author | Yigit Sever | 2021-04-16 02:02:47 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-16 02:02:47 +0300 |
commit | d69e68cd4ed0e74e0f857bfdf35a849d3c1a245d (patch) | |
tree | a025bcde968d97ae2c9fbe70595eb45899702478 /tests/route_tests.rs | |
parent | 9ff7728654205041fc4dddc2b896b6bd8f6e6c88 (diff) | |
download | gradecoin-d69e68cd4ed0e74e0f857bfdf35a849d3c1a245d.tar.gz gradecoin-d69e68cd4ed0e74e0f857bfdf35a849d3c1a245d.tar.bz2 gradecoin-d69e68cd4ed0e74e0f857bfdf35a849d3c1a245d.zip |
Add correct /register test stub
Diffstat (limited to 'tests/route_tests.rs')
-rw-r--r-- | tests/route_tests.rs | 68 |
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> // |