MCPcopy Create free account
hub / github.com/docker/cli / TestDisplayTrustRootInvalidFlags

Function TestDisplayTrustRootInvalidFlags

cli/command/swarm/ca_test.go:80–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestDisplayTrustRootInvalidFlags(t *testing.T) {
81 // we need an actual PEMfile to test
82 tmpDir := t.TempDir()
83 tmpFile, err := writeFile(tmpDir, cert)
84 assert.NilError(t, err)
85
86 errorTestCases := []invalidCATestCases{
87 {
88 args: []string{"--ca-cert=" + tmpFile},
89 errorMsg: "flag requires the `--rotate` flag to update the CA",
90 },
91 {
92 args: []string{"--ca-key=" + tmpFile},
93 errorMsg: "flag requires the `--rotate` flag to update the CA",
94 },
95 { // to make sure we're not erroring because we didn't provide a CA key along with the CA cert
96 args: []string{
97 "--ca-cert=" + tmpFile,
98 "--ca-key=" + tmpFile,
99 },
100 errorMsg: "flag requires the `--rotate` flag to update the CA",
101 },
102 {
103 args: []string{"--cert-expiry=2160h0m0s"},
104 errorMsg: "flag requires the `--rotate` flag to update the CA",
105 },
106 {
107 args: []string{"--external-ca=protocol=cfssl,url=https://some.example.com/https/url"},
108 errorMsg: "flag requires the `--rotate` flag to update the CA",
109 },
110 { // to make sure we're not erroring because we didn't provide a CA cert and external CA
111 args: []string{
112 "--ca-cert=" + tmpFile,
113 "--external-ca=protocol=cfssl,url=https://some.example.com/https/url",
114 },
115 errorMsg: "flag requires the `--rotate` flag to update the CA",
116 },
117 {
118 args: []string{
119 "--rotate",
120 "--external-ca=protocol=cfssl,url=https://some.example.com/https/url",
121 },
122 errorMsg: "rotating to an external CA requires the `--ca-cert` flag to specify the external CA's cert - " +
123 "to add an external CA with the current root CA certificate, use the `update` command instead",
124 },
125 {
126 args: []string{
127 "--rotate",
128 "--ca-cert=" + tmpFile,
129 },
130 errorMsg: "the --ca-cert flag requires that a --ca-key flag and/or --external-ca flag be provided as well",
131 },
132 }
133
134 for _, testCase := range errorTestCases {
135 cmd := newCACommand(
136 test.NewFakeCli(&fakeClient{
137 swarmInspectFunc: func() (client.SwarmInspectResult, error) {

Callers

nothing calls this directly

Calls 5

writeFileFunction · 0.85
newCACommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…