tests for the ci metrics, builder and hive forge accounts
This commit is contained in:
parent
c1234973be
commit
3032f34269
1 changed files with 493 additions and 1 deletions
|
|
@ -309,4 +309,49 @@ mod tests {
|
|||
assert_eq!(body["max_repo_creation"], 0);
|
||||
assert_eq!(body["allow_create_organization"], false);
|
||||
}
|
||||
|
||||
/// The account is created, its email checked, and it is locked out of
|
||||
/// creating repos and organizations, in that order.
|
||||
#[tokio::test]
|
||||
async fn the_account_is_created_and_locked_out_of_creating_repos() {
|
||||
use super::super::tests::{lockdown_patch, stub_forge, writes};
|
||||
|
||||
let (client, seen) = stub_forge(
|
||||
(201, "{}"),
|
||||
(200, r#"{"email":"builder@services.hyperhive.local"}"#),
|
||||
(200, "{}"),
|
||||
)
|
||||
.await;
|
||||
client.ensure_builder_user().await.unwrap();
|
||||
let lock = lockdown_patch(&seen, LOGIN).expect("lockdown sent");
|
||||
assert_eq!(lock["max_repo_creation"], 0);
|
||||
assert_eq!(lock["allow_create_organization"], false);
|
||||
assert_eq!(lock["login_name"], LOGIN);
|
||||
assert_eq!(
|
||||
writes(&seen),
|
||||
[
|
||||
"POST /api/v1/admin/users".to_owned(),
|
||||
format!("PATCH /api/v1/admin/users/{LOGIN}")
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_refused_create_or_lockdown_fails_the_job() {
|
||||
use super::super::tests::stub_forge;
|
||||
|
||||
let email = (200, r#"{"email":"builder@services.hyperhive.local"}"#);
|
||||
let (client, seen) = stub_forge((500, r#"{"message":"x"}"#), email, (200, "{}")).await;
|
||||
client
|
||||
.ensure_builder_user()
|
||||
.await
|
||||
.expect_err("create refused");
|
||||
assert_eq!(seen.lock().unwrap().len(), 1, "nothing is sent after it");
|
||||
|
||||
let (client, _) = stub_forge((201, "{}"), email, (500, r#"{"message":"x"}"#)).await;
|
||||
client
|
||||
.ensure_builder_user()
|
||||
.await
|
||||
.expect_err("a lockdown that failed is not a built account");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue