1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #21138 from tophj-ibm/add-notary-binary-test-requirement

Add notary binary requirement for tests
This commit is contained in:
Sebastiaan van Stijn 2016-03-14 13:34:06 +01:00
commit 30999ba50c
4 changed files with 17 additions and 6 deletions

View file

@ -158,7 +158,7 @@ type DockerTrustSuite struct {
} }
func (s *DockerTrustSuite) SetUpTest(c *check.C) { func (s *DockerTrustSuite) SetUpTest(c *check.C) {
testRequires(c, RegistryHosting, NotaryHosting) testRequires(c, RegistryHosting, NotaryServerHosting)
s.reg = setupRegistry(c, false, false) s.reg = setupRegistry(c, false, false)
s.not = setupNotary(c) s.not = setupNotary(c)
} }

View file

@ -496,6 +496,7 @@ func (s *DockerTrustSuite) TestTrustedPushWithExpiredTimestamp(c *check.C) {
} }
func (s *DockerTrustSuite) TestTrustedPushWithReleasesDelegation(c *check.C) { func (s *DockerTrustSuite) TestTrustedPushWithReleasesDelegation(c *check.C) {
testRequires(c, NotaryHosting)
repoName := fmt.Sprintf("%v/dockerclireleasedelegation/trusted", privateRegistryURL) repoName := fmt.Sprintf("%v/dockerclireleasedelegation/trusted", privateRegistryURL)
targetName := fmt.Sprintf("%s:latest", repoName) targetName := fmt.Sprintf("%s:latest", repoName)
pwd := "12345678" pwd := "12345678"

View file

@ -97,6 +97,16 @@ var (
}, },
fmt.Sprintf("Test requires an environment that can host %s in the same host", notaryBinary), fmt.Sprintf("Test requires an environment that can host %s in the same host", notaryBinary),
} }
NotaryServerHosting = testRequirement{
func() bool {
// for now notary-server binary is built only if we're running inside
// container through `make test`. Figure that out by testing if
// notary-server binary is in PATH.
_, err := exec.LookPath(notaryServerBinary)
return err == nil
},
fmt.Sprintf("Test requires an environment that can host %s in the same host", notaryServerBinary),
}
NotOverlay = testRequirement{ NotOverlay = testRequirement{
func() bool { func() bool {
cmd := exec.Command("grep", "^overlay / overlay", "/proc/mounts") cmd := exec.Command("grep", "^overlay / overlay", "/proc/mounts")

View file

@ -19,8 +19,8 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
var notaryBinary = "notary-server" var notaryBinary = "notary"
var notaryClientBinary = "notary" var notaryServerBinary = "notary-server"
type testNotary struct { type testNotary struct {
cmd *exec.Cmd cmd *exec.Cmd
@ -91,7 +91,7 @@ func newTestNotary(c *check.C) (*testNotary, error) {
} }
// run notary-server // run notary-server
cmd := exec.Command(notaryBinary, "-config", confPath) cmd := exec.Command(notaryServerBinary, "-config", confPath)
if err := cmd.Start(); err != nil { if err := cmd.Start(); err != nil {
os.RemoveAll(tmp) os.RemoveAll(tmp)
if os.IsNotExist(err) { if os.IsNotExist(err) {
@ -221,7 +221,7 @@ func notaryClientEnv(cmd *exec.Cmd, rootPwd, repositoryPwd string) {
} }
func (s *DockerTrustSuite) setupDelegations(c *check.C, repoName, pwd string) { func (s *DockerTrustSuite) setupDelegations(c *check.C, repoName, pwd string) {
initCmd := exec.Command(notaryClientBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "init", repoName) initCmd := exec.Command(notaryBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "init", repoName)
notaryClientEnv(initCmd, pwd, pwd) notaryClientEnv(initCmd, pwd, pwd)
out, _, err := runCommandWithOutput(initCmd) out, _, err := runCommandWithOutput(initCmd)
if err != nil { if err != nil {
@ -243,7 +243,7 @@ func (s *DockerTrustSuite) setupDelegations(c *check.C, repoName, pwd string) {
} }
// publishing first simulates the client pushing to a repo that they have been given delegated access to // publishing first simulates the client pushing to a repo that they have been given delegated access to
pubCmd := exec.Command(notaryClientBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "publish", repoName) pubCmd := exec.Command(notaryBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "publish", repoName)
notaryClientEnv(pubCmd, pwd, pwd) notaryClientEnv(pubCmd, pwd, pwd)
out, _, err = runCommandWithOutput(pubCmd) out, _, err = runCommandWithOutput(pubCmd)
if err != nil { if err != nil {