Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/gunnar-ui

crates/gunnar-ui-server/src/anonymous/forges_switch.rs

//! **AIRGAP: forge import dials the public forges (github.com, gitlab.com, …), so it is off unless
//! it is built AND switched on** (owner rule 2026-10-25). A default build has no forge client
//! at all (`forges` feature off) and answers every forge door with a refusal that names the
//! feature. A `forges` build answers the same doors with a refusal that names the switch
//! `GUNNAR_UI_FORGES` until it is `on`; the harness in `crate::mirroring` drives the switched-on
//! build, and its `with_the_switch_off_*` test proves the forge is never dialled.

use super::{console, signed_in, FakeGunnar};

/// The forge doors a signed-in person reaches with a GET.
const DOORS: &[&str] = &["/api/forges", "/api/forges/github/repos", "/api/forge/github/authorize"];

#[cfg(not(feature = "forges"))]
#[tokio::test]
async fn the_default_build_refuses_every_forge_door_by_the_feature_name() {
    let (app, keys, _feed) = console(FakeGunnar::new(), true).await;
    for path in DOORS {
        let (status, body) = signed_in(&app, &keys, "kim", crate::role::Role::Admin, path).await;
        assert_ne!(status, http::StatusCode::OK, "{path}: {body}");
        assert!(body.contains("`forges`"), "{path} names the feature: {status} {body}");
    }
}

#[cfg(feature = "forges")]
#[tokio::test]
async fn a_forges_build_refuses_every_forge_door_until_the_switch_is_on() {
    let (app, keys, _feed) = console(FakeGunnar::new(), true).await;
    for path in DOORS {
        let (status, body) = signed_in(&app, &keys, "kim", crate::role::Role::Admin, path).await;
        assert_ne!(status, http::StatusCode::OK, "{path}: {body}");
        assert!(body.contains("GUNNAR_UI_FORGES"), "{path} names the switch: {status} {body}");
    }
}