update e2e tests for content trust tests

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
Riyaz Faizullabhoy 2017-10-06 14:46:02 -07:00
parent 067fff8b03
commit 6e3bafd06b
7 changed files with 205 additions and 1 deletions

View File

@ -1,6 +1,6 @@
FROM docker/compose:1.15.0
RUN apk add -U bash curl
RUN apk add -U bash curl ca-certificates
ARG DOCKER_CHANNEL=edge
ARG DOCKER_VERSION=17.06.0-ce
@ -13,5 +13,8 @@ ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
WORKDIR /work
COPY scripts/test/e2e scripts/test/e2e
COPY e2e/compose-env.yaml e2e/compose-env.yaml
COPY e2e/testdata e2e/testdata
COPY e2e/testdata/notary/root-ca.cert /usr/local/share/ca-certificates/notary.cert
RUN update-ca-certificates
ENTRYPOINT ["bash", "/work/scripts/test/e2e/run"]

View File

@ -8,3 +8,11 @@ services:
image: 'docker:${TEST_ENGINE_VERSION:-edge-dind}'
privileged: true
command: ['--insecure-registry=registry:5000']
notary-server:
image: 'notary:server-0.4.2'
ports:
- 4443:4443
volumes:
- ./testdata/notary:/fixtures
command: ['notary-server', '-config=/fixtures/notary-config.json']

View File

@ -0,0 +1,51 @@
package container
import (
"fmt"
"os"
"strings"
"testing"
"github.com/gotestyourself/gotestyourself/icmd"
)
const notaryURL = "https://notary-server:4443"
const registryPrefix = "registry:5000"
func TestPullWithContentTrust(t *testing.T) {
image := createTrustedRemoteImage(t, "trust", "latest")
icmd.RunCmd(trustedCmdNoPassphrases(icmd.Command("docker", "pull", image))).Assert(t, icmd.Success)
// test that pulling without the tag defaults to latest
imageWithoutTag := strings.TrimSuffix(image, ":latest")
icmd.RunCmd(trustedCmdNoPassphrases(icmd.Command("docker", "pull", imageWithoutTag))).Assert(t, icmd.Success)
}
func createTrustedRemoteImage(t *testing.T, repo, tag string) string {
image := fmt.Sprintf("%s/%s:%s", registryPrefix, repo, tag)
icmd.RunCommand("docker", "pull", alpineImage).Assert(t, icmd.Success)
icmd.RunCommand("docker", "tag", alpineImage, image).Assert(t, icmd.Success)
icmd.RunCmd(trustedCmdWithPassphrases(icmd.Command("docker", "push", image), "root_password", "repo_password")).Assert(t, icmd.Success)
icmd.RunCommand("docker", "rmi", image).Assert(t, icmd.Success)
return image
}
func trustedCmdWithPassphrases(cmd icmd.Cmd, rootPwd, repositoryPwd string) icmd.Cmd {
env := append(os.Environ(), []string{
"DOCKER_CONTENT_TRUST=1",
fmt.Sprintf("DOCKER_CONTENT_TRUST_SERVER=%s", notaryURL),
fmt.Sprintf("DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE=%s", rootPwd),
fmt.Sprintf("DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE=%s", repositoryPwd),
}...)
cmd.Env = append(cmd.Env, env...)
return cmd
}
func trustedCmdNoPassphrases(cmd icmd.Cmd) icmd.Cmd {
env := append(os.Environ(), []string{
"DOCKER_CONTENT_TRUST=1",
fmt.Sprintf("DOCKER_CONTENT_TRUST_SERVER=%s", notaryURL),
}...)
cmd.Env = append(cmd.Env, env...)
return cmd
}

19
e2e/testdata/notary/notary-config.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"server": {
"http_addr": "notary-server:4443",
"tls_key_file": "./notary-server.key",
"tls_cert_file": "./notary-server.cert"
},
"trust_service": {
"type": "local",
"hostname": "",
"port": "",
"key_algorithm": "ed25519"
},
"logging": {
"level": "debug"
},
"storage": {
"backend": "memory"
}
}

63
e2e/testdata/notary/notary-server.cert vendored Normal file
View File

@ -0,0 +1,63 @@
-----BEGIN CERTIFICATE-----
MIIFBDCCAuygAwIBAgIJAPlHYZzp1daGMA0GCSqGSIb3DQEBCwUAMGwxCzAJBgNV
BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEPMA0G
A1UEChMGRG9ja2VyMScwJQYDVQQDEx5Ob3RhcnkgSW50ZXJtZWRpYXRlIFRlc3Rp
bmcgQ0EwHhcNMTcw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Zc1NjZ1WQ+XuoUhDgV1yzGpgRGtUdX4fByEUqNZb1GbY6UdIjmx
LvwT2SJnEcv9irGlQU2D4mm5oXgeZXJhxP3gMxEtw9bZS3tUDMWkMD5GCdo8T+FB
tjlGIe8Uh8R4wn33EYDMq+qFeUe+NiMDsVcFIlKWSwCRvmsTB3gvTYYkssuyS65Y
8Ngdsy5GIBhMEsLnZNdwmP7NJ41CECqlojK9tQeu8KAhB7xsKibbwPUbec7whQFl
82vOLgag7Fn3V1eVonqxk7uBt0nriV39/hXifPwBRo3WLoVLUTs+IAOiLapLAb6o
LCQV7ymBRptOyj9bPPYV+NJrfr/5IlkNamioWlbzH3SJdvyp5ldZH/2vciItlO3s
ALNmRewqFkXD
-----END CERTIFICATE-----

28
e2e/testdata/notary/notary-server.key vendored Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCo23n5TrVazr9C
DniRin4uSxx9w4tDtp5WbvACE0iWw2T0l6GHPnKa6aBFmJ3GxRQtwveM+cQVub3A
KjIS7OdJpeQA5fOrpnC5dgv5l/DbmZ5SHrzAm9JgYmrw7Uj1dyeQ6jpPra4ChF7P
YOIcoeTp4eWOSJzztZQyftnBLVRgTIYXXX1kVZVfWVFsT2FQk7ei9Gw/UnslyVQd
HZxYa98SAmsoQ5YZb3I11Tk1LHsCS6Py9p6tL3vdyW9rJioqNu2RhO/WwhqiSttd
/xTanwJRlD5IWE32CU3II4UtaZZrYDeimRekVV7zqwgTBAzNsmatZhD1o6E9LZ9D
JFhKwwDXAgMBAAECggEAbqa0PV0IlqMYze6xr53zpd5uozM61XqcM8Oq35FHZhRQ
2b9riDax3zXtYu3pplGLMZmrouQhTKNU5tI/0gsQXUCqMrR9gyQkhkQHAN5CZYU7
LFEcG5OAvsx/i7XSs5gLg3kaERCdEOUxQ/AW+/BTE7iGN0D6KPH6VUSu6VoNCrTK
PmYvgta7hwebnvo65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