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

@ -22,7 +22,7 @@ use super::{AppState, error_problem, swarm_hive};
pub struct PutForgeAccountRequest {
/// The forge's base URL, `http://` or `https://`. A trailing slash is
/// dropped.
#[schema(example = "https://codeberg.org")]
#[schema(example = "https://forge.example.org")]
url: String,
/// The access token. Never logged, and never returned by this route.
token: String,
@ -122,14 +122,14 @@ mod tests {
#[test]
fn the_url_loses_its_trailing_slash_and_the_token_is_kept() {
let a = account(request("https://codeberg.org/ ", "t0k3n")).expect("valid");
assert_eq!(a.url, "https://codeberg.org");
let a = account(request("https://forge.example.org/ ", "t0k3n")).expect("valid");
assert_eq!(a.url, "https://forge.example.org");
assert_eq!(a.value, "t0k3n");
}
#[test]
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());
// The control: plain http is accepted.
assert!(account(request("http://forge.lan", "t")).is_ok());
@ -137,7 +137,7 @@ mod tests {
#[test]
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.
@ -173,7 +173,7 @@ mod tests {
super::put_forge_account(
axum::extract::State(state(store)),
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
}
@ -182,7 +182,7 @@ mod tests {
#[tokio::test]
async fn a_label_hive_forge_cannot_name_is_refused_before_the_store() {
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");
assert_eq!(
problem.status,
@ -197,9 +197,9 @@ mod tests {
#[tokio::test]
async fn a_plain_label_reaches_the_store() {
let store = Arc::default();
let stored = put(&store, "codeberg").await.expect("nothing is stored");
assert_eq!(stored.url, "https://codeberg.org");
assert_eq!(store.written(), ["swarm/agents/atlas/forge/codeberg"]);
let stored = put(&store, "myforge").await.expect("nothing is stored");
assert_eq!(stored.url, "https://forge.example.org");
assert_eq!(store.written(), ["swarm/agents/atlas/forge/myforge"]);
}
#[tokio::test]
@ -208,8 +208,8 @@ mod tests {
use swarm_secret_client::forge;
let store = FakeStore::default();
let path = forge::account_path("atlas", "codeberg").expect("a valid path");
let first = account(request("https://codeberg.org", "t0k3n-first")).expect("valid");
let path = forge::account_path("atlas", "myforge").expect("a valid path");
let first = account(request("https://forge.example.org", "t0k3n-first")).expect("valid");
let second = account(request("https://forge.lan", "t0k3n-second")).expect("valid");
link(&store, &path, &first)
@ -218,12 +218,12 @@ mod tests {
let problem = link(&store, &path, &second)
.await
.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));
let detail = problem.detail.expect("a detail");
assert!(
detail.contains(r#"agent atlas already has forge account "codeberg""#),
detail.contains(r#"agent atlas already has forge account "myforge""#),
"{detail}"
);
assert_eq!(store.written(), std::slice::from_ref(&path));
@ -232,7 +232,7 @@ mod tests {
.await
.expect("store answers")
.expect("still stored");
assert_eq!(kept.url, "https://codeberg.org");
assert_eq!(kept.url, "https://forge.example.org");
assert_eq!(kept.value, "t0k3n-first");
}
}

View file

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