Watch
0
0
Fork
You've already forked hyperhive
0

lock the service forge accounts out of creating organizations

This commit is contained in:
atlas 2026-11-16 21:40:02 +01:00
commit 87dc4c5533
4 changed files with 55 additions and 12 deletions

View file

@ -288,4 +288,25 @@ mod tests {
assert!(format!("{err:#}").contains("not the swarm builder's"));
assert!(lockdown_patch(&seen, LOGIN).is_none());
}
/// An existing account is locked out of repo creation and of
/// organizations on every pass.
#[tokio::test]
async fn the_job_locks_the_builder_out_of_repos_and_organizations() {
use super::super::tests::{lockdown_patch, stub_forge};
let (client, seen) = stub_forge(
(409, r#"{"message":"user already exists"}"#),
(200, r#"{"email":"builder@services.hyperhive.local"}"#),
(200, "{}"),
)
.await;
client
.ensure_builder_user()
.await
.expect("the builder's own account");
let body = lockdown_patch(&seen, LOGIN).expect("no lockdown PATCH sent");
assert_eq!(body["max_repo_creation"], 0);
assert_eq!(body["allow_create_organization"], false);
}
}

View file

@ -473,4 +473,25 @@ mod tests {
assert!(format!("{err:#}").contains("not the CI metrics poller's"));
assert!(lockdown_patch(&seen, LOGIN).is_none());
}
/// An existing account is locked out of repo creation and of
/// organizations on every pass.
#[tokio::test]
async fn the_job_locks_the_poller_out_of_repos_and_organizations() {
use super::super::tests::{lockdown_patch, stub_forge};
let (client, seen) = stub_forge(
(409, r#"{"message":"user already exists"}"#),
(200, r#"{"email":"ci-metrics@services.hyperhive.local"}"#),
(200, "{}"),
)
.await;
client
.ensure_ci_metrics_user()
.await
.expect("the poller's own account");
let body = lockdown_patch(&seen, LOGIN).expect("no lockdown PATCH sent");
assert_eq!(body["max_repo_creation"], 0);
assert_eq!(body["allow_create_organization"], false);
}
}

View file

@ -582,5 +582,6 @@ mod tests {
.expect("the classifier's own account");
let body = lockdown_patch(&seen, LOGIN).expect("no lockdown PATCH sent");
assert_eq!(body["max_repo_creation"], 0);
assert_eq!(body["allow_create_organization"], false);
}
}

View file

@ -660,6 +660,7 @@ mod tests {
.expect("the hive's own account");
let body = lockdown_patch(&seen, "hive-alpha").expect("no lockdown PATCH sent");
assert_eq!(body["max_repo_creation"], 0);
assert_eq!(body["allow_create_organization"], false);
}
fn team(permission: TeamPermission, units: &[&str]) -> Team {