mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-13 08:29:38 -05:00
attestation: allow "go test" to work with CGO disabled
This commit is contained in:
parent
1d5f244879
commit
75ed8c9f3e
@ -9,6 +9,7 @@ package nitrotpm
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
|
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
|
||||||
@ -20,6 +21,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAttestationKey(t *testing.T) {
|
func TestGetAttestationKey(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
@ -42,6 +47,10 @@ func TestGetAttestationKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetInstanceInfo(t *testing.T) {
|
func TestGetInstanceInfo(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
client stubMetadataAPI
|
client stubMetadataAPI
|
||||||
wantErr bool
|
wantErr bool
|
||||||
|
@ -9,6 +9,7 @@ package snp
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
|
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
|
||||||
@ -20,6 +21,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAttestationKey(t *testing.T) {
|
func TestGetAttestationKey(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
@ -42,6 +47,10 @@ func TestGetAttestationKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetInstanceInfo(t *testing.T) {
|
func TestGetInstanceInfo(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
client stubMetadataAPI
|
client stubMetadataAPI
|
||||||
wantErr bool
|
wantErr bool
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/simulator"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/simulator"
|
||||||
@ -115,6 +116,10 @@ func TestGetSNPAttestation(t *testing.T) {
|
|||||||
// Testing anything else will only verify that the simulator works as expected, since getAkPub
|
// Testing anything else will only verify that the simulator works as expected, since getAkPub
|
||||||
// only retrieves the attestation key from the TPM.
|
// only retrieves the attestation key from the TPM.
|
||||||
func TestGetHCLAttestationKey(t *testing.T) {
|
func TestGetHCLAttestationKey(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/idkeydigest"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/idkeydigest"
|
||||||
@ -31,6 +32,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTrustedKeyFromSNP(t *testing.T) {
|
func TestTrustedKeyFromSNP(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
tpm, err := simulator.OpenSimulatedTPM()
|
tpm, err := simulator.OpenSimulatedTPM()
|
||||||
@ -237,6 +242,10 @@ func TestTrustedKeyFromSNP(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateAk(t *testing.T) {
|
func TestValidateAk(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
tpm, err := simulator.OpenSimulatedTPM()
|
tpm, err := simulator.OpenSimulatedTPM()
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"crypto/x509/pkix"
|
"crypto/x509/pkix"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -32,6 +33,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAttestationCert(t *testing.T) {
|
func TestGetAttestationCert(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
tpm, err := simulator.OpenSimulatedTPM()
|
tpm, err := simulator.OpenSimulatedTPM()
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
@ -9,6 +9,7 @@ package initialize
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
@ -29,6 +30,10 @@ func (s simTPMNOPCloser) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMarkNodeAsBootstrapped(t *testing.T) {
|
func TestMarkNodeAsBootstrapped(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
@ -57,6 +62,10 @@ func TestFailOpener(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIsNodeInitialized(t *testing.T) {
|
func TestIsNodeInitialized(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
pcrValueClusterID []byte
|
pcrValueClusterID []byte
|
||||||
wantInitialized bool
|
wantInitialized bool
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
tpmclient "github.com/google/go-tpm-tools/client"
|
tpmclient "github.com/google/go-tpm-tools/client"
|
||||||
@ -58,6 +59,10 @@ func fakeGetInstanceInfo(_ context.Context, _ io.ReadWriteCloser, _ []byte) ([]b
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
fakeValidateCVM := func(AttestationDocument, *attest.MachineState) error { return nil }
|
fakeValidateCVM := func(AttestationDocument, *attest.MachineState) error { return nil }
|
||||||
@ -421,6 +426,10 @@ func TestGetSHA256QuoteIndex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSelectedMeasurements(t *testing.T) {
|
func TestGetSelectedMeasurements(t *testing.T) {
|
||||||
|
cgo := os.Getenv("CGO_ENABLED")
|
||||||
|
if cgo == "0" {
|
||||||
|
t.Skip("skipping test because CGO is disabled and tpm simulator requires it")
|
||||||
|
}
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
openFunc TPMOpenFunc
|
openFunc TPMOpenFunc
|
||||||
pcrSelection tpm2.PCRSelection
|
pcrSelection tpm2.PCRSelection
|
||||||
|
Loading…
Reference in New Issue
Block a user