Browse code

Remove config tests, which are now unit tests in docker/cli

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2017/08/19 01:24:27
Showing 4 changed files
... ...
@@ -21,8 +21,6 @@ if ! command -v "$TEST_CLIENT_BINARY" &> /dev/null; then
21 21
 	false
22 22
 fi
23 23
 
24
-export DOCKER_CLI_VERSION=$(${TEST_CLIENT_BINARY} --version | awk '{ gsub(",", " "); print $3 }')
25
-
26 24
 # This is a temporary hack for split-binary mode. It can be removed once
27 25
 # https://github.com/docker/docker/pull/22134 is merged into docker master
28 26
 if [ "$(go env GOOS)" = 'windows' ]; then
... ...
@@ -71,7 +71,6 @@ test_env() {
71 71
 		[ -n "$TESTDEBUG" ] && set -x
72 72
 		env -i \
73 73
 			DEST="$ABS_DEST" \
74
-			DOCKER_CLI_VERSION="$DOCKER_CLI_VERSION" \
75 74
 			DOCKER_API_VERSION="$DOCKER_API_VERSION" \
76 75
 			DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \
77 76
 			DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \
... ...
@@ -4,17 +4,14 @@ import (
4 4
 	"fmt"
5 5
 	"io/ioutil"
6 6
 	"net/http"
7
-	"net/http/httptest"
8 7
 	"runtime"
9 8
 	"strconv"
10 9
 	"strings"
11 10
 
12 11
 	"github.com/docker/docker/api"
13 12
 	"github.com/docker/docker/integration-cli/checker"
14
-	"github.com/docker/docker/integration-cli/cli"
15 13
 	"github.com/docker/docker/integration-cli/request"
16 14
 	"github.com/docker/docker/pkg/testutil"
17
-	icmd "github.com/docker/docker/pkg/testutil/cmd"
18 15
 	"github.com/go-check/check"
19 16
 )
20 17
 
... ...
@@ -60,23 +57,6 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) {
60 60
 	c.Assert(strings.TrimSpace(string(content)), checker.Contains, expected)
61 61
 }
62 62
 
63
-func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) {
64
-	var svrVersion string
65
-
66
-	server := httptest.NewServer(http.HandlerFunc(
67
-		func(w http.ResponseWriter, r *http.Request) {
68
-			w.Header().Set("API-Version", api.DefaultVersion)
69
-			url := r.URL.Path
70
-			svrVersion = url
71
-		}))
72
-	defer server.Close()
73
-
74
-	// Test using the env var first
75
-	result := cli.Docker(cli.Args("-H="+server.URL[7:], "version"), cli.WithEnvironmentVariables(appendBaseEnv(false, "DOCKER_API_VERSION=xxx")...))
76
-	c.Assert(result, icmd.Matches, icmd.Expected{Out: "API version:  xxx", ExitCode: 1})
77
-	c.Assert(svrVersion, check.Equals, "/vxxx/version", check.Commentf("%s", result.Compare(icmd.Success)))
78
-}
79
-
80 63
 func (s *DockerSuite) TestAPIErrorJSON(c *check.C) {
81 64
 	httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{}))
82 65
 	c.Assert(err, checker.IsNil)
