(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…