Watch
0
0
Fork
You've already forked hyperhive
0

use a neutral forge name in link-form placeholders, schema examples and tests

Codeberg does not accept AI-assisted contributions, so it should not be
the example we put in front of operators. The placeholders now read
myforge / forge.example.org; the tests use the same neutral names.
This commit is contained in:
iris 2026-10-04 15:51:20 +02:00
commit 78e9f2ca67
5 changed files with 34 additions and 34 deletions

View file

@ -83,7 +83,7 @@ export function LinkForgeAccountForm({
value={label} value={label}
pattern={LABEL_PATTERN} pattern={LABEL_PATTERN}
title="1-63 chars: lowercase letters, digits, hyphen" title="1-63 chars: lowercase letters, digits, hyphen"
placeholder="e.g. codeberg" placeholder="e.g. myforge"
required required
onInput={setLabel} onInput={setLabel}
/> />
@ -92,7 +92,7 @@ export function LinkForgeAccountForm({
label="forge URL" label="forge URL"
type="url" type="url"
value={url} value={url}
placeholder="https://codeberg.org" placeholder="https://forge.example.org"
required required
onInput={setUrl} onInput={setUrl}
/> />

View file

@ -196,7 +196,7 @@ mod ident_tests {
"damocles", "damocles",
"hm1nd", "hm1nd",
"agent-with-dashes", "agent-with-dashes",
"codeberg", "myforge",
"acct-1", "acct-1",
] { ] {
assert!(Ident::parse(ok).is_ok(), "should accept {ok:?}"); assert!(Ident::parse(ok).is_ok(), "should accept {ok:?}");

View file

@ -22,7 +22,7 @@ use super::{AppState, error_problem, swarm_hive};
pub struct PutForgeAccountRequest { pub struct PutForgeAccountRequest {
/// The forge's base URL, `http://` or `https://`. A trailing slash is /// The forge's base URL, `http://` or `https://`. A trailing slash is
/// dropped. /// dropped.
#[schema(example = "https://codeberg.org")] #[schema(example = "https://forge.example.org")]
url: String, url: String,
/// The access token. Never logged, and never returned by this route. /// The access token. Never logged, and never returned by this route.
token: String, token: String,
@ -122,14 +122,14 @@ mod tests {
#[test] #[test]
fn the_url_loses_its_trailing_slash_and_the_token_is_kept() { fn the_url_loses_its_trailing_slash_and_the_token_is_kept() {
let a = account(request("https://codeberg.org/ ", "t0k3n")).expect("valid"); let a = account(request("https://forge.example.org/ ", "t0k3n")).expect("valid");
assert_eq!(a.url, "https://codeberg.org"); assert_eq!(a.url, "https://forge.example.org");
assert_eq!(a.value, "t0k3n"); assert_eq!(a.value, "t0k3n");
} }
#[test] #[test]
fn a_url_that_is_not_http_is_refused() { fn a_url_that_is_not_http_is_refused() {
assert!(account(request("codeberg.org", "t")).is_err()); assert!(account(request("forge.example.org", "t")).is_err());
assert!(account(request("file:///etc/passwd", "t")).is_err()); assert!(account(request("file:///etc/passwd", "t")).is_err());
// The control: plain http is accepted. // The control: plain http is accepted.
assert!(account(request("http://forge.lan", "t")).is_ok()); assert!(account(request("http://forge.lan", "t")).is_ok());
@ -137,7 +137,7 @@ mod tests {
#[test] #[test]
fn an_empty_token_is_refused() { fn an_empty_token_is_refused() {
assert!(account(request("https://codeberg.org", " ")).is_err()); assert!(account(request("https://forge.example.org", " ")).is_err());
} }
/// Bare-minimum `AppState`, as `matrix_account`'s tests build it. /// Bare-minimum `AppState`, as `matrix_account`'s tests build it.
@ -173,7 +173,7 @@ mod tests {
super::put_forge_account( super::put_forge_account(
axum::extract::State(state(store)), axum::extract::State(state(store)),
axum::extract::Path(("pr1ma".to_owned(), "atlas".to_owned(), label.to_owned())), axum::extract::Path(("pr1ma".to_owned(), "atlas".to_owned(), label.to_owned())),
axum::Json(request("https://codeberg.org", "t0k3n")), axum::Json(request("https://forge.example.org", "t0k3n")),
) )
.await .await
} }
@ -182,7 +182,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn a_label_hive_forge_cannot_name_is_refused_before_the_store() { async fn a_label_hive_forge_cannot_name_is_refused_before_the_store() {
let store = Arc::default(); let store = Arc::default();
for bad in ["Codeberg", "code_berg", "../x"] { for bad in ["MyForge", "my_forge", "../x"] {
let problem = put(&store, bad).await.expect_err("refused"); let problem = put(&store, bad).await.expect_err("refused");
assert_eq!( assert_eq!(
problem.status, problem.status,
@ -197,9 +197,9 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn a_plain_label_reaches_the_store() { async fn a_plain_label_reaches_the_store() {
let store = Arc::default(); let store = Arc::default();
let stored = put(&store, "codeberg").await.expect("nothing is stored"); let stored = put(&store, "myforge").await.expect("nothing is stored");
assert_eq!(stored.url, "https://codeberg.org"); assert_eq!(stored.url, "https://forge.example.org");
assert_eq!(store.written(), ["swarm/agents/atlas/forge/codeberg"]); assert_eq!(store.written(), ["swarm/agents/atlas/forge/myforge"]);
} }
#[tokio::test] #[tokio::test]
@ -208,8 +208,8 @@ mod tests {
use swarm_secret_client::forge; use swarm_secret_client::forge;
let store = FakeStore::default(); let store = FakeStore::default();
let path = forge::account_path("atlas", "codeberg").expect("a valid path"); let path = forge::account_path("atlas", "myforge").expect("a valid path");
let first = account(request("https://codeberg.org", "t0k3n-first")).expect("valid"); let first = account(request("https://forge.example.org", "t0k3n-first")).expect("valid");
let second = account(request("https://forge.lan", "t0k3n-second")).expect("valid"); let second = account(request("https://forge.lan", "t0k3n-second")).expect("valid");
link(&store, &path, &first) link(&store, &path, &first)
@ -218,12 +218,12 @@ mod tests {
let problem = link(&store, &path, &second) let problem = link(&store, &path, &second)
.await .await
.expect_err("an account is stored") .expect_err("an account is stored")
.problem(&super::existing("atlas", "codeberg")); .problem(&super::existing("atlas", "myforge"));
assert_eq!(problem.status, Some(axum::http::StatusCode::CONFLICT)); assert_eq!(problem.status, Some(axum::http::StatusCode::CONFLICT));
let detail = problem.detail.expect("a detail"); let detail = problem.detail.expect("a detail");
assert!( assert!(
detail.contains(r#"agent atlas already has forge account "codeberg""#), detail.contains(r#"agent atlas already has forge account "myforge""#),
"{detail}" "{detail}"
); );
assert_eq!(store.written(), std::slice::from_ref(&path)); assert_eq!(store.written(), std::slice::from_ref(&path));
@ -232,7 +232,7 @@ mod tests {
.await .await
.expect("store answers") .expect("store answers")
.expect("still stored"); .expect("still stored");
assert_eq!(kept.url, "https://codeberg.org"); assert_eq!(kept.url, "https://forge.example.org");
assert_eq!(kept.value, "t0k3n-first"); assert_eq!(kept.value, "t0k3n-first");
} }
} }

View file

@ -693,8 +693,8 @@ pub(crate) mod tests {
json!({"value": "t0k3n-old"}), json!({"value": "t0k3n-old"}),
) )
.with( .with(
"swarm/agents/atlas/forge/codeberg", "swarm/agents/atlas/forge/myforge",
json!({"value": "t0k3n-forge", "url": "https://codeberg.org"}), json!({"value": "t0k3n-forge", "url": "https://forge.example.org"}),
) )
.with( .with(
"swarm/agents/atlas/github-token", "swarm/agents/atlas/github-token",
@ -735,8 +735,8 @@ pub(crate) mod tests {
row(AccountKind::Matrix, "old", None, false), row(AccountKind::Matrix, "old", None, false),
row( row(
AccountKind::Forgejo, AccountKind::Forgejo,
"codeberg", "myforge",
Some("https://codeberg.org"), Some("https://forge.example.org"),
false false
), ),
row(AccountKind::Github, "github", Some("github.com"), false), row(AccountKind::Github, "github", Some("github.com"), false),
@ -802,7 +802,7 @@ pub(crate) mod tests {
) )
.await .await
.expect("stored"); .expect("stored");
remove_plain::<forge::Account>(&store, "swarm/agents/atlas/forge/codeberg") remove_plain::<forge::Account>(&store, "swarm/agents/atlas/forge/myforge")
.await .await
.expect("stored"); .expect("stored");
remove_plain::<github::Credential>(&store, "swarm/agents/atlas/github-token") remove_plain::<github::Credential>(&store, "swarm/agents/atlas/github-token")
@ -812,7 +812,7 @@ pub(crate) mod tests {
deleted(&store), deleted(&store),
[ [
"swarm/agents/atlas/matrix/catgirl", "swarm/agents/atlas/matrix/catgirl",
"swarm/agents/atlas/forge/codeberg", "swarm/agents/atlas/forge/myforge",
"swarm/agents/atlas/github-token", "swarm/agents/atlas/github-token",
] ]
); );
@ -828,7 +828,7 @@ pub(crate) mod tests {
None::<NoRevoke>, None::<NoRevoke>,
) )
.await, .await,
remove_plain::<forge::Account>(&store, "swarm/agents/atlas/forge/codeberg").await, remove_plain::<forge::Account>(&store, "swarm/agents/atlas/forge/myforge").await,
remove_plain::<github::Credential>(&store, "swarm/agents/atlas/github-token").await, remove_plain::<github::Credential>(&store, "swarm/agents/atlas/github-token").await,
]; ];
for result in results { for result in results {

View file

@ -109,8 +109,8 @@ mod tests {
fn an_account_and_its_directory_land_under_the_agent_prefix() { fn an_account_and_its_directory_land_under_the_agent_prefix() {
// Spelled out: `forge-accounts.nix` spells the same strings. // Spelled out: `forge-accounts.nix` spells the same strings.
assert_eq!( assert_eq!(
account_path("atlas", "codeberg").expect("both segments are legal"), account_path("atlas", "myforge").expect("both segments are legal"),
"swarm/agents/atlas/forge/codeberg" "swarm/agents/atlas/forge/myforge"
); );
assert_eq!( assert_eq!(
accounts_dir("atlas").expect("legal"), accounts_dir("atlas").expect("legal"),
@ -132,7 +132,7 @@ mod tests {
fn a_label_that_could_escape_the_directory_is_refused() { fn a_label_that_could_escape_the_directory_is_refused() {
for bad in ["../argus", "a/b", "a.b", ""] { for bad in ["../argus", "a/b", "a.b", ""] {
assert!(account_path("atlas", bad).is_err(), "label {bad:?}"); assert!(account_path("atlas", bad).is_err(), "label {bad:?}");
assert!(account_path(bad, "codeberg").is_err(), "agent {bad:?}"); assert!(account_path(bad, "myforge").is_err(), "agent {bad:?}");
} }
// The control: the legal charset stays reachable. // The control: the legal charset stays reachable.
assert!(account_path("a-b_C9", "d-e0").is_ok()); assert!(account_path("a-b_C9", "d-e0").is_ok());
@ -153,14 +153,14 @@ mod tests {
assert!(covers(&format!("secret/metadata/{dir}/"))); assert!(covers(&format!("secret/metadata/{dir}/")));
assert!(covers(&format!( assert!(covers(&format!(
"secret/data/{}", "secret/data/{}",
account_path("atlas", "codeberg").expect("legal") account_path("atlas", "myforge").expect("legal")
))); )));
// The control: another agent's accounts are outside both grants. // The control: another agent's accounts are outside both grants.
let other = accounts_dir("argus").expect("legal"); let other = accounts_dir("argus").expect("legal");
assert!(!covers(&format!("secret/metadata/{other}/"))); assert!(!covers(&format!("secret/metadata/{other}/")));
assert!(!covers(&format!( assert!(!covers(&format!(
"secret/data/{}", "secret/data/{}",
account_path("argus", "codeberg").expect("legal") account_path("argus", "myforge").expect("legal")
))); )));
} }
@ -168,21 +168,21 @@ mod tests {
fn the_account_fields_match_what_the_nix_reader_asks_for() { fn the_account_fields_match_what_the_nix_reader_asks_for() {
let json = serde_json::to_string(&Account { let json = serde_json::to_string(&Account {
value: "t".to_owned(), value: "t".to_owned(),
url: "https://codeberg.org".to_owned(), url: "https://forge.example.org".to_owned(),
}) })
.expect("two Strings serialise"); .expect("two Strings serialise");
assert_eq!(json, r#"{"value":"t","url":"https://codeberg.org"}"#); assert_eq!(json, r#"{"value":"t","url":"https://forge.example.org"}"#);
} }
#[test] #[test]
fn debug_never_prints_an_accounts_value() { fn debug_never_prints_an_accounts_value() {
let a = Account { let a = Account {
value: "0123456789abcdef".to_owned(), value: "0123456789abcdef".to_owned(),
url: "https://codeberg.org".to_owned(), url: "https://forge.example.org".to_owned(),
}; };
let shown = format!("{a:?}"); let shown = format!("{a:?}");
assert!(!shown.contains("0123456789abcdef"), "{shown}"); assert!(!shown.contains("0123456789abcdef"), "{shown}");
assert!(shown.contains("codeberg.org"), "{shown}"); assert!(shown.contains("forge.example.org"), "{shown}");
} }
#[test] #[test]