WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:07:22 +01:00
parent 231e8cd136
commit 5afc7e9f7f
1223 changed files with 6225 additions and 113722 deletions

View File

@@ -18,9 +18,9 @@ use tempfile::tempdir;
fn layer(id: &str, name: &str, contents: &str) -> RequirementsLayerEntry {
RequirementsLayerEntry::from_toml(
RequirementSource::EnterpriseManaged {
id: id.to_string(),
name: name.to_string(),
RequirementSource::MdmManagedPreferences {
domain: name.to_string(),
key: id.to_string(),
},
contents,
)
@@ -57,40 +57,6 @@ fn empty_layers_compose_to_none() {
assert_eq!(composed, None);
}
#[test]
fn cloud_auth_requirements_do_not_override_local_or_discard_other_policy() {
let local = RequirementsLayerEntry::from_toml(
RequirementSource::Unknown,
r#"allowed_login_methods = ["api"]
cli_auth_credentials_store = "keyring"
chatgpt_base_url = "https://managed.example/backend-api/""#,
);
for cloud_auth in [
r#"allowed_login_methods = ["api", "chatgpt"]
allowed_chatgpt_workspaces = ["other"]"#,
r#"allowed_login_methods = ["saml"]
allowed_chatgpt_workspaces = "invalid"
cli_auth_credentials_store = "invalid"
chatgpt_base_url = false"#,
] {
let cloud = layer(
"req_cloud",
"Cloud policy",
&format!("{cloud_auth}\nallow_login_shell = false"),
);
assert_eq!(
compose(vec![local.clone(), cloud])
.expect("cloud auth cannot invalidate enterprise policy"),
Some(expected_requirements(
r#"allowed_login_methods = ["api"]
cli_auth_credentials_store = "keyring"
chatgpt_base_url = "https://managed.example/backend-api/"
allow_login_shell = false"#
))
);
}
}
#[test]
fn top_level_values_use_toml_priority() {
let composed = compose(vec![
@@ -583,9 +549,9 @@ allow_managed_hooks_only = true
composed.allow_managed_hooks_only,
Some(Sourced::new(
/*value*/ true,
RequirementSource::EnterpriseManaged {
id: "req_1".to_string(),
name: "Security baseline".to_string(),
RequirementSource::MdmManagedPreferences {
domain: "Security baseline".to_string(),
key: "req_1".to_string(),
},
))
);
@@ -684,13 +650,13 @@ fn feature_aliases_merge_with_layer_precedence() {
#[test]
fn merged_table_source_is_composite_in_priority_order() {
let high_source = RequirementSource::EnterpriseManaged {
id: "req_high".to_string(),
name: "High".to_string(),
let high_source = RequirementSource::MdmManagedPreferences {
domain: "High".to_string(),
key: "req_high".to_string(),
};
let low_source = RequirementSource::EnterpriseManaged {
id: "req_low".to_string(),
name: "Low".to_string(),
let low_source = RequirementSource::MdmManagedPreferences {
domain: "Low".to_string(),
key: "req_low".to_string(),
};
let composed = compose_requirements_for_hostname(
vec![
@@ -1337,8 +1303,8 @@ managed_dir = "/managed/high"
)
.expect_err("conflicting managed dirs should fail closed");
assert!(err.to_string().contains("hooks.managed_dir"));
assert!(err.to_string().contains("High (req_high)"));
assert!(err.to_string().contains("Low (req_low)"));
assert!(err.to_string().contains("MDM High:req_high"));
assert!(err.to_string().contains("MDM Low:req_low"));
}
#[test]
@@ -1367,8 +1333,8 @@ windows_managed_dir = 'C:\managed\high'
.expect_err("conflicting windows managed dirs should fail closed");
assert!(err.to_string().contains("hooks.windows_managed_dir"));
assert!(err.to_string().contains("High (req_high)"));
assert!(err.to_string().contains("Low (req_low)"));
assert!(err.to_string().contains("MDM High:req_high"));
assert!(err.to_string().contains("MDM Low:req_low"));
}
#[test]
@@ -1672,7 +1638,7 @@ fn parse_error_names_layer() {
)])
.expect_err("invalid layer should fail");
assert!(err.to_string().contains("Bad layer (req_bad)"));
assert!(err.to_string().contains("MDM Bad layer:req_bad"));
assert!(err.to_string().contains("allowed_approval_policies"));
}
@@ -1785,7 +1751,10 @@ reff = "main"
)])
.expect_err("invalid marketplace rule should fail");
assert!(err.to_string().contains("Bad marketplace layer (req_bad)"));
assert!(
err.to_string()
.contains("MDM Bad marketplace layer:req_bad")
);
assert!(err.to_string().contains("unknown field `reff`"));
}
@@ -1891,20 +1860,3 @@ scopes = ["policy.read"]
}
);
}
#[test]
fn fetched_policy_cannot_change_config_server() {
let result = crate::compose_requirements([RequirementsLayerEntry::from_toml(
RequirementSource::EnterpriseManaged {
id: "remote".into(),
name: "Remote policy".into(),
},
"[config_server]\nbase_url = 'https://replacement.example/settings'",
)]);
assert!(
result
.unwrap_err()
.to_string()
.contains("only be configured in local managed requirements")
);
}