factor out rigging for pushing unsigned busybox image

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
Riyaz Faizullabhoy 2017-10-10 12:00:52 -07:00
parent 46f3d8bb7f
commit 7dda6fc3c9
1 changed files with 8 additions and 4 deletions

View File

@ -31,10 +31,7 @@ func TestPullWithContentTrust(t *testing.T) {
icmd.RunCommand("docker", "rmi", image).Assert(t, icmd.Success) icmd.RunCommand("docker", "rmi", image).Assert(t, icmd.Success)
// push an unsigned image on the same reference name, but with different content (busybox) // push an unsigned image on the same reference name, but with different content (busybox)
icmd.RunCommand("docker", "pull", busyboxImage).Assert(t, icmd.Success) createNamedUnsignedImageFromBusyBox(t, image)
icmd.RunCommand("docker", "tag", busyboxImage, image).Assert(t, icmd.Success)
icmd.RunCommand("docker", "push", image).Assert(t, icmd.Success)
icmd.RunCommand("docker", "rmi", image).Assert(t, icmd.Success)
// now pull with content trust // now pull with content trust
result = icmd.RunCmd(trustedCmdNoPassphrases(icmd.Command("docker", "pull", image))) result = icmd.RunCmd(trustedCmdNoPassphrases(icmd.Command("docker", "pull", image)))
@ -54,6 +51,13 @@ func createTrustedRemoteImage(t *testing.T, repo, tag string) string {
return image return image
} }
func createNamedUnsignedImageFromBusyBox(t *testing.T, image string) {
icmd.RunCommand("docker", "pull", busyboxImage).Assert(t, icmd.Success)
icmd.RunCommand("docker", "tag", busyboxImage, image).Assert(t, icmd.Success)
icmd.RunCommand("docker", "push", image).Assert(t, icmd.Success)
icmd.RunCommand("docker", "rmi", image).Assert(t, icmd.Success)
}
func trustedCmdWithPassphrases(cmd icmd.Cmd, rootPwd, repositoryPwd string) icmd.Cmd { func trustedCmdWithPassphrases(cmd icmd.Cmd, rootPwd, repositoryPwd string) icmd.Cmd {
env := append(os.Environ(), []string{ env := append(os.Environ(), []string{
"DOCKER_CONTENT_TRUST=1", "DOCKER_CONTENT_TRUST=1",