Skip to content

Commit

Permalink
acceptance test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joejstuart committed Nov 6, 2023
1 parent 07d97c6 commit 4e519ff
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
10 changes: 10 additions & 0 deletions acceptance/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Signature struct {
Certificate string `json:"certificate,omitempty"`
Chain []string `json:"chain,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Digest string `json:"digest,omitempty"`
}

// imageState holds the state of images used in acceptance tests keyed by the
Expand Down Expand Up @@ -209,10 +210,15 @@ func createAndPushImageSignature(ctx context.Context, imageName string, keyName
return ctx, err
}

sigDigest, err := signatureLayer.Digest()
if err != nil {
return ctx, err
}
state.Signatures[imageName] = ref.String()
state.ImageSignatures[imageName] = Signature{
KeyID: "",
Signature: signatureBase64,
Digest: sigDigest.String(),
}

return ctx, nil
Expand Down Expand Up @@ -270,6 +276,9 @@ func createAndPushAttestationWithPatches(ctx context.Context, imageName, keyName
if sig, err := unmarshallSignatures(signedAttestation); err != nil {
return ctx, err
} else {
if err != nil {
return ctx, err
}
state.AttestationSignatures[imageName] = Signature{
KeyID: sig.KeyID,
Signature: sig.Sig,
Expand Down Expand Up @@ -857,6 +866,7 @@ func RawImageSignaturesFrom(ctx context.Context) map[string]string {
ret := map[string]string{}
for ref, signature := range state.ImageSignatures {
ret[fmt.Sprintf("IMAGE_SIGNATURE_%s", ref)] = signature.Signature
ret[fmt.Sprintf("SIGNATURE_DIGEST_%s", ref)] = signature.Digest
}

return ret
Expand Down
2 changes: 1 addition & 1 deletion acceptance/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"strings"
"text/tabwriter"

"github.com/cucumber/godog"
clr "github.com/doiit/picocolors"
"golang.org/x/exp/maps"

"github.com/enterprise-contract/ec-cli/acceptance/crypto"
"github.com/enterprise-contract/ec-cli/acceptance/image"
Expand Down
35 changes: 28 additions & 7 deletions features/__snapshots__/validate_image.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -151,7 +154,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -240,7 +246,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -317,7 +326,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -396,7 +408,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -467,7 +482,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
]
}
Expand Down Expand Up @@ -580,7 +598,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-multiple-sources}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-multiple-sources}"
}
}
]
}
Expand Down

0 comments on commit 4e519ff

Please sign in to comment.