MCPcopy Index your code
hub / github.com/docker/cli / TestUpdateSwarmSpecCertAndKey

Function TestUpdateSwarmSpecCertAndKey

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

Source from the content-addressed store, hash-verified

206}
207
208func TestUpdateSwarmSpecCertAndKey(t *testing.T) {
209 tmpDir := t.TempDir()
210 certFile, err := writeFile(tmpDir, cert)
211 assert.NilError(t, err)
212
213 keyFile, err := writeFile(tmpDir, key)
214 assert.NilError(t, err)
215
216 s := &swarmUpdateRecorder{}
217 cli := test.NewFakeCli(&fakeClient{
218 swarmInspectFunc: swarmInspectFuncWithFullCAConfig,
219 swarmUpdateFunc: s.swarmUpdate,
220 })
221 cmd := newCACommand(cli)
222 cmd.SetArgs([]string{
223 "--rotate",
224 "--detach",
225 "--ca-cert=" + certFile,
226 "--ca-key=" + keyFile,
227 "--cert-expiry=3m",
228 })
229 cmd.SetOut(cli.OutBuffer())
230 assert.NilError(t, cmd.Execute())
231
232 expected := swarmSpecWithFullCAConfig()
233 expected.CAConfig.SigningCACert = cert
234 expected.CAConfig.SigningCAKey = key
235 expected.CAConfig.NodeCertExpiry = 3 * time.Minute
236 assert.Check(t, is.DeepEqual(*expected, s.spec))
237}
238
239func TestUpdateSwarmSpecCertAndExternalCA(t *testing.T) {
240 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

OutBufferMethod · 0.95
writeFileFunction · 0.85
newCACommandFunction · 0.85
SetArgsMethod · 0.80
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…