cli: fix unmarshalling of sev-snp attestation documents in constellation verify (#3171)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2024-06-17 13:38:59 +02:00 committed by GitHub
parent e0f52b4acd
commit 9d99d05826
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 25 deletions

View file

@ -208,18 +208,20 @@ func TestVerify(t *testing.T) {
func TestFormatDefault(t *testing.T) {
testCases := map[string]struct {
doc string
doc []byte
attCfg config.AttestationCfg
wantErr bool
}{
"invalid doc": {
doc: "invalid",
doc: []byte("invalid"),
attCfg: &config.AzureSEVSNP{},
wantErr: true,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
_, err := formatDefault(context.Background(), tc.doc, nil, logger.NewTest(t))
_, err := formatDefault(context.Background(), tc.doc, tc.attCfg, logger.NewTest(t))
if tc.wantErr {
assert.Error(t, err)
} else {
@ -313,9 +315,9 @@ type stubVerifyClient struct {
endpoint string
}
func (c *stubVerifyClient) Verify(_ context.Context, endpoint string, _ *verifyproto.GetAttestationRequest, _ atls.Validator) (string, error) {
func (c *stubVerifyClient) Verify(_ context.Context, endpoint string, _ *verifyproto.GetAttestationRequest, _ atls.Validator) ([]byte, error) {
c.endpoint = endpoint
return "", c.verifyErr
return nil, c.verifyErr
}
type stubVerifyAPI struct {