Skip to content

Commit 834c734

Browse files
committed
uefi_sb: Test pool and VM cert states when no custom cert installed
We previously didn't check that a pool without custom certs only has PK.auth in `/var/lib/varstored`. Check this. We also didn't test what happens when you boot a fresh UEFI VM on a pool which only has PK.auth, and this bit us. We thought it would behave some way, and it actually behaved the other way. We changed it so that it behaves as we need, so add a test which ensures this works and doesn't regress in the future. Signed-off-by: Samuel Verschelde <[email protected]>
1 parent bd2ec43 commit 834c734

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/uefi_sb/test_varstored_cert_flow.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def test_clear_custom_pool_certificates(self, host):
5151
for h in host.pool.hosts:
5252
logging.info(f"Check host {h} has no custom certificates on disk.")
5353
assert h.is_symlink(host.varstore_dir())
54+
logging.info(f"Check host {h} only has PK, and no other certs.")
55+
assert h.ssh(['ls', '/var/lib/varstored/']) == 'PK.auth'
5456

5557
@pytest.mark.small_vm
5658
@pytest.mark.usefixtures("host_at_least_8_3")
@@ -116,10 +118,24 @@ def test_start_vm_without_uefi_vars(self, uefi_vm):
116118
pool_auths = generate_keys(as_dict=True)
117119
vm.host.pool.install_custom_uefi_certs([pool_auths[key] for key in ['PK', 'KEK', 'db', 'dbx']])
118120
vm.start()
119-
logging.info("Check that the VM certs were updated")
121+
logging.info("Check that the VM certs were updated: PK, KEK, db, dbx")
120122
for key in ['PK', 'KEK', 'db', 'dbx']:
121123
check_vm_cert_md5sum(vm, key, pool_auths[key].auth)
122124

125+
def test_start_vm_without_uefi_vars_on_pool_with_only_pk(self, uefi_vm):
126+
# When a VM first starts but the pool doesn't have certs configured,
127+
# this used, until late in 8.3 development, to *not* propagate the certs to the VM
128+
# and we had no test that detected this situation.
129+
# We have now changed the behaviour, propagating the certs even if just PK is present.
130+
vm = uefi_vm
131+
vm.clear_uefi_variables()
132+
vm.host.pool.clear_custom_uefi_certs()
133+
vm.start()
134+
logging.info("Check that the VM certs were updated: PK only")
135+
assert vm.is_cert_present('PK')
136+
for key in ['KEK', 'db', 'dbx']:
137+
assert not vm.is_cert_present(key)
138+
123139
def test_start_vm_in_setup_mode(self, uefi_vm):
124140
# In setup mode, no cert is set, but other UEFI variables are present.
125141
# varstored will *not* propagate the certs in this case.

0 commit comments

Comments
 (0)