2014-05-09 10:32:19 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2015-05-22 23:15:14 +00:00
|
|
|
"fmt"
|
2014-11-11 16:17:33 +00:00
|
|
|
"os"
|
2015-01-07 00:04:10 +00:00
|
|
|
"reflect"
|
2015-04-06 13:21:18 +00:00
|
|
|
"strings"
|
2014-05-09 10:32:19 +00:00
|
|
|
"time"
|
2015-02-26 04:16:44 +00:00
|
|
|
|
2015-07-22 18:39:35 +00:00
|
|
|
"os/exec"
|
|
|
|
|
2015-06-30 16:41:01 +00:00
|
|
|
"github.com/docker/docker/pkg/nat"
|
2015-04-18 16:46:47 +00:00
|
|
|
"github.com/go-check/check"
|
2014-05-09 10:32:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Make sure we can create a simple container with some args
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateArgs(c *check.C) {
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space")
|
2014-05-09 10:32:19 +00:00
|
|
|
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-05-09 10:32:19 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
|
2014-05-09 10:32:19 +00:00
|
|
|
|
|
|
|
containers := []struct {
|
|
|
|
ID string
|
|
|
|
Created time.Time
|
|
|
|
Path string
|
|
|
|
Args []string
|
|
|
|
Image string
|
|
|
|
}{}
|
2014-10-14 19:34:02 +00:00
|
|
|
if err := json.Unmarshal([]byte(out), &containers); err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Error inspecting the container: %s", err)
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
if len(containers) != 1 {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Unexpected container count. Expected 0, received: %d", len(containers))
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
cont := containers[0]
|
|
|
|
if cont.Path != "command" {
|
|
|
|
c.Fatalf("Unexpected container path. Expected command, received: %s", cont.Path)
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
b := false
|
|
|
|
expected := []string{"arg1", "arg2", "arg with space"}
|
|
|
|
for i, arg := range expected {
|
2015-04-18 16:46:47 +00:00
|
|
|
if arg != cont.Args[i] {
|
2014-05-09 10:32:19 +00:00
|
|
|
b = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2015-04-18 16:46:47 +00:00
|
|
|
if len(cont.Args) != len(expected) || b {
|
|
|
|
c.Fatalf("Unexpected args. Expected %v, received: %v", expected, cont.Args)
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we can set hostconfig options too
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateHostConfig(c *check.C) {
|
2015-02-20 06:56:02 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "-P", "busybox", "echo")
|
2014-05-09 10:32:19 +00:00
|
|
|
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-05-09 10:32:19 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
|
2014-05-09 10:32:19 +00:00
|
|
|
|
|
|
|
containers := []struct {
|
|
|
|
HostConfig *struct {
|
|
|
|
PublishAllPorts bool
|
|
|
|
}
|
|
|
|
}{}
|
2014-10-14 19:34:02 +00:00
|
|
|
if err := json.Unmarshal([]byte(out), &containers); err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Error inspecting the container: %s", err)
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
if len(containers) != 1 {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Unexpected container count. Expected 0, received: %d", len(containers))
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
cont := containers[0]
|
|
|
|
if cont.HostConfig == nil {
|
|
|
|
c.Fatalf("Expected HostConfig, got none")
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
if !cont.HostConfig.PublishAllPorts {
|
|
|
|
c.Fatalf("Expected PublishAllPorts, got false")
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateWithPortRange(c *check.C) {
|
2015-02-20 06:56:02 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "-p", "3300-3303:3300-3303/tcp", "busybox", "echo")
|
2014-11-03 18:15:55 +00:00
|
|
|
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-11-03 18:15:55 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
|
2014-11-03 18:15:55 +00:00
|
|
|
|
|
|
|
containers := []struct {
|
|
|
|
HostConfig *struct {
|
|
|
|
PortBindings map[nat.Port][]nat.PortBinding
|
|
|
|
}
|
|
|
|
}{}
|
|
|
|
if err := json.Unmarshal([]byte(out), &containers); err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Error inspecting the container: %s", err)
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
if len(containers) != 1 {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Unexpected container count. Expected 0, received: %d", len(containers))
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
cont := containers[0]
|
|
|
|
if cont.HostConfig == nil {
|
|
|
|
c.Fatalf("Expected HostConfig, got none")
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
if len(cont.HostConfig.PortBindings) != 4 {
|
|
|
|
c.Fatalf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings))
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
2015-04-18 16:46:47 +00:00
|
|
|
for k, v := range cont.HostConfig.PortBindings {
|
2014-11-03 18:15:55 +00:00
|
|
|
if len(v) != 1 {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Expected 1 ports binding, for the port %s but found %s", k, v)
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
if k.Port() != v[0].HostPort {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Expected host port %d to match published port %d", k.Port(), v[0].HostPort)
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateWithiLargePortRange(c *check.C) {
|
2015-02-20 06:56:02 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "-p", "1-65535:1-65535/tcp", "busybox", "echo")
|
2014-11-03 18:15:55 +00:00
|
|
|
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-11-03 18:15:55 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ = dockerCmd(c, "inspect", cleanedContainerID)
|
2014-11-03 18:15:55 +00:00
|
|
|
|
|
|
|
containers := []struct {
|
|
|
|
HostConfig *struct {
|
|
|
|
PortBindings map[nat.Port][]nat.PortBinding
|
|
|
|
}
|
|
|
|
}{}
|
|
|
|
if err := json.Unmarshal([]byte(out), &containers); err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Error inspecting the container: %s", err)
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
if len(containers) != 1 {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Unexpected container count. Expected 0, received: %d", len(containers))
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
cont := containers[0]
|
|
|
|
if cont.HostConfig == nil {
|
|
|
|
c.Fatalf("Expected HostConfig, got none")
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
if len(cont.HostConfig.PortBindings) != 65535 {
|
|
|
|
c.Fatalf("Expected 65535 ports bindings, got %d", len(cont.HostConfig.PortBindings))
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
2015-04-18 16:46:47 +00:00
|
|
|
for k, v := range cont.HostConfig.PortBindings {
|
2014-11-03 18:15:55 +00:00
|
|
|
if len(v) != 1 {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Expected 1 ports binding, for the port %s but found %s", k, v)
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
if k.Port() != v[0].HostPort {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Expected host port %d to match published port %d", k.Port(), v[0].HostPort)
|
2014-11-03 18:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-09 10:32:19 +00:00
|
|
|
// "test123" should be printed by docker create + start
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateEchoStdout(c *check.C) {
|
2015-02-20 06:56:02 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "busybox", "echo", "test123")
|
2014-05-09 10:32:19 +00:00
|
|
|
|
2015-04-06 13:21:18 +00:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-05-09 10:32:19 +00:00
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ = dockerCmd(c, "start", "-ai", cleanedContainerID)
|
2014-05-09 10:32:19 +00:00
|
|
|
|
|
|
|
if out != "test123\n" {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Errorf("container should've printed 'test123', got %q", out)
|
2014-05-09 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-11-11 16:17:33 +00:00
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateVolumesCreated(c *check.C) {
|
|
|
|
testRequires(c, SameHostDaemon)
|
2015-02-20 06:56:02 +00:00
|
|
|
|
2014-11-11 16:17:33 +00:00
|
|
|
name := "test_create_volume"
|
2015-07-14 06:35:36 +00:00
|
|
|
dockerCmd(c, "create", "--name", name, "-v", "/foo", "busybox")
|
|
|
|
|
2015-06-03 19:21:38 +00:00
|
|
|
dir, err := inspectMountSourceField(name, "/foo")
|
2014-11-11 16:17:33 +00:00
|
|
|
if err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Error getting volume host path: %q", err)
|
2014-11-11 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Volume was not created")
|
2014-11-11 16:17:33 +00:00
|
|
|
}
|
|
|
|
if err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Error statting volume host path: %q", err)
|
2014-11-11 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-01-07 00:04:10 +00:00
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateLabels(c *check.C) {
|
2015-01-07 00:04:10 +00:00
|
|
|
name := "test_create_labels"
|
|
|
|
expected := map[string]string{"k1": "v1", "k2": "v2"}
|
2015-07-14 06:35:36 +00:00
|
|
|
dockerCmd(c, "create", "--name", name, "-l", "k1=v1", "--label", "k2=v2", "busybox")
|
2015-01-07 00:04:10 +00:00
|
|
|
|
|
|
|
actual := make(map[string]string)
|
|
|
|
err := inspectFieldAndMarshall(name, "Config.Labels", &actual)
|
|
|
|
if err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatal(err)
|
2015-01-07 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expected, actual) {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Expected %s got %s", expected, actual)
|
2015-01-07 00:04:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
|
2015-01-07 00:04:10 +00:00
|
|
|
imageName := "testcreatebuildlabel"
|
|
|
|
_, err := buildImage(imageName,
|
|
|
|
`FROM busybox
|
|
|
|
LABEL k1=v1 k2=v2`,
|
|
|
|
true)
|
|
|
|
if err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatal(err)
|
2015-01-07 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
name := "test_create_labels_from_image"
|
2015-06-05 17:56:25 +00:00
|
|
|
expected := map[string]string{"k2": "x", "k3": "v3"}
|
2015-07-14 06:35:36 +00:00
|
|
|
dockerCmd(c, "create", "--name", name, "-l", "k2=x", "--label", "k3=v3", imageName)
|
2015-01-07 00:04:10 +00:00
|
|
|
|
|
|
|
actual := make(map[string]string)
|
|
|
|
err = inspectFieldAndMarshall(name, "Config.Labels", &actual)
|
|
|
|
if err != nil {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatal(err)
|
2015-01-07 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expected, actual) {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("Expected %s got %s", expected, actual)
|
2015-01-07 00:04:10 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-10 21:06:43 +00:00
|
|
|
|
2015-04-18 16:46:47 +00:00
|
|
|
func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) {
|
|
|
|
out, _ := dockerCmd(c, "run", "-h", "web.0", "busybox", "hostname")
|
2015-04-10 21:06:43 +00:00
|
|
|
if strings.TrimSpace(out) != "web.0" {
|
2015-04-18 16:46:47 +00:00
|
|
|
c.Fatalf("hostname not set, expected `web.0`, got: %s", out)
|
2015-04-10 21:06:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-21 14:30:51 +00:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestCreateRM(c *check.C) {
|
|
|
|
// Test to make sure we can 'rm' a new container that is in
|
|
|
|
// "Created" state, and has ever been run. Test "rm -f" too.
|
|
|
|
|
|
|
|
// create a container
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "busybox")
|
2015-05-21 14:30:51 +00:00
|
|
|
cID := strings.TrimSpace(out)
|
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
dockerCmd(c, "rm", cID)
|
2015-05-21 14:30:51 +00:00
|
|
|
|
|
|
|
// Now do it again so we can "rm -f" this time
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ = dockerCmd(c, "create", "busybox")
|
2015-05-21 14:30:51 +00:00
|
|
|
|
|
|
|
cID = strings.TrimSpace(out)
|
2015-07-14 06:35:36 +00:00
|
|
|
dockerCmd(c, "rm", "-f", cID)
|
2015-05-21 14:30:51 +00:00
|
|
|
}
|
2015-05-22 23:15:14 +00:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) {
|
|
|
|
testRequires(c, SameHostDaemon)
|
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
out, _ := dockerCmd(c, "create", "busybox")
|
2015-05-22 23:15:14 +00:00
|
|
|
id := strings.TrimSpace(out)
|
|
|
|
|
2015-07-14 06:35:36 +00:00
|
|
|
dockerCmd(c, "create", fmt.Sprintf("--ipc=container:%s", id), "busybox")
|
2015-05-22 23:15:14 +00:00
|
|
|
}
|
2015-07-22 16:14:48 +00:00
|
|
|
|
|
|
|
func (s *DockerTrustSuite) TestTrustedCreate(c *check.C) {
|
2015-07-22 18:39:35 +00:00
|
|
|
repoName := fmt.Sprintf("%v/dockerclicreate/trusted:latest", privateRegistryURL)
|
2015-07-22 16:14:48 +00:00
|
|
|
// tag the image and upload it to the private registry
|
|
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
|
|
|
|
|
|
pushCmd := exec.Command(dockerBinary, "push", repoName)
|
|
|
|
s.trustedCmd(pushCmd)
|
|
|
|
out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Error running trusted push: %s\n%s", err, out)
|
|
|
|
}
|
|
|
|
if !strings.Contains(string(out), "Signing and pushing trust metadata") {
|
|
|
|
c.Fatalf("Missing expected output on trusted push:\n%s", out)
|
|
|
|
}
|
|
|
|
|
|
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
|
|
// Try create
|
|
|
|
createCmd := exec.Command(dockerBinary, "create", repoName)
|
|
|
|
s.trustedCmd(createCmd)
|
|
|
|
out, _, err = runCommandWithOutput(createCmd)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Error running trusted create: %s\n%s", err, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(string(out), "Tagging") {
|
|
|
|
c.Fatalf("Missing expected output on trusted push:\n%s", out)
|
|
|
|
}
|
|
|
|
|
|
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
|
|
// Try untrusted create to ensure we pushed the tag to the registry
|
|
|
|
createCmd = exec.Command(dockerBinary, "create", "--untrusted=true", repoName)
|
|
|
|
s.trustedCmd(createCmd)
|
|
|
|
out, _, err = runCommandWithOutput(createCmd)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Error running trusted create: %s\n%s", err, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(string(out), "Status: Downloaded") {
|
|
|
|
c.Fatalf("Missing expected output on trusted create with --untrusted:\n%s", out)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustSuite) TestUntrustedCreate(c *check.C) {
|
|
|
|
repoName := fmt.Sprintf("%v/dockercli/trusted:latest", privateRegistryURL)
|
|
|
|
// tag the image and upload it to the private registry
|
|
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
|
|
dockerCmd(c, "push", repoName)
|
|
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
|
|
// Try trusted create on untrusted tag
|
|
|
|
createCmd := exec.Command(dockerBinary, "create", repoName)
|
|
|
|
s.trustedCmd(createCmd)
|
|
|
|
out, _, err := runCommandWithOutput(createCmd)
|
|
|
|
if err == nil {
|
|
|
|
c.Fatalf("Error expected when running trusted create with:\n%s", out)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(string(out), "no trust data available") {
|
|
|
|
c.Fatalf("Missing expected output on trusted create:\n%s", out)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustSuite) TestCreateWhenCertExpired(c *check.C) {
|
|
|
|
repoName := fmt.Sprintf("%v/dockercli/trusted:latest", privateRegistryURL)
|
|
|
|
// tag the image and upload it to the private registry
|
|
|
|
dockerCmd(c, "tag", "busybox", repoName)
|
|
|
|
|
|
|
|
pushCmd := exec.Command(dockerBinary, "push", repoName)
|
|
|
|
s.trustedCmd(pushCmd)
|
|
|
|
out, _, err := runCommandWithOutput(pushCmd)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Error running trusted push: %s\n%s", err, out)
|
|
|
|
}
|
|
|
|
if !strings.Contains(string(out), "Signing and pushing trust metadata") {
|
|
|
|
c.Fatalf("Missing expected output on trusted push:\n%s", out)
|
|
|
|
}
|
|
|
|
|
|
|
|
dockerCmd(c, "rmi", repoName)
|
|
|
|
|
|
|
|
// Certificates have 10 years of expiration
|
|
|
|
elevenYearsFromNow := time.Now().Add(time.Hour * 24 * 365 * 11)
|
|
|
|
|
|
|
|
runAtDifferentDate(elevenYearsFromNow, func() {
|
|
|
|
// Try create
|
|
|
|
createCmd := exec.Command(dockerBinary, "create", repoName)
|
|
|
|
s.trustedCmd(createCmd)
|
|
|
|
out, _, err = runCommandWithOutput(createCmd)
|
|
|
|
if err == nil {
|
|
|
|
c.Fatalf("Error running trusted create in the distant future: %s\n%s", err, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(string(out), "could not validate the path to a trusted root") {
|
|
|
|
c.Fatalf("Missing expected output on trusted create in the distant future:\n%s", out)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
runAtDifferentDate(elevenYearsFromNow, func() {
|
|
|
|
// Try create
|
|
|
|
createCmd := exec.Command(dockerBinary, "create", "--untrusted", repoName)
|
|
|
|
s.trustedCmd(createCmd)
|
|
|
|
out, _, err = runCommandWithOutput(createCmd)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Error running untrusted create in the distant future: %s\n%s", err, out)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(string(out), "Status: Downloaded") {
|
|
|
|
c.Fatalf("Missing expected output on untrusted create in the distant future:\n%s", out)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|