mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-25 15:39:37 -05:00
913b09aeb8
* terraform: enable creation of SEV-SNP VMs on GCP * variant: add SEV-SNP attestation variant * config: add SEV-SNP config options for GCP * measurements: add GCP SEV-SNP measurements * gcp: separate package for SEV-ES * attestation: add GCP SEV-SNP attestation logic * gcp: factor out common logic * choose: add GCP SEV-SNP * cli: add TF variable passthrough for GCP SEV-SNP variables * cli: support GCP SEV-SNP for `constellation verify` * Adjust usage of GCP SEV-SNP throughout codebase * ci: add GCP SEV-SNP * terraform-provider: support GCP SEV-SNP * docs: add GCP SEV-SNP reference * linter fixes * gcp: only run test with TPM simulator * gcp: remove nonsense test * Update cli/internal/cmd/verify.go Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * Update docs/docs/overview/clouds.md Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * Update terraform-provider-constellation/internal/provider/attestation_data_source_test.go Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com> * linter fixes * terraform_provider: correctly pass down CC technology * config: mark attestationconfigapi as unimplemented * gcp: fix comments and typos * snp: use nonce and PK hash in SNP report * snp: ensure we never use ARK supplied by Issuer (#3025) * Make sure SNP ARK is always loaded from config, or fetched from AMD KDS * GCP: Set validator `reportData` correctly --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems> Co-authored-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * attestationconfigapi: add GCP to uploading * snp: use correct cert Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform-provider: enable fetching of attestation config values for GCP SEV-SNP * linter fixes --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems> Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com>
154 lines
3.0 KiB
Go
154 lines
3.0 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package choose
|
|
|
|
import (
|
|
"encoding/asn1"
|
|
"testing"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIssuer(t *testing.T) {
|
|
testCases := map[string]struct {
|
|
variant variant.Variant
|
|
wantErr bool
|
|
}{
|
|
"aws-sev-snp": {
|
|
variant: variant.AWSSEVSNP{},
|
|
},
|
|
"aws-nitro-tpm": {
|
|
variant: variant.AWSNitroTPM{},
|
|
},
|
|
"azure-sev-snp": {
|
|
variant: variant.AzureSEVSNP{},
|
|
},
|
|
"azure-tdx": {
|
|
variant: variant.AzureTDX{},
|
|
},
|
|
"azure-trusted-launch": {
|
|
variant: variant.AzureTrustedLaunch{},
|
|
},
|
|
"gcp-sev-es": {
|
|
variant: variant.GCPSEVES{},
|
|
},
|
|
"gcp-sev-snp": {
|
|
variant: variant.GCPSEVSNP{},
|
|
},
|
|
"qemu-vtpm": {
|
|
variant: variant.QEMUVTPM{},
|
|
},
|
|
"dummy": {
|
|
variant: variant.Dummy{},
|
|
},
|
|
"unknown": {
|
|
variant: unknownVariant{},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
|
|
for name, tc := range testCases {
|
|
t.Run(name, func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
require := require.New(t)
|
|
|
|
issuer, err := Issuer(tc.variant, nil)
|
|
|
|
if tc.wantErr {
|
|
assert.Error(err)
|
|
return
|
|
}
|
|
require.NoError(err)
|
|
assert.True(issuer.OID().Equal(tc.variant.OID()))
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestValidator(t *testing.T) {
|
|
testCases := map[string]struct {
|
|
cfg config.AttestationCfg
|
|
wantErr bool
|
|
}{
|
|
"aws-nitro-tpm": {
|
|
cfg: &config.AWSNitroTPM{},
|
|
},
|
|
"azure-sev-snp": {
|
|
cfg: &config.AzureSEVSNP{},
|
|
},
|
|
"azure-tdx": {
|
|
cfg: &config.AzureTDX{},
|
|
},
|
|
"azure-trusted-launch": {
|
|
cfg: &config.AzureTrustedLaunch{},
|
|
},
|
|
"gcp-sev-es": {
|
|
cfg: &config.GCPSEVES{},
|
|
},
|
|
"gcp-sev-snp": {
|
|
cfg: &config.GCPSEVSNP{},
|
|
},
|
|
"qemu-vtpm": {
|
|
cfg: &config.QEMUVTPM{},
|
|
},
|
|
"dummy": {
|
|
cfg: &config.DummyCfg{},
|
|
},
|
|
"unknown": {
|
|
cfg: unknownConfig{},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
|
|
for name, tc := range testCases {
|
|
t.Run(name, func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
require := require.New(t)
|
|
|
|
validator, err := Validator(tc.cfg, nil)
|
|
|
|
if tc.wantErr {
|
|
assert.Error(err)
|
|
return
|
|
}
|
|
require.NoError(err)
|
|
assert.True(validator.OID().Equal(tc.cfg.GetVariant().OID()))
|
|
})
|
|
}
|
|
}
|
|
|
|
type unknownVariant struct{}
|
|
|
|
func (unknownVariant) OID() asn1.ObjectIdentifier {
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 9999, 9999}
|
|
}
|
|
|
|
func (unknownVariant) String() string {
|
|
return "unknown"
|
|
}
|
|
|
|
func (unknownVariant) Equal(other variant.Getter) bool {
|
|
return other.OID().Equal(unknownVariant{}.OID())
|
|
}
|
|
|
|
type unknownConfig struct{}
|
|
|
|
func (unknownConfig) GetVariant() variant.Variant {
|
|
return unknownVariant{}
|
|
}
|
|
|
|
func (unknownConfig) GetMeasurements() measurements.M {
|
|
return nil
|
|
}
|
|
|
|
func (unknownConfig) SetMeasurements(measurements.M) {}
|
|
|
|
func (unknownConfig) EqualTo(config.AttestationCfg) (bool, error) { return false, nil }
|