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

Function TestUpdateSwarmSpecCertAndKeyAndExternalCA

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

Source from the content-addressed store, hash-verified

271}
272
273func TestUpdateSwarmSpecCertAndKeyAndExternalCA(t *testing.T) {
274 tmpDir := t.TempDir()
275 certFile, err := writeFile(tmpDir, cert)
276 assert.NilError(t, err)
277
278 keyFile, err := writeFile(tmpDir, key)
279 assert.NilError(t, err)
280
281 s := &swarmUpdateRecorder{}
282 cli := test.NewFakeCli(&fakeClient{
283 swarmInspectFunc: swarmInspectFuncWithFullCAConfig,
284 swarmUpdateFunc: s.swarmUpdate,
285 })
286 cmd := newCACommand(cli)
287 cmd.SetArgs([]string{
288 "--rotate",
289 "--detach",
290 "--ca-cert=" + certFile,
291 "--ca-key=" + keyFile,
292 "--external-ca=protocol=cfssl,url=https://some.external.ca.example.com",
293 })
294 cmd.SetOut(cli.OutBuffer())
295 assert.NilError(t, cmd.Execute())
296
297 expected := swarmSpecWithFullCAConfig()
298 expected.CAConfig.SigningCACert = cert
299 expected.CAConfig.SigningCAKey = key
300 expected.CAConfig.ExternalCAs = []*swarm.ExternalCA{
301 {
302 Protocol: swarm.ExternalCAProtocolCFSSL,
303 URL: "https://some.external.ca.example.com",
304 CACert: cert,
305 Options: make(map[string]string),
306 },
307 }
308 assert.Check(t, is.DeepEqual(*expected, s.spec))
309}

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…