Skip to content

Commit 30f1a37

Browse files
committed
test(supervisor): run baseline write-back cases only on Unix hosts
The startup policy write-refusal tests from #3785 rely on enrich_proto_baseline_paths adding the proxy baseline paths (/usr, /tmp, /dev/null, ...) to a policy, which triggers a write-back that the fake gateway then refuses. Enrichment only adds paths that exist on the host. Prior to this change, the tests assumed those paths exist, so on Windows enrichment added nothing, the precondition assertions failed, and the baseline case of permanent_codes_still_exit never saw a write to refuse. Now, the four baseline write-back tests are gated to Unix, and permanent_codes_still_exit checks the image policy upload case on every host and the baseline write-back case only on Unix. Signed-off-by: Kris Hicks <khicks@nvidia.com>
1 parent 34c67cd commit 30f1a37

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

  • crates/openshell-supervisor/src

‎crates/openshell-supervisor/src/lib.rs‎

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5620,6 +5620,8 @@ network_policies:
56205620
.await;
56215621
}
56225622

5623+
// Baseline enrichment adds host paths that only exist on Unix.
5624+
#[cfg(unix)]
56235625
#[tokio::test(start_paused = true)]
56245626
async fn startup_policy_write_refusal_baseline_write_back_waits_for_repair() {
56255627
// The gateway policy has network rules but lacks the proxy baseline
@@ -5749,6 +5751,8 @@ network_policies:
57495751
.await;
57505752
}
57515753

5754+
// Baseline enrichment adds host paths that only exist on Unix.
5755+
#[cfg(unix)]
57525756
#[tokio::test(start_paused = true)]
57535757
async fn startup_policy_write_refusal_baseline_repair_before_report_refetches() {
57545758
let mut repaired = proto_tcp_policy_fixture();
@@ -5892,6 +5896,8 @@ network_policies:
58925896
.await;
58935897
}
58945898

5899+
// Baseline enrichment adds host paths that only exist on Unix.
5900+
#[cfg(unix)]
58955901
#[tokio::test(start_paused = true)]
58965902
async fn startup_policy_write_refusal_write_back_outlasts_the_attempt_limit() {
58975903
// The same limit applies to a refused baseline-path write-back.
@@ -5979,6 +5985,8 @@ network_policies:
59795985
);
59805986
}
59815987

5988+
// Baseline enrichment adds host paths that only exist on Unix.
5989+
#[cfg(unix)]
59825990
#[tokio::test(start_paused = true)]
59835991
async fn startup_policy_write_refusal_global_policy_skips_baseline_write_back() {
59845992
use openshell_core::proto::{ConfigurationAdmissionState, PolicySource};
@@ -6067,18 +6075,18 @@ network_policies:
60676075
// Both writes are checked: the image policy upload to a gateway with
60686076
// no policy, and the write-back of a stored policy that lacks the
60696077
// proxy baseline paths.
6070-
let writes = [
6071-
(
6072-
"image policy upload",
6073-
unset_policy_snapshot(),
6074-
ImagePolicyDiscovery::Policy(Box::new(proto_tcp_policy_fixture())),
6075-
),
6076-
(
6077-
"baseline write-back",
6078-
settings_poll_result(Some(proto_tcp_policy_fixture()), 1, PolicySource::Sandbox),
6079-
ImagePolicyDiscovery::Missing,
6080-
),
6081-
];
6078+
let image_upload = (
6079+
"image policy upload",
6080+
unset_policy_snapshot(),
6081+
ImagePolicyDiscovery::Policy(Box::new(proto_tcp_policy_fixture())),
6082+
);
6083+
let baseline_write_back = (
6084+
"baseline write-back",
6085+
settings_poll_result(Some(proto_tcp_policy_fixture()), 1, PolicySource::Sandbox),
6086+
ImagePolicyDiscovery::Missing,
6087+
);
6088+
// Baseline enrichment adds host paths that only exist on Unix.
6089+
let writes = std::iter::once(image_upload).chain(cfg!(unix).then_some(baseline_write_back));
60826090
for (write, initial, discovery) in writes {
60836091
for code in [
60846092
tonic::Code::PermissionDenied,

0 commit comments

Comments
 (0)