(t *testing.T)
| 206 | } |
| 207 | |
| 208 | func 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 | |
| 239 | func TestUpdateSwarmSpecCertAndExternalCA(t *testing.T) { |
| 240 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected
searching dependent graphs…