agents get a per-agent repo limit in their permissions record, orgs are locked
max_repos (default 0, 0..=100) lives in the agent's agent-permissions record and is edited on its permissions panel. The controller applies each agent's own value as max_repo_creation at CreateForgeUser and to existing accounts on change, restart and every five minutes; agent accounts may not create organizations.
This commit is contained in:
parent
dc0d08b7fb
commit
1edeb5c55d
1 changed files with 763 additions and 58 deletions
|
|
@ -8,6 +8,10 @@ import {
|
|||
internetBody,
|
||||
internetMode,
|
||||
internetSummary,
|
||||
MAX_REPOS,
|
||||
maxReposBody,
|
||||
parseMaxRepos,
|
||||
reposSummary,
|
||||
} from "../src/agent/detail/permissions.ts";
|
||||
|
||||
const all = ["messaging", "meta", "inbox", "execution", "manage_root_agent"];
|
||||
|
|
@ -79,3 +83,29 @@ test("the log mode keeps the old flag false and names internet_log; the others l
|
|||
assert.equal("internet_log" in internetBody([], "restricted"), false);
|
||||
assert.equal("internet_log" in internetBody([], "unrestricted"), false);
|
||||
});
|
||||
|
||||
test("a whole number from 0 to the most is a repository limit", () => {
|
||||
assert.equal(parseMaxRepos("0"), 0);
|
||||
assert.equal(parseMaxRepos(" 7 "), 7);
|
||||
assert.equal(parseMaxRepos(String(MAX_REPOS)), MAX_REPOS);
|
||||
});
|
||||
|
||||
test("anything else is not: empty, negative, fractional, above the most, text", () => {
|
||||
for (const t of ["", " ", "-1", "1.5", "1e2", String(MAX_REPOS + 1), "x"]) {
|
||||
assert.equal(parseMaxRepos(t), null, JSON.stringify(t));
|
||||
}
|
||||
});
|
||||
|
||||
test("the repositories badge tells none from a limit", () => {
|
||||
assert.equal(reposSummary(undefined), "none");
|
||||
assert.equal(reposSummary(0), "none");
|
||||
assert.equal(reposSummary(3), "up to 3");
|
||||
});
|
||||
|
||||
test("the limit's body carries the stored list, so the PUT does not reset it", () => {
|
||||
assert.deepEqual(maxReposBody(["meta"], 3), {
|
||||
permissions: ["meta"],
|
||||
max_repos: 3,
|
||||
});
|
||||
assert.deepEqual(maxReposBody(undefined, 0), { max_repos: 0 });
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue