Skip to content

Commit afc8412

Browse files
committed
tests, integration: PCR combination on bootloader+kernel update
Add an integration test in which 2 approved images with different bootloader and kernel are added to the cluster. This emulates the situation in which a coreos image could be undergoing a bootloader and kernel update. The test checks that 2 images are added to the image pcr config map, and then checks that the reference values contain all possible pcr4 combinations. pcr7 and pcr14 are constant in this case, so there are not combinations possible (apart from the original value). Signed-off-by: Beñat Gartzia Arruabarrena <bgartzia@redhat.com>
1 parent ff55b9b commit afc8412

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

tests/trusted_execution_cluster.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,73 @@ async fn test_image_disallow() -> anyhow::Result<()> {
8282
Ok(())
8383
}
8484
}
85+
86+
named_test! {
87+
async fn test_combined_image_pcrs_configmap_updates() -> anyhow::Result<()> {
88+
let test_ctx = setup!([
89+
"quay.io/trusted-execution-clusters/fedora-coreos@sha256:372a5db90a8695fafc2869d438bacd7f0ef7fd84f63746a450bfcd4b8b64ae83",
90+
]).await?;
91+
let client = test_ctx.client();
92+
let namespace = test_ctx.namespace();
93+
94+
let secondary_expected_pcr4_hash = "37517a1f76c4d5cf615f4690921c732ad31359aac55f3aaf66d65a8ed38655a9";
95+
96+
test_ctx.verify_expected_pcrs(
97+
&[&expected_base_pcrs!(),
98+
// In practical terms it emulates a grub + kernel upgrade
99+
&[
100+
Pcr {
101+
id: 4,
102+
value: hex::decode(secondary_expected_pcr4_hash).unwrap(),
103+
events: vec![
104+
pcr4_ev_efi_action_event!(),
105+
pcr_separator_event!(4, TPMEventID::Pcr4Separator),
106+
pcr4_shim_event!(),
107+
TPMEvent { pcr: 4, name: "EV_EFI_BOOT_SERVICES_APPLICATION".to_string(), hash: hex::decode("f45c2c974192366a5391e077c3cbf91e735e86eba2037fd86a1f1501818f73f4").unwrap(), id: TPMEventID::Pcr4Grub },
108+
TPMEvent { pcr: 4, name: "EV_EFI_BOOT_SERVICES_APPLICATION".to_string(), hash: hex::decode("f31e645e5e9ed131eea5dca0a18893a21e5625b4a56314fa39587ddc33a7fa91").unwrap(), id: TPMEventID::Pcr4Vmlinuz },
109+
],
110+
},
111+
expected_pcr7!(),
112+
expected_pcr14!(),
113+
]]
114+
).await?;
115+
116+
let expected_ref_values = [
117+
// PCR4
118+
expected_pcr4_hash!(),
119+
"0c4e52c0bc5d2fedbf83b2fee82664dbe5347a79cfb2cbcb9a37f64211add6e8",
120+
"cc5a5360e64b25718be370ca2056645a9ba9e9bae33df08308d6b8e05b8ebb87",
121+
secondary_expected_pcr4_hash,
122+
// PCR7
123+
expected_pcr7_hash!(),
124+
// PCR14
125+
expected_pcr14_hash!(),
126+
];
127+
128+
let configmap_api: Api<ConfigMap> = Api::namespaced(client.clone(), namespace);
129+
let poller = Poller::new()
130+
.with_timeout(Duration::from_secs(180))
131+
.with_interval(Duration::from_secs(5))
132+
.with_error_message("Reference value expectations not met".to_string());
133+
poller.poll_async(|| {
134+
let api = configmap_api.clone();
135+
async move {
136+
let cm = api.get("trustee-data").await?;
137+
if let Some(data) = &cm.data
138+
&& let Some(reference_values_json) = data.get("reference-values.json")
139+
{
140+
for value in expected_ref_values {
141+
if !reference_values_json.contains(value) {
142+
return Err(anyhow::anyhow!("Reference value expectations not met"));
143+
}
144+
}
145+
}
146+
Ok(())
147+
}
148+
}).await?;
149+
150+
test_ctx.cleanup().await?;
151+
152+
Ok(())
153+
}
154+
}

0 commit comments

Comments
 (0)