Skip to content

Commit f99dcde

Browse files
committed
Update e2e tests to use scaffolding containers
Signed-off-by: Aaron Lew <[email protected]>
1 parent 4e3042c commit f99dcde

File tree

6 files changed

+31
-257
lines changed

6 files changed

+31
-257
lines changed

test/e2e_test.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,8 @@ func trustedRootCmd(t *testing.T, downloadDirectory, tsaURL string) *trustedroot
588588
defer rekorFP.Close()
589589
must(downloadFile(rekorURL+"/api/v1/log/publicKey", rekorFP), t)
590590
ctfePath := filepath.Join(downloadDirectory, "ctfe.pub")
591-
home, err := os.UserHomeDir()
592-
must(err, t)
593-
must(copyFile(filepath.Join(home, "fulcio", "config", "ctfe", "pubkey.pem"), ctfePath), t)
591+
ctLogKey := os.Getenv("CT_LOG_KEY")
592+
must(copyFile(ctLogKey, ctfePath), t)
594593
out := filepath.Join(downloadDirectory, "trusted_root.json")
595594
cmd := &trustedroot.CreateCmd{
596595
CertChain: []string{caPath},
@@ -624,8 +623,7 @@ func prepareTrustedRootWithSelfSignedCertificate(t *testing.T, certPath, tsaURL
624623
}
625624

626625
func TestSignVerifyWithTUFMirror(t *testing.T) {
627-
home, err := os.UserHomeDir() // fulcio repo was downloaded to $HOME in e2e_test.sh
628-
must(err, t)
626+
ctLogKey := os.Getenv("CT_LOG_KEY")
629627
tufLocalCache := t.TempDir()
630628
t.Setenv("TUF_ROOT", tufLocalCache)
631629
tufMirror := t.TempDir()
@@ -652,7 +650,7 @@ func TestSignVerifyWithTUFMirror(t *testing.T) {
652650
targets: []targetInfo{
653651
{
654652
name: "ct.pub",
655-
source: filepath.Join(home, "fulcio", "config", "ctfe", "pubkey.pem"),
653+
source: ctLogKey,
656654
},
657655
},
658656
wantSignErr: true,
@@ -670,7 +668,7 @@ func TestSignVerifyWithTUFMirror(t *testing.T) {
670668
},
671669
{
672670
name: "ctfe.pub",
673-
source: filepath.Join(home, "fulcio", "config", "ctfe", "pubkey.pem"),
671+
source: ctLogKey,
674672
},
675673
{
676674
name: "tsa_leaf.crt.pem",
@@ -699,7 +697,7 @@ func TestSignVerifyWithTUFMirror(t *testing.T) {
699697
},
700698
{
701699
name: "ctfe.pub",
702-
source: filepath.Join(home, "fulcio", "config", "ctfe", "pubkey.pem"),
700+
source: ctLogKey,
703701
},
704702
{
705703
name: "tsaleaf.pem",
@@ -737,7 +735,7 @@ func TestSignVerifyWithTUFMirror(t *testing.T) {
737735
{
738736
name: "cert-transparency.pem",
739737
usage: "CTFE",
740-
source: filepath.Join(home, "fulcio", "config", "ctfe", "pubkey.pem"),
738+
source: ctLogKey,
741739
},
742740
{
743741
name: "tsaleaf.pem",
@@ -813,7 +811,7 @@ func TestSignVerifyWithTUFMirror(t *testing.T) {
813811
must(gotErr, t)
814812

815813
// Verify an image
816-
issuer := os.Getenv("OIDC_URL")
814+
issuer := os.Getenv("ISSUER_URL")
817815
verifyCmd := cliverify.VerifyCommand{
818816
CertVerifyOptions: options.CertVerifyOptions{
819817
CertOidcIssuer: issuer,
@@ -959,7 +957,7 @@ func TestSignAttestVerifyBlobWithSigningConfig(t *testing.T) {
959957
must(err, t)
960958

961959
// Verify a blob
962-
issuer := os.Getenv("OIDC_URL")
960+
issuer := os.Getenv("ISSUER_URL")
963961
verifyBlobCmd := cliverify.VerifyBlobCmd{
964962
KeyOpts: ko,
965963
CertVerifyOptions: options.CertVerifyOptions{
@@ -1074,7 +1072,7 @@ func TestSignAttestVerifyContainerWithSigningConfig(t *testing.T) {
10741072
// Verify Fulcio-signed image
10751073
cmd := cliverify.VerifyCommand{
10761074
CertVerifyOptions: options.CertVerifyOptions{
1077-
CertOidcIssuer: os.Getenv("OIDC_URL"),
1075+
CertOidcIssuer: os.Getenv("ISSUER_URL"),
10781076
CertIdentity: certID,
10791077
},
10801078
NewBundleFormat: true,
@@ -1102,7 +1100,7 @@ func TestSignAttestVerifyContainerWithSigningConfig(t *testing.T) {
11021100
// Verify attestation
11031101
verifyAttestation := cliverify.VerifyAttestationCommand{
11041102
CertVerifyOptions: options.CertVerifyOptions{
1105-
CertOidcIssuer: os.Getenv("OIDC_URL"),
1103+
CertOidcIssuer: os.Getenv("ISSUER_URL"),
11061104
CertIdentity: certID,
11071105
},
11081106
CommonVerifyOptions: options.CommonVerifyOptions{
@@ -1412,7 +1410,7 @@ func TestSignVerifyBundle(t *testing.T) {
14121410
// Verify Fulcio-signed image
14131411
cmd = cliverify.VerifyCommand{
14141412
CertVerifyOptions: options.CertVerifyOptions{
1415-
CertOidcIssuer: os.Getenv("OIDC_URL"),
1413+
CertOidcIssuer: os.Getenv("ISSUER_URL"),
14161414
CertIdentityRegexp: ".+",
14171415
},
14181416
CommonVerifyOptions: options.CommonVerifyOptions{
@@ -3998,7 +3996,7 @@ from %s
39983996
`, signedImg1)
39993997
withLowercaseDockerfile := mkfile(withLowercaseDockerfileContents, td, t)
40003998

4001-
issuer := os.Getenv("OIDC_URL")
3999+
issuer := os.Getenv("ISSUER_URL")
40024000

40034001
tests := []struct {
40044002
name string
@@ -4127,7 +4125,7 @@ spec:
41274125
unsignedManifestContents := fmt.Sprintf(manifestTemplate, "unsigned-img", unsignedImg)
41284126
unsignedManifest := mkfileWithExt(unsignedManifestContents, td, ".yaml", t)
41294127

4130-
issuer := os.Getenv("OIDC_URL")
4128+
issuer := os.Getenv("ISSUER_URL")
41314129

41324130
tests := []struct {
41334131
name string

test/e2e_test.sh

Lines changed: 14 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -16,116 +16,36 @@
1616

1717
set -ex
1818

19-
docker_compose="docker compose"
20-
if ! ${docker_compose} version >/dev/null 2>&1; then
21-
docker_compose="docker-compose"
22-
fi
23-
24-
echo "setting up OIDC provider"
25-
pushd ./test/fakeoidc
26-
oidcimg=$(ko build main.go --local)
27-
docker network ls | grep fulcio_default || docker network create fulcio_default --label "com.docker.compose.network=fulcio_default"
28-
docker run -d --rm -p 8080:8080 --network fulcio_default --name fakeoidc $oidcimg
29-
cleanup_oidc() {
30-
echo "cleaning up oidc"
31-
docker stop fakeoidc
32-
}
33-
trap cleanup_oidc EXIT
34-
oidc_ip=$(docker inspect fakeoidc | jq -r '.[0].NetworkSettings.Networks.fulcio_default.IPAddress')
35-
export OIDC_URL="http://${oidc_ip}:8080"
36-
cat <<EOF > /tmp/fulcio-config.json
37-
{
38-
"OIDCIssuers": {
39-
"$OIDC_URL": {
40-
"IssuerURL": "$OIDC_URL",
41-
"ClientID": "sigstore",
42-
"Type": "email"
43-
}
44-
}
45-
}
46-
EOF
19+
echo "downloading sigstore/scaffolding repository"
20+
SCAFFOLDING_DIR=$(mktemp -d)
21+
git clone https://github.com/sigstore/scaffolding.git "$SCAFFOLDING_DIR"
22+
SCAFFOLDING_SETUP_DIR="$SCAFFOLDING_DIR/actions/setup-sigstore-env"
23+
24+
echo "setting up sigstore test environment"
25+
pushd "$SCAFFOLDING_SETUP_DIR"
26+
source ./run-containers.sh
4727
popd
4828

49-
pushd $HOME
50-
51-
echo "downloading service repos"
52-
for repo in rekor fulcio; do
53-
if [[ ! -d $repo ]]; then
54-
git clone https://github.com/sigstore/${repo}.git
55-
else
56-
pushd $repo
57-
git pull
58-
popd
59-
fi
60-
done
61-
62-
echo "starting services"
63-
export FULCIO_METRICS_PORT=2113
64-
export FULCIO_CONFIG=/tmp/fulcio-config.json
65-
for repo in rekor fulcio; do
66-
pushd $repo
67-
if [ "$repo" == "fulcio" ]; then
68-
yq -i e '.networks={"default":{ "name":"fulcio_default","external":true }}' docker-compose.yml
69-
yq -i e '.services.fulcio-server.networks=["default"]' docker-compose.yml
70-
fi
71-
${docker_compose} up -d
72-
echo -n "waiting up to 60 sec for system to start"
73-
if [ "$repo" == "fulcio" ]; then
74-
healthytotal=3
75-
elif [ "$repo" == "rekor" ]; then
76-
healthytotal=5
77-
else
78-
# handle no match in case another service is added
79-
healthytotal=0
80-
fi
81-
count=0
82-
until [ $(${docker_compose} ps | grep -c "(healthy)") == $healthytotal ];
83-
do
84-
if [ $count -eq 18 ]; then
85-
echo "! timeout reached"
86-
exit 1
87-
else
88-
echo -n "."
89-
sleep 10
90-
let 'count+=1'
91-
fi
92-
done
29+
cleanup() {
30+
echo "cleaning up sigstore test environment"
31+
pushd "$SCAFFOLDING_SETUP_DIR"
32+
stop_services
9333
popd
94-
done
95-
cleanup_services() {
96-
echo "cleaning up"
97-
cleanup_oidc
98-
for repo in rekor fulcio; do
99-
pushd $HOME/$repo
100-
${docker_compose} down
101-
popd
102-
done
34+
docker rm -f registry registry-2 || true
10335
}
104-
trap cleanup_services EXIT
36+
trap cleanup EXIT
10537

10638
echo
10739
echo "running tests"
108-
109-
popd
11040
go test -tags=e2e -v -race ./test/...
11141

11242
# Test on a private registry
11343
echo "testing sign/verify/clean on private registry"
114-
cleanup_registry() {
115-
cleanup_services
116-
docker rm -f registry
117-
}
118-
trap cleanup_registry EXIT
11944
docker run -d -p 5000:5000 --restart always -e REGISTRY_STORAGE_DELETE_ENABLED=true --name registry registry:latest
12045
export COSIGN_TEST_REPO=localhost:5000
12146
go test -tags=e2e -v ./test/... -run TestSignVerifyClean
12247

12348
# Test with signature in separate registry
124-
cleanup() {
125-
cleanup_registry
126-
docker rm -f registry-2
127-
}
128-
trap cleanup EXIT
12949
docker run -d -p 5001:5000 --restart always -e REGISTRY_STORAGE_DELETE_ENABLED=true --name registry-2 registry:latest
13050
export COSIGN_REPOSITORY=localhost:5001/hello
13151
go test -tags=e2e -v ./test/... -run TestSignVerifyWithRepoOverride

test/fakeoidc/go.mod

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/fakeoidc/go.sum

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/fakeoidc/main.go

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)