|
@@ -3,12 +3,11 @@ package main
|
|
import (
|
|
import (
|
|
"fmt"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
- "os/exec"
|
|
|
|
- "strings"
|
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
"github.com/docker/docker/pkg/testutil"
|
|
"github.com/docker/docker/pkg/testutil"
|
|
|
|
+ icmd "github.com/docker/docker/pkg/testutil/cmd"
|
|
"github.com/go-check/check"
|
|
"github.com/go-check/check"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -16,33 +15,18 @@ func (s *DockerTrustSuite) TestTrustedPull(c *check.C) {
|
|
repoName := s.setupTrustedImage(c, "trusted-pull")
|
|
repoName := s.setupTrustedImage(c, "trusted-pull")
|
|
|
|
|
|
// Try pull
|
|
// Try pull
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Tagging", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmd).Assert(c, SuccessTagging)
|
|
|
|
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
// Try untrusted pull to ensure we pushed the tag to the registry
|
|
// Try untrusted pull to ensure we pushed the tag to the registry
|
|
- pullCmd = exec.Command(dockerBinary, "pull", "--disable-content-trust=true", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Status: Downloaded", check.Commentf(out))
|
|
|
|
-
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", "--disable-content-trust=true", repoName), trustedCmd).Assert(c, SuccessDownloaded)
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerTrustSuite) TestTrustedIsolatedPull(c *check.C) {
|
|
func (s *DockerTrustSuite) TestTrustedIsolatedPull(c *check.C) {
|
|
repoName := s.setupTrustedImage(c, "trusted-isolated-pull")
|
|
repoName := s.setupTrustedImage(c, "trusted-isolated-pull")
|
|
|
|
|
|
// Try pull (run from isolated directory without trust information)
|
|
// Try pull (run from isolated directory without trust information)
|
|
- pullCmd := exec.Command(dockerBinary, "--config", "/tmp/docker-isolated", "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Tagging", check.Commentf(string(out)))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "--config", "/tmp/docker-isolated", "pull", repoName), trustedCmd).Assert(c, SuccessTagging)
|
|
|
|
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
}
|
|
}
|
|
@@ -55,12 +39,10 @@ func (s *DockerTrustSuite) TestUntrustedPull(c *check.C) {
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
// Try trusted pull on untrusted tag
|
|
// Try trusted pull on untrusted tag
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Error: remote trust data does not exist", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "Error: remote trust data does not exist",
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerTrustSuite) TestPullWhenCertExpired(c *check.C) {
|
|
func (s *DockerTrustSuite) TestPullWhenCertExpired(c *check.C) {
|
|
@@ -72,22 +54,19 @@ func (s *DockerTrustSuite) TestPullWhenCertExpired(c *check.C) {
|
|
|
|
|
|
testutil.RunAtDifferentDate(elevenYearsFromNow, func() {
|
|
testutil.RunAtDifferentDate(elevenYearsFromNow, func() {
|
|
// Try pull
|
|
// Try pull
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "could not validate the path to a trusted root", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Cmd{
|
|
|
|
+ Command: []string{dockerBinary, "pull", repoName},
|
|
|
|
+ }, trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "could not validate the path to a trusted root",
|
|
|
|
+ })
|
|
})
|
|
})
|
|
|
|
|
|
testutil.RunAtDifferentDate(elevenYearsFromNow, func() {
|
|
testutil.RunAtDifferentDate(elevenYearsFromNow, func() {
|
|
// Try pull
|
|
// Try pull
|
|
- pullCmd := exec.Command(dockerBinary, "pull", "--disable-content-trust", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Status: Downloaded", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Cmd{
|
|
|
|
+ Command: []string{dockerBinary, "pull", "--disable-content-trust", repoName},
|
|
|
|
+ }, trustedCmd).Assert(c, SuccessDownloaded)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,21 +80,11 @@ func (s *DockerTrustSuite) TestTrustedPullFromBadTrustServer(c *check.C) {
|
|
// tag the image and upload it to the private registry
|
|
// tag the image and upload it to the private registry
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
|
|
|
|
- pushCmd := exec.Command(dockerBinary, "push", repoName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Signing and pushing trust metadata", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", repoName), trustedCmd).Assert(c, SuccessSigningAndPushing)
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
// Try pull
|
|
// Try pull
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Tagging", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmd).Assert(c, SuccessTagging)
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
// Kill the notary server, start a new "evil" one.
|
|
// Kill the notary server, start a new "evil" one.
|
|
@@ -129,23 +98,13 @@ func (s *DockerTrustSuite) TestTrustedPullFromBadTrustServer(c *check.C) {
|
|
dockerCmd(c, "--config", evilLocalConfigDir, "tag", "busybox", repoName)
|
|
dockerCmd(c, "--config", evilLocalConfigDir, "tag", "busybox", repoName)
|
|
|
|
|
|
// Push up to the new server
|
|
// Push up to the new server
|
|
- pushCmd = exec.Command(dockerBinary, "--config", evilLocalConfigDir, "push", repoName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pushCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Signing and pushing trust metadata", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "--config", evilLocalConfigDir, "push", repoName), trustedCmd).Assert(c, SuccessSigningAndPushing)
|
|
|
|
|
|
// Now, try pulling with the original client from this new trust server. This should fail because the new root is invalid.
|
|
// Now, try pulling with the original client from this new trust server. This should fail because the new root is invalid.
|
|
- pullCmd = exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- if err == nil {
|
|
|
|
- c.Fatalf("Continuing with cached data even though it's an invalid root rotation: %s\n%s", err, out)
|
|
|
|
- }
|
|
|
|
- if !strings.Contains(out, "could not rotate trust to a new trusted root") {
|
|
|
|
- c.Fatalf("Missing expected output on trusted pull:\n%s", out)
|
|
|
|
- }
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "could not rotate trust to a new trusted root",
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerTrustSuite) TestTrustedPullWithExpiredSnapshot(c *check.C) {
|
|
func (s *DockerTrustSuite) TestTrustedPullWithExpiredSnapshot(c *check.C) {
|
|
@@ -155,13 +114,7 @@ func (s *DockerTrustSuite) TestTrustedPullWithExpiredSnapshot(c *check.C) {
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
|
|
|
|
// Push with default passphrases
|
|
// Push with default passphrases
|
|
- pushCmd := exec.Command(dockerBinary, "push", repoName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Signing and pushing trust metadata", check.Commentf(out))
|
|
|
|
-
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", repoName), trustedCmd).Assert(c, SuccessSigningAndPushing)
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
// Snapshots last for three years. This should be expired
|
|
// Snapshots last for three years. This should be expired
|
|
@@ -169,41 +122,28 @@ func (s *DockerTrustSuite) TestTrustedPullWithExpiredSnapshot(c *check.C) {
|
|
|
|
|
|
testutil.RunAtDifferentDate(fourYearsLater, func() {
|
|
testutil.RunAtDifferentDate(fourYearsLater, func() {
|
|
// Try pull
|
|
// Try pull
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.NotNil, check.Commentf("Missing expected error running trusted pull with expired snapshots"))
|
|
|
|
- c.Assert(string(out), checker.Contains, "repository out-of-date", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Cmd{
|
|
|
|
+ Command: []string{dockerBinary, "pull", repoName},
|
|
|
|
+ }, trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "repository out-of-date",
|
|
|
|
+ })
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerTrustSuite) TestTrustedOfflinePull(c *check.C) {
|
|
func (s *DockerTrustSuite) TestTrustedOfflinePull(c *check.C) {
|
|
repoName := s.setupTrustedImage(c, "trusted-offline-pull")
|
|
repoName := s.setupTrustedImage(c, "trusted-offline-pull")
|
|
|
|
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmdWithServer(pullCmd, "https://invalidnotaryserver")
|
|
|
|
- out, _, err := runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "error contacting notary server", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmdWithServer("https://invalidnotaryserver")).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "error contacting notary server",
|
|
|
|
+ })
|
|
// Do valid trusted pull to warm cache
|
|
// Do valid trusted pull to warm cache
|
|
- pullCmd = exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Tagging", check.Commentf(out))
|
|
|
|
-
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmd).Assert(c, SuccessTagging)
|
|
dockerCmd(c, "rmi", repoName)
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
// Try pull again with invalid notary server, should use cache
|
|
// Try pull again with invalid notary server, should use cache
|
|
- pullCmd = exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmdWithServer(pullCmd, "https://invalidnotaryserver")
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
-
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(string(out), checker.Contains, "Tagging", check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmdWithServer("https://invalidnotaryserver")).Assert(c, SuccessTagging)
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerTrustSuite) TestTrustedPullDelete(c *check.C) {
|
|
func (s *DockerTrustSuite) TestTrustedPullDelete(c *check.C) {
|
|
@@ -214,29 +154,16 @@ func (s *DockerTrustSuite) TestTrustedPullDelete(c *check.C) {
|
|
CMD echo trustedpulldelete
|
|
CMD echo trustedpulldelete
|
|
`, true)
|
|
`, true)
|
|
|
|
|
|
- pushCmd := exec.Command(dockerBinary, "push", repoName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
- if err != nil {
|
|
|
|
- c.Fatalf("Error running trusted push: %s\n%s", err, out)
|
|
|
|
- }
|
|
|
|
- if !strings.Contains(string(out), "Signing and pushing trust metadata") {
|
|
|
|
- c.Fatalf("Missing expected output on trusted push:\n%s", out)
|
|
|
|
- }
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", repoName), trustedCmd).Assert(c, SuccessSigningAndPushing)
|
|
|
|
|
|
- if out, status := dockerCmd(c, "rmi", repoName); status != 0 {
|
|
|
|
- c.Fatalf("Error removing image %q\n%s", repoName, out)
|
|
|
|
- }
|
|
|
|
|
|
+ dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
// Try pull
|
|
// Try pull
|
|
- pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
|
|
+ result := icmd.RunCmd(icmd.Command(dockerBinary, "pull", repoName), trustedCmd)
|
|
|
|
+ result.Assert(c, icmd.Success)
|
|
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
-
|
|
|
|
- matches := digestRegex.FindStringSubmatch(out)
|
|
|
|
- c.Assert(matches, checker.HasLen, 2, check.Commentf("unable to parse digest from pull output: %s", out))
|
|
|
|
|
|
+ matches := digestRegex.FindStringSubmatch(result.Combined())
|
|
|
|
+ c.Assert(matches, checker.HasLen, 2, check.Commentf("unable to parse digest from pull output: %s", result.Combined()))
|
|
pullDigest := matches[1]
|
|
pullDigest := matches[1]
|
|
|
|
|
|
imageID := inspectField(c, repoName, "Id")
|
|
imageID := inspectField(c, repoName, "Id")
|
|
@@ -263,18 +190,13 @@ func (s *DockerTrustSuite) TestTrustedPullReadsFromReleasesRole(c *check.C) {
|
|
|
|
|
|
// Push with targets first, initializing the repo
|
|
// Push with targets first, initializing the repo
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
- pushCmd := exec.Command(dockerBinary, "push", targetName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", targetName), trustedCmd).Assert(c, icmd.Success)
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets")
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets")
|
|
|
|
|
|
// Try pull, check we retrieve from targets role
|
|
// Try pull, check we retrieve from targets role
|
|
- pullCmd := exec.Command(dockerBinary, "-D", "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(out, checker.Contains, "retrieving target for targets role")
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ Err: "retrieving target for targets role",
|
|
|
|
+ })
|
|
|
|
|
|
// Now we'll create the releases role, and try pushing and pulling
|
|
// Now we'll create the releases role, and try pushing and pulling
|
|
s.notaryCreateDelegation(c, repoName, "targets/releases", s.not.keys[0].Public)
|
|
s.notaryCreateDelegation(c, repoName, "targets/releases", s.not.keys[0].Public)
|
|
@@ -283,31 +205,23 @@ func (s *DockerTrustSuite) TestTrustedPullReadsFromReleasesRole(c *check.C) {
|
|
|
|
|
|
// try a pull, check that we can still pull because we can still read the
|
|
// try a pull, check that we can still pull because we can still read the
|
|
// old tag in the targets role
|
|
// old tag in the targets role
|
|
- pullCmd = exec.Command(dockerBinary, "-D", "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
- c.Assert(out, checker.Contains, "retrieving target for targets role")
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ Err: "retrieving target for targets role",
|
|
|
|
+ })
|
|
|
|
|
|
// try a pull -a, check that it succeeds because we can still pull from the
|
|
// try a pull -a, check that it succeeds because we can still pull from the
|
|
// targets role
|
|
// targets role
|
|
- pullCmd = exec.Command(dockerBinary, "-D", "pull", "-a", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", "-a", repoName), trustedCmd).Assert(c, icmd.Success)
|
|
|
|
|
|
// Push, should sign with targets/releases
|
|
// Push, should sign with targets/releases
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
- pushCmd = exec.Command(dockerBinary, "push", targetName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pushCmd)
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", targetName), trustedCmd).Assert(c, icmd.Success)
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets", "targets/releases")
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets", "targets/releases")
|
|
|
|
|
|
// Try pull, check we retrieve from targets/releases role
|
|
// Try pull, check we retrieve from targets/releases role
|
|
- pullCmd = exec.Command(dockerBinary, "-D", "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(out, checker.Contains, "retrieving target for targets/releases role")
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ Err: "retrieving target for targets/releases role",
|
|
|
|
+ })
|
|
|
|
|
|
// Create another delegation that we'll sign with
|
|
// Create another delegation that we'll sign with
|
|
s.notaryCreateDelegation(c, repoName, "targets/other", s.not.keys[1].Public)
|
|
s.notaryCreateDelegation(c, repoName, "targets/other", s.not.keys[1].Public)
|
|
@@ -315,16 +229,13 @@ func (s *DockerTrustSuite) TestTrustedPullReadsFromReleasesRole(c *check.C) {
|
|
s.notaryPublish(c, repoName)
|
|
s.notaryPublish(c, repoName)
|
|
|
|
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
- pushCmd = exec.Command(dockerBinary, "push", targetName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pushCmd)
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", targetName), trustedCmd).Assert(c, icmd.Success)
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets", "targets/releases", "targets/other")
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets", "targets/releases", "targets/other")
|
|
|
|
|
|
// Try pull, check we retrieve from targets/releases role
|
|
// Try pull, check we retrieve from targets/releases role
|
|
- pullCmd = exec.Command(dockerBinary, "-D", "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(out, checker.Contains, "retrieving target for targets/releases role")
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ Err: "retrieving target for targets/releases role",
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerTrustSuite) TestTrustedPullIgnoresOtherDelegationRoles(c *check.C) {
|
|
func (s *DockerTrustSuite) TestTrustedPullIgnoresOtherDelegationRoles(c *check.C) {
|
|
@@ -341,26 +252,22 @@ func (s *DockerTrustSuite) TestTrustedPullIgnoresOtherDelegationRoles(c *check.C
|
|
|
|
|
|
// Push should write to the delegation role, not targets
|
|
// Push should write to the delegation role, not targets
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
dockerCmd(c, "tag", "busybox", targetName)
|
|
- pushCmd := exec.Command(dockerBinary, "push", targetName)
|
|
|
|
- s.trustedCmd(pushCmd)
|
|
|
|
- out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
- c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "push", targetName), trustedCmd).Assert(c, icmd.Success)
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets/other")
|
|
s.assertTargetInRoles(c, repoName, "latest", "targets/other")
|
|
s.assertTargetNotInRoles(c, repoName, "latest", "targets")
|
|
s.assertTargetNotInRoles(c, repoName, "latest", "targets")
|
|
|
|
|
|
// Try pull - we should fail, since pull will only pull from the targets/releases
|
|
// Try pull - we should fail, since pull will only pull from the targets/releases
|
|
// role or the targets role
|
|
// role or the targets role
|
|
- pullCmd := exec.Command(dockerBinary, "-D", "pull", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
|
- c.Assert(out, checker.Contains, "No trust data for")
|
|
|
|
|
|
+ dockerCmd(c, "tag", "busybox", targetName)
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "No trust data for",
|
|
|
|
+ })
|
|
|
|
|
|
// try a pull -a: we should fail since pull will only pull from the targets/releases
|
|
// try a pull -a: we should fail since pull will only pull from the targets/releases
|
|
// role or the targets role
|
|
// role or the targets role
|
|
- pullCmd = exec.Command(dockerBinary, "-D", "pull", "-a", repoName)
|
|
|
|
- s.trustedCmd(pullCmd)
|
|
|
|
- out, _, err = runCommandWithOutput(pullCmd)
|
|
|
|
- c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
|
- c.Assert(out, checker.Contains, "No trusted tags for")
|
|
|
|
|
|
+ icmd.RunCmd(icmd.Command(dockerBinary, "-D", "pull", "-a", repoName), trustedCmd).Assert(c, icmd.Expected{
|
|
|
|
+ ExitCode: 1,
|
|
|
|
+ Err: "No trusted tags for",
|
|
|
|
+ })
|
|
}
|
|
}
|