Changing trustServer allowed URL behavior

Signed-off-by: Diogo Monica <diogo@docker.com>
Upstream-commit: a2f9fb7777ab4ff90747a1fe67dda9046686acad
Component: engine
This commit is contained in:
Diogo Monica
2015-10-08 17:47:25 -07:00
parent b5abf96150
commit 5d84a009ca
4 changed files with 75 additions and 20 deletions
@@ -148,7 +148,7 @@ func (s *DockerTrustSuite) TestTrustedPushWithFaillingServer(c *check.C) {
dockerCmd(c, "tag", "busybox", repoName)
pushCmd := exec.Command(dockerBinary, "push", repoName)
s.trustedCmdWithServer(pushCmd, "example/")
s.trustedCmdWithServer(pushCmd, "https://example.com:81/")
out, _, err := runCommandWithOutput(pushCmd)
if err == nil {
c.Fatalf("Missing error while running trusted push w/ no server")
@@ -165,7 +165,7 @@ func (s *DockerTrustSuite) TestTrustedPushWithoutServerAndUntrusted(c *check.C)
dockerCmd(c, "tag", "busybox", repoName)
pushCmd := exec.Command(dockerBinary, "push", "--disable-content-trust", repoName)
s.trustedCmdWithServer(pushCmd, "example/")
s.trustedCmdWithServer(pushCmd, "https://example.com/")
out, _, err := runCommandWithOutput(pushCmd)
if err != nil {
c.Fatalf("trusted push with no server and --disable-content-trust failed: %s\n%s", err, out)
@@ -22,6 +22,9 @@ type testNotary struct {
dir string
}
const notaryHost = "localhost:4443"
const notaryURL = "https://" + notaryHost
func newTestNotary(c *check.C) (*testNotary, error) {
template := `{
"server": {
@@ -48,7 +51,7 @@ func newTestNotary(c *check.C) (*testNotary, error) {
if err != nil {
return nil, err
}
if _, err := fmt.Fprintf(config, template, "localhost:4443"); err != nil {
if _, err := fmt.Fprintf(config, template, notaryHost); err != nil {
os.RemoveAll(tmp)
return nil, err
}
@@ -82,10 +85,6 @@ func newTestNotary(c *check.C) (*testNotary, error) {
return testNotary, nil
}
func (t *testNotary) address() string {
return "localhost:4443"
}
func (t *testNotary) Ping() error {
tlsConfig := tlsconfig.ClientDefault
tlsConfig.InsecureSkipVerify = true
@@ -100,7 +99,7 @@ func (t *testNotary) Ping() error {
TLSClientConfig: &tlsConfig,
},
}
resp, err := client.Get(fmt.Sprintf("https://%s/v2/", t.address()))
resp, err := client.Get(fmt.Sprintf("%s/v2/", notaryURL))
if err != nil {
return err
}
@@ -117,7 +116,7 @@ func (t *testNotary) Close() {
func (s *DockerTrustSuite) trustedCmd(cmd *exec.Cmd) {
pwd := "12345678"
trustCmdEnv(cmd, s.not.address(), pwd, pwd)
trustCmdEnv(cmd, notaryURL, pwd, pwd)
}
func (s *DockerTrustSuite) trustedCmdWithServer(cmd *exec.Cmd, server string) {
@@ -126,7 +125,7 @@ func (s *DockerTrustSuite) trustedCmdWithServer(cmd *exec.Cmd, server string) {
}
func (s *DockerTrustSuite) trustedCmdWithPassphrases(cmd *exec.Cmd, offlinePwd, taggingPwd string) {
trustCmdEnv(cmd, s.not.address(), offlinePwd, taggingPwd)
trustCmdEnv(cmd, notaryURL, offlinePwd, taggingPwd)
}
func trustCmdEnv(cmd *exec.Cmd, server, offlinePwd, taggingPwd string) {