2016-06-15 17:18:55 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-12-12 23:05:53 +00:00
|
|
|
"fmt"
|
2016-12-27 20:51:00 +00:00
|
|
|
"os/exec"
|
2016-12-12 23:05:53 +00:00
|
|
|
|
2016-12-30 17:23:00 +00:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2016-06-15 17:18:55 +00:00
|
|
|
"github.com/go-check/check"
|
2016-07-15 17:37:17 +00:00
|
|
|
|
2016-11-22 17:42:58 +00:00
|
|
|
"io/ioutil"
|
2016-07-27 20:38:13 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2016-07-15 17:37:17 +00:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-11-22 19:21:34 +00:00
|
|
|
pluginProcessName = "sample-volume-plugin"
|
2016-12-12 23:05:53 +00:00
|
|
|
pName = "tonistiigi/sample-volume-plugin"
|
2016-12-16 20:53:22 +00:00
|
|
|
npName = "tonistiigi/test-docker-netplugin"
|
2016-11-10 21:07:53 +00:00
|
|
|
pTag = "latest"
|
|
|
|
pNameWithTag = pName + ":" + pTag
|
2016-12-16 20:53:22 +00:00
|
|
|
npNameWithTag = npName + ":" + pTag
|
2016-06-15 17:18:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-07-15 17:37:17 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
2016-06-15 17:18:55 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 17:37:17 +00:00
|
|
|
c.Assert(out, checker.Contains, pName)
|
|
|
|
c.Assert(out, checker.Contains, pTag)
|
2016-06-15 17:18:55 +00:00
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
|
2016-08-17 11:52:27 +00:00
|
|
|
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
|
2016-11-05 00:37:41 +00:00
|
|
|
id = strings.TrimSpace(id)
|
2016-07-27 20:38:13 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-06-15 17:18:55 +00:00
|
|
|
|
2016-07-15 17:37:17 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-11-22 19:21:34 +00:00
|
|
|
c.Assert(err, checker.NotNil)
|
2016-08-04 23:19:46 +00:00
|
|
|
c.Assert(out, checker.Contains, "is enabled")
|
2016-06-15 17:18:55 +00:00
|
|
|
|
2016-07-15 17:37:17 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
2016-06-15 17:18:55 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
2016-07-15 17:37:17 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-06-15 17:18:55 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 17:37:17 +00:00
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
2016-07-27 20:38:13 +00:00
|
|
|
|
2016-08-17 11:52:27 +00:00
|
|
|
_, err = os.Stat(filepath.Join(dockerBasePath, "plugins", id))
|
2016-07-27 20:38:13 +00:00
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
c.Fatal(err)
|
|
|
|
}
|
2016-06-15 17:18:55 +00:00
|
|
|
}
|
2016-06-17 14:44:57 +00:00
|
|
|
|
2016-07-22 15:24:54 +00:00
|
|
|
func (s *DockerSuite) TestPluginForceRemove(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-07-22 15:24:54 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-08-04 23:19:46 +00:00
|
|
|
c.Assert(out, checker.Contains, "is enabled")
|
2016-07-22 15:24:54 +00:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag)
|
2016-09-07 13:59:15 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginActive(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-12-20 16:26:58 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
2016-09-07 13:59:15 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
2016-12-20 16:26:58 +00:00
|
|
|
_, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag, "--name", "testvol1")
|
2016-09-07 13:59:15 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
2016-12-20 16:26:58 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "disable", pNameWithTag)
|
|
|
|
c.Assert(out, checker.Contains, "in use")
|
2016-09-07 13:59:15 +00:00
|
|
|
|
2016-12-20 16:26:58 +00:00
|
|
|
_, _, err = dockerCmdWithError("volume", "rm", "testvol1")
|
2016-09-07 13:59:15 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-07-22 15:24:54 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
|
|
|
}
|
|
|
|
|
2016-12-16 20:53:22 +00:00
|
|
|
func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("network", "create", "-d", npNameWithTag, "test")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
nID := strings.TrimSpace(out)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
|
|
|
c.Assert(out, checker.Contains, "is in use")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("network", "rm", nID)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
|
|
|
c.Assert(out, checker.Contains, "is enabled")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, npNameWithTag)
|
|
|
|
}
|
|
|
|
|
2016-06-17 14:44:57 +00:00
|
|
|
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-07-15 17:37:17 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
2016-06-17 14:44:57 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 17:37:17 +00:00
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
2016-06-17 14:44:57 +00:00
|
|
|
|
2016-07-15 17:37:17 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2016-06-17 14:44:57 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, "false")
|
|
|
|
|
2016-07-15 17:37:17 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pName)
|
2016-06-17 14:44:57 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 17:37:17 +00:00
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
2016-06-17 14:44:57 +00:00
|
|
|
}
|
2016-07-06 19:16:14 +00:00
|
|
|
|
2016-11-01 22:03:14 +00:00
|
|
|
func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-11-01 22:03:14 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
dockerCmd(c, "volume", "ls")
|
|
|
|
}
|
|
|
|
|
2016-11-01 00:07:05 +00:00
|
|
|
func (s *DockerSuite) TestPluginSet(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-11-01 00:07:05 +00:00
|
|
|
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
2016-11-08 02:51:47 +00:00
|
|
|
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
2016-11-01 00:07:05 +00:00
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
|
|
|
|
|
|
|
|
dockerCmd(c, "plugin", "set", pName, "DEBUG=1")
|
|
|
|
|
2016-11-08 02:51:47 +00:00
|
|
|
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
2016-11-01 00:07:05 +00:00
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
|
|
|
|
}
|
|
|
|
|
2016-11-08 01:43:11 +00:00
|
|
|
func (s *DockerSuite) TestPluginInstallArgs(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-11-08 01:43:11 +00:00
|
|
|
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName, "DEBUG=1")
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
2016-11-08 02:51:47 +00:00
|
|
|
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
2016-11-08 01:43:11 +00:00
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
|
|
|
|
}
|
|
|
|
|
2016-12-12 23:05:53 +00:00
|
|
|
func (s *DockerRegistrySuite) TestPluginInstallImage(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64)
|
|
|
|
|
|
|
|
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
|
|
|
|
// tag the image to upload it to the private registry
|
|
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
|
|
// push the image to the registry
|
|
|
|
dockerCmd(c, "push", repoName)
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", repoName)
|
2016-07-06 19:16:14 +00:00
|
|
|
c.Assert(err, checker.NotNil)
|
2016-12-12 23:05:53 +00:00
|
|
|
c.Assert(out, checker.Contains, "target is image")
|
2016-07-06 19:16:14 +00:00
|
|
|
}
|
2016-07-25 21:06:27 +00:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-07-25 21:06:27 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "remove", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
}
|
2016-11-22 17:42:58 +00:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginCreate(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-11-22 17:42:58 +00:00
|
|
|
|
|
|
|
name := "foo/bar-driver"
|
|
|
|
temp, err := ioutil.TempDir("", "foo")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
defer os.RemoveAll(temp)
|
|
|
|
|
|
|
|
data := `{"description": "foo plugin"}`
|
|
|
|
err = ioutil.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0644)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
2016-12-12 23:05:53 +00:00
|
|
|
err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0700)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
2016-11-22 17:42:58 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "create", name, temp)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, name)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, name)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "create", name, temp)
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(out, checker.Contains, "already exist")
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, name)
|
|
|
|
// The output will consists of one HEADER line and one line of foo/bar-driver
|
|
|
|
c.Assert(len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2)
|
|
|
|
}
|
2016-11-24 04:04:44 +00:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginInspect(c *check.C) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-11-24 04:04:44 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pName)
|
|
|
|
c.Assert(out, checker.Contains, pTag)
|
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
|
|
|
|
// Find the ID first
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
id := strings.TrimSpace(out)
|
|
|
|
c.Assert(id, checker.Not(checker.Equals), "")
|
|
|
|
|
|
|
|
// Long form
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, id)
|
|
|
|
|
|
|
|
// Short form
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, id)
|
|
|
|
|
|
|
|
// Name with tag form
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, id)
|
|
|
|
|
|
|
|
// Name without tag form
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, id)
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
|
|
|
|
|
|
|
// After remove nothing should be found
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
}
|
2016-12-07 15:38:18 +00:00
|
|
|
|
|
|
|
// Test case for https://github.com/docker/docker/pull/29186#discussion_r91277345
|
|
|
|
func (s *DockerSuite) TestPluginInspectOnWindows(c *check.C) {
|
|
|
|
// This test should work on Windows only
|
|
|
|
testRequires(c, DaemonIsWindows)
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "inspect", "foobar")
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(out, checker.Contains, "plugins are not supported on this platform")
|
|
|
|
c.Assert(err.Error(), checker.Contains, "plugins are not supported on this platform")
|
|
|
|
}
|
2016-12-27 20:51:00 +00:00
|
|
|
|
|
|
|
func (s *DockerTrustSuite) TestPluginTrustedInstall(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
|
|
|
|
|
|
|
trustedName := s.setupTrustedplugin(c, pNameWithTag, "trusted-plugin-install")
|
|
|
|
|
|
|
|
installCmd := exec.Command(dockerBinary, "plugin", "install", "--grant-all-permissions", trustedName)
|
|
|
|
s.trustedCmd(installCmd)
|
|
|
|
out, _, err := runCommandWithOutput(installCmd)
|
|
|
|
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", trustedName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", trustedName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "rm", "-f", trustedName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
|
|
|
|
|
|
|
|
// Try untrusted pull to ensure we pushed the tag to the registry
|
|
|
|
installCmd = exec.Command(dockerBinary, "plugin", "install", "--disable-content-trust=true", "--grant-all-permissions", trustedName)
|
|
|
|
s.trustedCmd(installCmd)
|
|
|
|
out, _, err = runCommandWithOutput(installCmd)
|
|
|
|
c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
c.Assert(string(out), checker.Contains, "Status: Downloaded", check.Commentf(out))
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustSuite) TestPluginUntrustedInstall(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
|
|
|
|
|
|
|
pluginName := fmt.Sprintf("%v/dockercliuntrusted/plugintest:latest", privateRegistryURL)
|
|
|
|
// install locally and push to private registry
|
|
|
|
dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--alias", pluginName, pNameWithTag)
|
|
|
|
dockerCmd(c, "plugin", "push", pluginName)
|
|
|
|
dockerCmd(c, "plugin", "rm", "-f", pluginName)
|
|
|
|
|
|
|
|
// Try trusted install on untrusted plugin
|
|
|
|
installCmd := exec.Command(dockerBinary, "plugin", "install", "--grant-all-permissions", pluginName)
|
|
|
|
s.trustedCmd(installCmd)
|
|
|
|
out, _, err := runCommandWithOutput(installCmd)
|
|
|
|
|
|
|
|
c.Assert(err, check.NotNil, check.Commentf(out))
|
|
|
|
c.Assert(string(out), checker.Contains, "Error: remote trust data does not exist", check.Commentf(out))
|
|
|
|
}
|
2016-12-22 23:41:53 +00:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginIDPrefix(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--disable", "--grant-all-permissions", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
// Find ID first
|
|
|
|
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
|
|
|
|
id = strings.TrimSpace(id)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
// List current state
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pName)
|
|
|
|
c.Assert(out, checker.Contains, pTag)
|
|
|
|
c.Assert(out, checker.Contains, "false")
|
|
|
|
|
|
|
|
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
|
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
|
|
|
|
|
|
|
|
dockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
|
|
|
|
|
|
|
|
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
|
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
|
|
|
|
|
|
|
|
// Enable
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "enable", id[:5])
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pName)
|
|
|
|
c.Assert(out, checker.Contains, pTag)
|
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
|
|
|
|
// Disable
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", id[:5])
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pName)
|
|
|
|
c.Assert(out, checker.Contains, pTag)
|
|
|
|
c.Assert(out, checker.Contains, "false")
|
|
|
|
|
|
|
|
// Remove
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", id[:5])
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
// List returns none
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Not(checker.Contains), pName)
|
|
|
|
c.Assert(out, checker.Not(checker.Contains), pTag)
|
|
|
|
}
|