Browse code

integration-cli: add tests for case a) and d) in #21054

- add test for pull from private registry with no credentials
- add test for push to docker hub with no credentials

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Signed-off-by: Antonio Murdaca <amurdaca@localhost.localdomain>
Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/03/13 04:34:07
Showing 2 changed files
... ...
@@ -254,3 +254,12 @@ func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) {
254 254
 	_, err = s.CmdWithError("inspect", repoName)
255 255
 	c.Assert(err, checker.NotNil, check.Commentf("image was pulled after client disconnected"))
256 256
 }
257
+
258
+func (s *DockerRegistryAuthSuite) TestPullNoCredentialsNotFound(c *check.C) {
259
+	// we don't care about the actual image, we just want to see image not found
260
+	// because that means v2 call returned 401 and we fell back to v1 which usually
261
+	// gives a 404 (in this case the test registry doesn't handle v1 at all)
262
+	out, _, err := dockerCmdWithError("pull", privateRegistryURL+"/busybox")
263
+	c.Assert(err, check.NotNil, check.Commentf(out))
264
+	c.Assert(out, checker.Contains, "Error: image busybox not found")
265
+}
... ...
@@ -535,3 +535,13 @@ func (s *DockerRegistryAuthSuite) TestPushNoCredentialsNoRetry(c *check.C) {
535 535
 	c.Assert(out, check.Not(checker.Contains), "Retrying")
536 536
 	c.Assert(out, checker.Contains, "no basic auth credentials")
537 537
 }
538
+
539
+// This may be flaky but it's needed not to regress on unauthorized push, see #21054
540
+func (s *DockerSuite) TestPushToCentralRegistryUnauthorized(c *check.C) {
541
+	testRequires(c, Network)
542
+	repoName := "test/busybox"
543
+	dockerCmd(c, "tag", "busybox", repoName)
544
+	out, _, err := dockerCmdWithError("push", repoName)
545
+	c.Assert(err, check.NotNil, check.Commentf(out))
546
+	c.Assert(out, checker.Contains, "unauthorized: access to the requested resource is not authorized")
547
+}