83 66
deleted file mode 100644
... ...
@@ -1,150 +0,0 @@
1
-package main
2
-
3
-import (
4
-	"io/ioutil"
5
-	"net/http"
6
-	"net/http/httptest"
7
-	"os"
8
-	"path/filepath"
9
-	"runtime"
10
-
11
-	"github.com/docker/docker/api"
12
-	"github.com/docker/docker/integration-cli/checker"
13
-	"github.com/docker/docker/pkg/homedir"
14
-	icmd "github.com/docker/docker/pkg/testutil/cmd"
15
-	"github.com/go-check/check"
16
-)
17
-
18
-func (s *DockerSuite) TestConfigHTTPHeader(c *check.C) {
19
-	testRequires(c, UnixCli) // Can't set/unset HOME on windows right now
20
-	// We either need a level of Go that supports Unsetenv (for cases
21
-	// when HOME/USERPROFILE isn't set), or we need to be able to use
22
-	// os/user but user.Current() only works if we aren't statically compiling
23
-
24
-	var headers map[string][]string
25
-
26
-	server := httptest.NewServer(http.HandlerFunc(
27
-		func(w http.ResponseWriter, r *http.Request) {
28
-			w.Header().Set("API-Version", api.DefaultVersion)
29
-			headers = r.Header
30
-		}))
31
-	defer server.Close()
32
-
33
-	homeKey := homedir.Key()
34
-	homeVal := homedir.Get()
35
-	tmpDir, err := ioutil.TempDir("", "fake-home")
36
-	c.Assert(err, checker.IsNil)
37
-	defer os.RemoveAll(tmpDir)
38
-
39
-	dotDocker := filepath.Join(tmpDir, ".docker")
40
-	os.Mkdir(dotDocker, 0600)
41
-	tmpCfg := filepath.Join(dotDocker, "config.json")
42
-
43
-	defer func() { os.Setenv(homeKey, homeVal) }()
44
-	os.Setenv(homeKey, tmpDir)
45
-
46
-	data := `{
47
-		"HttpHeaders": { "MyHeader": "MyValue" }
48
-	}`
49
-
50
-	err = ioutil.WriteFile(tmpCfg, []byte(data), 0600)
51
-	c.Assert(err, checker.IsNil)
52
-
53
-	result := icmd.RunCommand(dockerBinary, "-H="+server.URL[7:], "ps")
54
-	result.Assert(c, icmd.Expected{
55
-		ExitCode: 1,
56
-		Error:    "exit status 1",
57
-	})
58
-
59
-	c.Assert(headers["User-Agent"], checker.NotNil, check.Commentf("Missing User-Agent"))
60
-
61
-	c.Assert(headers["User-Agent"][0], checker.Equals, "Docker-Client/"+os.Getenv("DOCKER_CLI_VERSION")+" ("+runtime.GOOS+")", check.Commentf("Badly formatted User-Agent,out:%v", result.Combined()))
62
-
63
-	c.Assert(headers["Myheader"], checker.NotNil)
64
-	c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("Missing/bad header,out:%v", result.Combined()))
65
-
66
-}
67
-
68
-func (s *DockerSuite) TestConfigDir(c *check.C) {
69
-	cDir, err := ioutil.TempDir("", "fake-home")
70
-	c.Assert(err, checker.IsNil)
71
-	defer os.RemoveAll(cDir)
72
-
73
-	// First make sure pointing to empty dir doesn't generate an error
74
-	dockerCmd(c, "--config", cDir, "ps")
75
-
76
-	// Test with env var too
77
-	icmd.RunCmd(icmd.Cmd{
78
-		Command: []string{dockerBinary, "ps"},
79
-		Env:     appendBaseEnv(true, "DOCKER_CONFIG="+cDir),
80
-	}).Assert(c, icmd.Success)
81
-
82
-	// Start a server so we can check to see if the config file was
83
-	// loaded properly
84
-	var headers map[string][]string
85
-
86
-	server := httptest.NewServer(http.HandlerFunc(
87
-		func(w http.ResponseWriter, r *http.Request) {
88
-			headers = r.Header
89
-		}))
90
-	defer server.Close()
91
-
92
-	// Create a dummy config file in our new config dir
93
-	data := `{
94
-		"HttpHeaders": { "MyHeader": "MyValue" }
95
-	}`
96
-
97
-	tmpCfg := filepath.Join(cDir, "config.json")
98
-	err = ioutil.WriteFile(tmpCfg, []byte(data), 0600)
99
-	c.Assert(err, checker.IsNil, check.Commentf("Err creating file"))
100
-
101
-	env := appendBaseEnv(false)
102
-
103
-	icmd.RunCmd(icmd.Cmd{
104
-		Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"},
105
-		Env:     env,
106
-	}).Assert(c, icmd.Expected{
107
-		ExitCode: 1,
108
-		Error:    "exit status 1",
109
-	})
110
-	c.Assert(headers["Myheader"], checker.NotNil)
111
-	c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps3 - Missing header"))
112
-
113
-	// Reset headers and try again using env var this time
114
-	headers = map[string][]string{}
115
-	icmd.RunCmd(icmd.Cmd{
116
-		Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"},
117
-		Env:     append(env, "DOCKER_CONFIG="+cDir),
118
-	}).Assert(c, icmd.Expected{
119
-		ExitCode: 1,
120
-	})
121
-	c.Assert(headers["Myheader"], checker.NotNil)
122
-	c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps4 - Missing header"))
123
-
124
-	// FIXME(vdemeester) should be a unit test
125
-	// Reset headers and make sure flag overrides the env var
126
-	headers = map[string][]string{}
127
-	icmd.RunCmd(icmd.Cmd{
128
-		Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"},
129
-		Env:     append(env, "DOCKER_CONFIG=MissingDir"),
130
-	}).Assert(c, icmd.Expected{
131
-		ExitCode: 1,
132
-	})
133
-	c.Assert(headers["Myheader"], checker.NotNil)
134
-	c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps5 - Missing header"))
135
-
136
-	// FIXME(vdemeester) should be a unit test
137
-	// Reset headers and make sure flag overrides the env var.
138
-	// Almost same as previous but make sure the "MissingDir" isn't
139
-	// ignore - we don't want to default back to the env var.
140
-	headers = map[string][]string{}
141
-	icmd.RunCmd(icmd.Cmd{
142
-		Command: []string{dockerBinary, "--config", "MissingDir", "-H=" + server.URL[7:], "ps"},
143
-		Env:     append(env, "DOCKER_CONFIG="+cDir),
144
-	}).Assert(c, icmd.Expected{
145
-		ExitCode: 1,
146
-		Error:    "exit status 1",
147
-	})
148
-
149
-	c.Assert(headers["Myheader"], checker.IsNil, check.Commentf("ps6 - Headers shouldn't be the expected value"))
150
-}