mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 21:51:33 +00:00
Make --tlsverify enable tls regardless of value specified
I also needed to add a mflag.IsSet() function that allows you to check to see if a certain flag was actually specified on the cmd line. Per #9221 - also tweaked the docs to fix a typo. Closes #9221 Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
@@ -2687,3 +2687,28 @@ func TestContainerNetworkMode(t *testing.T) {
|
||||
|
||||
logDone("run - container shared network namespace")
|
||||
}
|
||||
|
||||
func TestRunTLSverify(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "ps")
|
||||
out, ec, err := runCommandWithOutput(cmd)
|
||||
if err != nil || ec != 0 {
|
||||
t.Fatalf("Should have worked: %v:\n%v", err, out)
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
cmd = exec.Command(dockerBinary, "--tlsverify=false", "ps")
|
||||
out, ec, err = runCommandWithOutput(cmd)
|
||||
if err == nil || ec == 0 || !strings.Contains(out, "trying to connect") {
|
||||
t.Fatalf("Should have failed: \nec:%v\nout:%v\nerr:%v", ec, out, err)
|
||||
}
|
||||
|
||||
cmd = exec.Command(dockerBinary, "--tlsverify=true", "ps")
|
||||
out, ec, err = runCommandWithOutput(cmd)
|
||||
if err == nil || ec == 0 || !strings.Contains(out, "cert") {
|
||||
t.Fatalf("Should have failed: \nec:%v\nout:%v\nerr:%v", ec, out, err)
|
||||
}
|
||||
|
||||
logDone("run - verify tls is set for --tlsverify")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user