Skip to content

Commit

Permalink
fix linter checks
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Sanft <[email protected]>
  • Loading branch information
msanft committed Sep 4, 2023
1 parent 58c2784 commit 8018765
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions internal/attestation/azure/snp/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,31 @@ func TestInstanceInfoAttestation(t *testing.T) {
"report too short": {
report: defaultReport[:len(defaultReport)-100],
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
},
"corrupted report": {
report: defaultReport[10 : len(defaultReport)-10],
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
},
"certificate fetch error": {
report: defaultReport[10 : len(defaultReport)-10],
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
assert.AnError,
),
wantErr: true,
},
"success": {
report: defaultReport,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: false,
Expand Down Expand Up @@ -163,7 +163,7 @@ type urlResponseMatcher struct {
vcekResponse []byte
}

func newUrlResponseMatcher(certChainResponse []byte, vcekResponse []byte) *urlResponseMatcher {
func newURLResponseMatcher(certChainResponse []byte, vcekResponse []byte) *urlResponseMatcher {
return &urlResponseMatcher{
certChainResponse: certChainResponse,
vcekResponse: vcekResponse,
Expand Down Expand Up @@ -192,13 +192,13 @@ func TestCheckIDKeyDigest(t *testing.T) {
cfg.FirmwareSignerConfig.EnforcementPolicy = enforcementPolicy
return cfg
}
reportWithIdKeyDigest := func(idKeyDigest string) *spb.Attestation {
reportWithIDKeyDigest := func(idKeyDigest string) *spb.Attestation {
report := &spb.Attestation{}
report.Report = &spb.Report{}
report.Report.IdKeyDigest = []byte(idKeyDigest)
return report
}
newTestValidator := func(cfg *config.AzureSEVSNP, log *logger.Logger, validateTokenErr error) *Validator {
newTestValidator := func(cfg *config.AzureSEVSNP, validateTokenErr error) *Validator {
validator := NewValidator(cfg, logger.NewTest(t))
validator.maa = &stubMaaValidator{
validateTokenErr: validateTokenErr,
Expand Down Expand Up @@ -251,8 +251,8 @@ func TestCheckIDKeyDigest(t *testing.T) {
require := require.New(t)

cfg := cfgWithAcceptedIDKeyDigests(tc.enforcementPolicy, tc.acceptedIDKeyDigests)
report := reportWithIdKeyDigest(tc.idKeyDigest)
validator := newTestValidator(cfg, logger.NewTest(t), tc.validateMaaTokenErr)
report := reportWithIDKeyDigest(tc.idKeyDigest)
validator := newTestValidator(cfg, tc.validateMaaTokenErr)

err := validator.checkIDKeyDigest(context.Background(), report, "", nil)
if tc.wantErr {
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
},
Expand All @@ -442,7 +442,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
assert.AnError,
),
wantErr: true,
Expand All @@ -460,7 +460,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -476,7 +476,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, []byte("invalid")),
newURLResponseMatcher(testdata.CertChain, []byte("invalid")),
nil,
),
wantErr: true,
Expand All @@ -492,7 +492,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher([]byte("invalid"), testdata.VCEK),
newURLResponseMatcher([]byte("invalid"), testdata.VCEK),
nil,
),
},
Expand All @@ -504,7 +504,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -520,7 +520,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -536,7 +536,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -552,7 +552,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: defaultVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
},
Expand All @@ -573,7 +573,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: skipVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -595,7 +595,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: skipVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -613,7 +613,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: skipVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -635,7 +635,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: skipVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -653,7 +653,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: skipVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand All @@ -671,7 +671,7 @@ func TestTrustedKeyFromSNP(t *testing.T) {
verifier: skipVerifier,
validator: defaultValidator,
getter: newStubHTTPSGetter(
newUrlResponseMatcher(testdata.CertChain, testdata.VCEK),
newURLResponseMatcher(testdata.CertChain, testdata.VCEK),
nil,
),
wantErr: true,
Expand Down

0 comments on commit 8018765

Please sign in to comment.