From 3edf5d60f54bfd0cd2c818e5fb1ca133e324325d Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Thu, 30 Dec 2021 11:45:59 +0100 Subject: rename to planetwars-server --- backend/tests/login.rs | 61 -------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 backend/tests/login.rs (limited to 'backend/tests/login.rs') diff --git a/backend/tests/login.rs b/backend/tests/login.rs deleted file mode 100644 index 60c5d6f..0000000 --- a/backend/tests/login.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![feature(async_closure)] -extern crate mozaic4_backend; - -use rocket::http::{ContentType, Status}; - -mod util; -use util::run_test; - -#[rocket::async_test] -async fn test_registration() { - run_test(async move |client, _conn| { - let response = client - .post("/register") - .header(ContentType::JSON) - .body(r#"{"username": "piepkonijn", "password": "geheim123"}"#) - .dispatch() - .await; - - assert_eq!(response.status(), Status::Ok); - assert_eq!(response.content_type(), Some(ContentType::JSON)); - - let response = client - .post("/login") - .header(ContentType::JSON) - .body(r#"{"username": "piepkonijn", "password": "geheim123"}"#) - .dispatch() - .await; - - assert_eq!(response.status(), Status::Ok); - let token = response.into_string().await.unwrap(); - - let response = client - .get("/users/me") - .header(util::BearerAuth::new(token)) - .dispatch() - .await; - - assert_eq!(response.status(), Status::Ok); - assert_eq!(response.content_type(), Some(ContentType::JSON)); - let resp = response.into_string().await.unwrap(); - let json: serde_json::Value = serde_json::from_str(&resp).unwrap(); - assert_eq!(json["username"], "piepkonijn"); - }) - .await -} - -#[rocket::async_test] -async fn test_reject_invalid_credentials() { - run_test(async move |client, _conn| { - let response = client - .post("/login") - .header(ContentType::JSON) - .body(r#"{"username": "piepkonijn", "password": "letmeinplease"}"#) - .dispatch() - .await; - - assert_eq!(response.status(), Status::Forbidden); - // assert_eq!(response.content_type(), Some(ContentType::JSON)); - }) - .await -} -- cgit v1.2.3