From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound. --- tests/config.rs | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'tests/config.rs') diff --git a/tests/config.rs b/tests/config.rs index 3737045..080bbc7 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -3,8 +3,6 @@ use std::process::Command; use aur_build::config::Config; -/// The exact shape of the bug: a relative `--root`, saved verbatim, read back by -/// the next command. #[test] fn a_relative_root_is_absolutized_once_and_never_doubled() { let rel = PathBuf::from("target").join("config-root-test").join("runtime"); @@ -28,16 +26,12 @@ fn a_relative_root_is_absolutized_once_and_never_doubled() { "the root must never be joined onto itself: {}", rel.join("runtime").display() ); - // Everything derived hangs off the one root, so the database cannot end up in - // a second tree while the config sits in the first. assert!(reloaded.db_path().starts_with(&reloaded.root)); assert!(reloaded.repo_arch_dir().starts_with(&reloaded.root)); std::fs::remove_dir_all(&rel).unwrap(); } -/// The legacy shape on disk: a config written by an `init` that saved `--root -/// runtime` verbatim. Loading it must not resurrect the doubled tree. #[test] fn a_stale_relative_root_in_the_file_is_ignored() { let tmp = tempfile::tempdir().unwrap(); @@ -61,8 +55,6 @@ fn a_root_with_no_config_is_an_error_not_a_fresh_server() { ); } -/// The CLI half of the same rule: the old fallback invented a default config for -/// *any* command, so a typo'd `--root` quietly produced an empty server. #[test] fn the_cli_refuses_a_root_that_was_never_initialized() { let tmp = tempfile::tempdir().unwrap(); @@ -83,7 +75,6 @@ fn the_cli_refuses_a_root_that_was_never_initialized() { assert!(err.contains("init"), "{err}"); } -/// …and `init` is still allowed to run where there is no config yet. #[test] fn init_still_runs_where_there_is_no_config_yet() { let tmp = tempfile::tempdir().unwrap(); @@ -100,14 +91,11 @@ fn init_still_runs_where_there_is_no_config_yet() { assert!(root.join("config.json").exists()); assert!(root.join("aur-build.db").exists()); - // And the command after it agrees about where the tree is. let cfg = Config::load(&root).unwrap(); assert_eq!(cfg.root, std::path::absolute(&root).unwrap()); assert!(!root.join("runtime").exists(), "no doubled tree"); } -/// A root that exists but holds nothing but a config still resolves to itself, -/// whichever way it was spelled. #[test] fn an_absolute_root_is_used_verbatim() { let tmp = tempfile::tempdir().unwrap(); @@ -120,11 +108,6 @@ fn an_absolute_root_is_used_verbatim() { assert_eq!(Config::load(dir).unwrap().root, dir); } -// The sandbox configuration: three kinds, and only three. The kinds are an enum -// now, so a configuration that would silently mean "run the untrusted PKGBUILD as -// the hub's own user" does not parse. - -/// Write a config carrying exactly this `sandbox` value and load it. fn load_sandbox(sandbox: &str) -> Result { let tmp = tempfile::tempdir().unwrap(); std::fs::write( @@ -135,7 +118,6 @@ fn load_sandbox(sandbox: &str) -> Result { Config::load(tmp.path()).map_err(|e| e.to_string()) } -/// Load a config written as an older `aur-build init` would have written it. fn load_raw(body: &str) -> Result { let tmp = tempfile::tempdir().unwrap(); std::fs::write(tmp.path().join("config.json"), body).unwrap(); @@ -206,15 +188,12 @@ fn a_missing_required_field_names_the_field() { #[test] fn a_misspelled_field_is_refused_not_ignored() { - // deny_unknown_fields: `listn` must not parse as "no listen address given". let err = load_sandbox(r#"{"kind":"remote","listn":"127.0.0.1:1","token":"t"}"#).unwrap_err(); assert!(err.contains("listn"), "a typo'd field name must be named: {err}"); } #[test] fn an_unknown_kind_names_the_value_and_the_valid_set() { - // The exact mistake this enum exists to catch: `kata` was a real intent, - // and the old match sent it quietly to loopback. let err = load_sandbox(r#"{"kind":"kata"}"#).unwrap_err(); assert!(err.contains("kata"), "must name the bad value: {err}"); for kind in aur_build::config::Sandbox::KINDS { @@ -224,8 +203,6 @@ fn an_unknown_kind_names_the_value_and_the_valid_set() { #[test] fn a_config_with_no_sandbox_object_is_the_local_backend() { - // The contract with every config.json already on disk: saying nothing means - // loopback. let cfg = load_raw("{\n \"repo_name\": \"aur\"\n}\n").unwrap(); assert!(matches!(cfg.sandbox, aur_build::config::Sandbox::Loopback)); assert_eq!(cfg.repo_name, "aur", "the rest of the config is untouched"); @@ -233,8 +210,6 @@ fn a_config_with_no_sandbox_object_is_the_local_backend() { assert!(cfg.sandbox.shared_workspace(), "loopback shares the filesystem by construction"); } -/// The file an older `aur-build init` wrote, verbatim. It carries the retired keys, -/// but they say what the default already means, so it must still load. #[test] fn a_config_init_wrote_before_the_enum_still_loads() { let cfg = load_raw( @@ -269,8 +244,6 @@ fn a_config_init_wrote_before_the_enum_still_loads() { assert_eq!(cfg.lease_secs, 90); } -/// …but retired keys that *would* have changed behaviour are refused, not quietly -/// reinterpreted. #[test] fn retired_sandbox_keys_that_mean_something_are_refused() { let err = load_raw(r#"{ "sandbox_backend": "remote", "agent_listen": "0.0.0.0:1", "agent_token": "t" }"#) @@ -278,18 +251,14 @@ fn retired_sandbox_keys_that_mean_something_are_refused() { assert!(err.contains("sandbox_backend"), "must name the retired key: {err}"); assert!(err.contains("sandbox"), "must point at the replacement: {err}"); - // Even one retired key with content is enough to refuse. let err = load_raw(r#"{ "sandbox_backend": "kata" }"#).unwrap_err(); assert!(err.contains("sandbox_backend"), "{err}"); - // An empty retired key is noise, not intent, and stays tolerated. assert!(load_raw(r#"{ "sandbox_backend": "loopback", "agent_token": "" }"#).is_ok()); } #[test] fn the_rendezvous_secrets_never_reach_debug() { - // A config that ends up in a log line, a panic, or an audit payload must - // not carry the token or the cluster bearer. let cfg = load_sandbox( r#"{"kind":"agent-sandbox","api":"https://k8s:6443","namespace":"builds", "bearer":"kube-token","image":"img","listen":"0.0.0.0:1","token":"s3cr3t"}"#, @@ -301,12 +270,6 @@ fn the_rendezvous_secrets_never_reach_debug() { assert!(shown.contains("builds"), "the non-secret fields are still visible: {shown}"); } -// The startup guard: the enum makes the impossible unrepresentable, this refuses -// what a type cannot see — a field present but empty, and a remote backend that -// was never told the workspace is shared. - -/// A config that parses but cannot work must be refused by `validate`, not -/// discovered at the step that needed the thing it is missing. #[test] fn a_field_that_is_present_but_empty_is_refused() { let cfg = load_sandbox(r#"{"kind":"remote","listen":"","token":"t","shared_workspace":true}"#) @@ -319,7 +282,6 @@ fn a_field_that_is_present_but_empty_is_refused() { let err = cfg.validate().unwrap_err().to_string(); assert!(err.contains("token"), "whitespace is not a token: {err}"); - // Every agent-sandbox field, one at a time. for blank in ["api", "namespace", "bearer", "image", "listen", "token"] { let mut fields = std::collections::BTreeMap::from([ ("api", "https://k8s:6443"), @@ -338,8 +300,6 @@ fn a_field_that_is_present_but_empty_is_refused() { } } -/// The workspace gap: the build workspace is not shipped to a remote sandbox, so -/// "remote" without this assertion would silently build on the hub. #[test] fn a_remote_backend_must_assert_the_shared_workspace() { let cfg = load_sandbox(r#"{"kind":"remote","listen":"127.0.0.1:1","token":"t"}"#).unwrap(); @@ -357,7 +317,6 @@ fn a_remote_backend_must_assert_the_shared_workspace() { assert!(err.contains("shared_workspace"), "{err}"); assert!(err.contains("agent-sandbox"), "{err}"); - // Asserting it is enough — the guard refuses the silence, not the kind. assert!(load_sandbox( r#"{"kind":"remote","listen":"127.0.0.1:1","token":"t","shared_workspace":true}"# ) @@ -368,15 +327,10 @@ fn a_remote_backend_must_assert_the_shared_workspace() { #[test] fn the_local_backend_needs_no_assertion_at_all() { - // The whole point of keeping loopback the default: it shares the filesystem - // by construction, so there is nothing to promise. assert!(load_sandbox(r#"{"kind":"loopback"}"#).unwrap().validate().is_ok()); assert!(load_raw("{}\n").unwrap().validate().is_ok()); } -/// The guard is wired to the process, not just available as a library call: -/// `aur-build serve` with a remote config that never asserted the shared -/// workspace must refuse rather than come up healthy and build on the hub. #[test] fn serve_refuses_a_remote_config_that_never_asserted_the_workspace() { let tmp = tempfile::tempdir().unwrap(); @@ -394,8 +348,6 @@ fn serve_refuses_a_remote_config_that_never_asserted_the_workspace() { assert!(err.contains("shared_workspace"), "{err}"); } -/// …and the same for the CLI build path, which is where the build would -/// actually have run. #[test] fn the_cli_build_path_refuses_an_unusable_sandbox_config() { let tmp = tempfile::tempdir().unwrap(); -- cgit v1.2.3