-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use reqwest::StatusCode; | ||
|
||
use commune::account::service::CreateAccountDto; | ||
use commune_server::router::api::v1::account::login::{AccountLoginPayload, AccountLoginResponse}; | ||
|
||
use crate::tools::environment::Environment; | ||
use crate::tools::http::HttpClient; | ||
|
||
#[tokio::test] | ||
async fn logs_into_account() { | ||
let environment = Environment::new().await; | ||
|
||
let username = "lucy".to_string(); | ||
let password = "P@ssW0Rd$".to_string(); | ||
|
||
environment | ||
.commune | ||
.account | ||
.register(CreateAccountDto { | ||
username: username.clone(), | ||
password: password.clone().into(), | ||
email: "lucyinthesky@gmail.com".to_string(), | ||
session: "TEST".to_string(), | ||
code: "TEST".to_string(), | ||
}) | ||
.await | ||
.unwrap(); | ||
|
||
let http_client = HttpClient::new().await; | ||
|
||
let response = http_client | ||
.post("/api/v1/account/login") | ||
.json(&AccountLoginPayload { username, password }) | ||
.send() | ||
.await; | ||
let response_status = response.status(); | ||
let response_payload = response.json::<AccountLoginResponse>().await; | ||
|
||
assert_eq!( | ||
response_status, | ||
StatusCode::OK, | ||
"should return 200 for successful login" | ||
); | ||
assert!(!response_payload.access_token.is_empty(),) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod create; | ||
mod login; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters