Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: add new test package "global" with TestTLSVerify #2196

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions e2e/global/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package global

import (
"testing"

"github.com/docker/cli/internal/test/environment"
"gotest.tools/icmd"
"gotest.tools/skip"
)

func TestTLSVerify(t *testing.T) {
// Remote daemons use TLS and this test is not applicable when TLS is required.
skip.If(t, environment.RemoteDaemon())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps put the "skip" description as third argument to skip.If, then it shows up in the logs as reason why it's skipped


icmd.RunCmd(icmd.Command("docker", "ps")).Assert(t, icmd.Success)

// Regardless of whether we specify true or false we need to
// test to make sure tls is turned on if --tlsverify is specified at all
result := icmd.RunCmd(icmd.Command("docker", "--tlsverify=false", "ps"))
result.Assert(t, icmd.Expected{ExitCode: 1, Err: "unable to resolve docker endpoint:"})

result = icmd.RunCmd(icmd.Command("docker", "--tlsverify=true", "ps"))
result.Assert(t, icmd.Expected{ExitCode: 1, Err: "ca.pem"})
}
17 changes: 17 additions & 0 deletions e2e/global/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package global

import (
"fmt"
"os"
"testing"

"github.com/docker/cli/internal/test/environment"
)

func TestMain(m *testing.M) {
if err := environment.Setup(); err != nil {
fmt.Println(err.Error())
os.Exit(3)
}
os.Exit(m.Run())
}