Skip to content

Commit 59ee492

Browse files
committed
e2e: test disallowed PIIDs
1 parent c477410 commit 59ee492

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

e2e/attestation/attestation_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,41 @@ func TestAttestation(t *testing.T) {
5353
}), "contrast set should fail due to non-allowed chip ID")
5454
})
5555

56+
// Same as above, but for TDX PIIDs.
57+
t.Run("allowed-piids", func(t *testing.T) {
58+
platform, err := platforms.FromString(contrasttest.Flags.PlatformStr)
59+
require.NoError(t, err)
60+
if !platforms.IsTDX(platform) {
61+
t.Skip()
62+
}
63+
64+
require := require.New(t)
65+
ct := contrasttest.New(t)
66+
67+
runtimeHandler, err := manifest.RuntimeHandler(platform)
68+
require.NoError(err)
69+
resources := kuberesource.CoordinatorBundle()
70+
resources = kuberesource.PatchRuntimeHandlers(resources, runtimeHandler)
71+
resources = kuberesource.AddPortForwarders(resources)
72+
ct.Init(t, resources)
73+
74+
require.True(t.Run("generate", ct.Generate), "contrast generate needs to succeed for subsequent tests")
75+
require.True(t.Run("apply", ct.Apply), "Kubernetes resources need to be applied for subsequent tests")
76+
77+
ct.PatchManifest(t, func(m manifest.Manifest) manifest.Manifest {
78+
for i := range m.ReferenceValues.TDX {
79+
m.ReferenceValues.TDX[i].AllowedPIIDs = []manifest.HexString{
80+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
81+
}
82+
}
83+
return m
84+
})
85+
require.True(t.Run("set", func(t *testing.T) {
86+
err := ct.RunSet(t.Context())
87+
require.ErrorContains(err, "not in allowed PIIDs")
88+
}), "contrast set should fail due to non-allowed PIID")
89+
})
90+
5691
// Test that it is okay to have failing validators as long as one validator passes.
5792
t.Run("non-matching-validators", func(t *testing.T) {
5893
platform, err := platforms.FromString(contrasttest.Flags.PlatformStr)

0 commit comments

Comments
 (0)