-
Notifications
You must be signed in to change notification settings - Fork 2
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
5 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Hi {{name}} | ||
|
||
Your account has been rejected. | ||
If you think this is a mistake you can contact us at {{admin_email}}. | ||
|
||
Kind regards | ||
The Zeus Authentication Server |
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 |
---|---|---|
|
@@ -788,6 +788,79 @@ async fn user_approval_flow() { | |
.await; | ||
} | ||
|
||
#[rocket::async_test] | ||
async fn user_rejectal_flow() { | ||
common::as_admin(async move |http_client: HttpClient, db, _admin| { | ||
let email = String::from("[email protected]"); | ||
let user = User::create_pending( | ||
NewUser { | ||
username: String::from("user"), | ||
password: String::from("password"), | ||
full_name: String::from("name"), | ||
email: email.clone(), | ||
ssh_key: None, | ||
not_a_robot: true, | ||
}, | ||
&common::config(), | ||
&db, | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
let token = user | ||
.pending_email_token | ||
.as_ref() | ||
.expect("email token") | ||
.clone(); | ||
|
||
let response = http_client | ||
.get(format!("/users/confirm/{}", token)) | ||
.header(Accept::HTML) | ||
.header(ContentType::Form) | ||
.dispatch() | ||
.await; | ||
|
||
assert_eq!(response.status(), Status::Ok); | ||
|
||
let response = | ||
common::expect_mail_to(vec!["admin@localhost"], async || { | ||
http_client | ||
.post("/users/confirm") | ||
.header(Accept::HTML) | ||
.header(ContentType::Form) | ||
.body(format!("token={}", token)) | ||
.dispatch() | ||
.await | ||
}) | ||
.await; | ||
|
||
assert_eq!(response.status(), Status::Ok); | ||
|
||
let user = user.reload(&db).await.expect("reload user"); | ||
|
||
assert_eq!( | ||
user.state, | ||
UserState::PendingApproval, | ||
"after email is confirmed, user should be pending for approval" | ||
); | ||
|
||
common::expect_mail_to(vec![&email], async || { | ||
let response = http_client | ||
.post(format!("/users/{}/reject/", user.username)) | ||
.header(Accept::HTML) | ||
.header(ContentType::Form) | ||
.dispatch() | ||
.await; | ||
|
||
assert_eq!(response.status(), Status::SeeOther); | ||
}) | ||
.await; | ||
|
||
user.reload(&db).await.expect_err("user should be removed"); | ||
}) | ||
.await; | ||
} | ||
|
||
#[rocket::async_test] | ||
async fn refuse_robots() { | ||
common::as_visitor(async move |http_client: HttpClient, db| { | ||
|