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 70d15cb
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 29 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
140 changes: 112 additions & 28 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 Expand Up @@ -664,7 +685,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/bad-actor}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/bad-actor}"
}
}
]
}
Expand Down Expand Up @@ -748,7 +772,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 @@ -836,7 +863,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 @@ -938,7 +968,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-multiple-sources}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-multiple-sources}"
}
}
]
}
Expand Down Expand Up @@ -1110,7 +1143,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 @@ -1211,7 +1247,10 @@ Error: 1 error occurred:
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -1289,7 +1328,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 @@ -1544,7 +1586,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/source}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/source}"
}
}
]
}
Expand Down Expand Up @@ -1671,7 +1716,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
]
}
Expand Down Expand Up @@ -1751,7 +1799,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 @@ -1829,7 +1880,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/my-image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/my-image}"
}
}
]
}
Expand Down Expand Up @@ -1922,7 +1976,10 @@ ${TEMP}/ec-work-${RANDOM}/policy/${RANDOM}/main.rego:34: rego_type_error: undefi
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ec-happy-day}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ec-happy-day}"
}
}
]
}
Expand Down Expand Up @@ -2009,7 +2066,10 @@ ${TEMP}/ec-work-${RANDOM}/policy/${RANDOM}/main.rego:34: rego_type_error: undefi
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
]
}
Expand Down Expand Up @@ -2101,7 +2161,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/unique-successes}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/unique-successes}"
}
}
]
}
Expand Down Expand Up @@ -2216,7 +2279,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image-config}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image-config}"
}
}
]
}
Expand Down Expand Up @@ -2267,7 +2333,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
]
}
Expand Down Expand Up @@ -2432,7 +2501,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/ignore-rekor}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/ignore-rekor}"
}
}
]
}
Expand Down Expand Up @@ -2839,7 +2911,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
]
}
Expand Down Expand Up @@ -2911,7 +2986,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
]
}
Expand Down Expand Up @@ -2993,7 +3071,10 @@ Error: success criteria not met
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/image}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/image}"
}
}
],
"image": {
Expand Down Expand Up @@ -3220,7 +3301,10 @@ Error: 1 error occurred:
"keyid": "",
"sig": "${ATTESTATION_SIGNATURE_acceptance/fetch-oci-blob}"
}
]
],
"digest": {
"sha256": "${SIGNATURE_DIGEST_acceptance/fetch-oci-blob}"
}
}
]
}
Expand Down

0 comments on commit 70d15cb

Please sign in to comment.