Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CVM attestation test for cloud hypervisor platform #3542

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lisa/sut_orchestrator/libvirt/ch_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def _configure_node(
)
else:
node_context.kernel_path = node_runbook.kernel.path
node_context.host_data = secrets.token_hex(32)

def _create_node(
self,
Expand Down Expand Up @@ -131,7 +132,7 @@ def _create_node_domain_xml(
policy = ET.SubElement(launch_sec, "policy")
policy.text = "0"
host_data = ET.SubElement(launch_sec, "host_data")
host_data.text = secrets.token_hex(32)
host_data.text = node_context.host_data

devices = ET.SubElement(domain, "devices")
if len(node_context.passthrough_devices) > 0:
Expand Down
1 change: 1 addition & 0 deletions lisa/sut_orchestrator/libvirt/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class NodeContext:
vm_name: str = ""
kernel_source_path: str = ""
kernel_path: str = ""
host_data: str = ""
guest_vm_type: GuestVmType = field(default_factory=lambda: GuestVmType.Standard)
cloud_init_file_path: str = ""
ignition_file_path: str = ""
Expand Down
4 changes: 3 additions & 1 deletion microsoft/testsuites/cvm/cvm_attestation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from lisa.features.security_profile import CvmEnabled
from lisa.operating_system import Ubuntu
from lisa.sut_orchestrator import AZURE, CLOUD_HYPERVISOR
from lisa.sut_orchestrator.libvirt.context import get_node_context
from lisa.testsuite import TestResult, simple_requirement
from lisa.tools import Ls, Lscpu
from lisa.tools.lscpu import CpuType
Expand Down Expand Up @@ -116,7 +117,8 @@ def verify_nested_cvm_attestation_report(
result: TestResult,
variables: Dict[str, Any],
) -> None:
host_data = variables.get("host_data", "")
node_context = get_node_context(node)
host_data = node_context.host_data
if not host_data:
raise SkippedException("host_data is empty")
node.tools[NestedCVMAttestationTests].run_cvm_attestation(
Expand Down
3 changes: 2 additions & 1 deletion microsoft/testsuites/cvm/cvm_attestation_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ def run_cvm_attestation(
output: str = command.stdout
result = self._extract_result(output)
self._log.debug(f"Attestation result: {result}")
attestation_host_data = result["host_data"].replace(" ", "").strip()

assert_that(
host_data,
"'host_data' passed to testcase is not matching with attestation result",
).is_equal_to(result["host_data"].strip())
).is_equal_to(attestation_host_data)

# save the attestation report under log_path as cvm_attestation_report.txt
self._save_attestation_report(output, log_path)
Expand Down
Loading