Skip to content

Commit

Permalink
e2e/openssl: fill in missing manifest values for baremetal SNP
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Aug 14, 2024
1 parent bd7376d commit afa1b22
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions e2e/openssl/openssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ func TestOpenSSL(t *testing.T) {
ct.Init(t, resources)
require.True(t, t.Run("generate", ct.Generate), "contrast generate needs to succeed for subsequent tests")

if platform == platforms.K3sQEMUSNP {
// The generate command doesn't fill in all required fields when
// generating a manifest for baremetal SNP. Do that now.

manifestBytes, err := os.ReadFile(ct.WorkDir + "/manifest.json")
require.NoError(t, err)
var m manifest.Manifest
require.NoError(t, json.Unmarshal(manifestBytes, &m))

for i, snp := range m.ReferenceValues.SNP {
snp.MinimumTCB.BootloaderVersion = toPtr(manifest.SVN(0))
snp.MinimumTCB.TEEVersion = toPtr(manifest.SVN(0))
snp.MinimumTCB.SNPVersion = toPtr(manifest.SVN(0))
snp.MinimumTCB.MicrocodeVersion = toPtr(manifest.SVN(0))
m.ReferenceValues.SNP[i] = snp
}

manifestBytes, err = json.Marshal(m)
require.NoError(t, err)
require.NoError(t, os.WriteFile(ct.WorkDir+"/manifest.json", manifestBytes, 0o644))
}

require.True(t, t.Run("apply", ct.Apply), "Kubernetes resources need to be applied for subsequent tests")

require.True(t, t.Run("set", ct.Set), "contrast set needs to succeed for subsequent tests")
Expand Down Expand Up @@ -258,3 +280,7 @@ func opensslConnectCmd(addr, caCert string) string {
`openssl s_client -connect %s -verify_return_error -x509_strict -CAfile /tls-config/%s -cert /tls-config/certChain.pem -key /tls-config/key.pem </dev/null`,
addr, caCert)
}

func toPtr[T any](t T) *T {
return &t
}

0 comments on commit afa1b22

Please sign in to comment.