mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add tests to ensure we can add an external CA to the cluster without
error. Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
e34bee387e
commit
9b96b2d276
2 changed files with 29 additions and 1 deletions
|
@ -145,6 +145,25 @@ func (s *DockerSwarmSuite) TestAPISwarmJoinToken(c *check.C) {
|
|||
c.Assert(info.LocalNodeState, checker.Equals, swarm.LocalNodeStateInactive)
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestUpdateSwarmAddExternalCA(c *check.C) {
|
||||
// TODO: when root rotation is in, convert to a series of root rotation tests instead.
|
||||
// currently just makes sure that we don't have to provide a CA certificate when
|
||||
// providing an external CA
|
||||
d1 := s.AddDaemon(c, false, false)
|
||||
c.Assert(d1.Init(swarm.InitRequest{}), checker.IsNil)
|
||||
d1.UpdateSwarm(c, func(s *swarm.Spec) {
|
||||
s.CAConfig.ExternalCAs = []*swarm.ExternalCA{
|
||||
{
|
||||
Protocol: swarm.ExternalCAProtocolCFSSL,
|
||||
URL: "https://thishasnoca.org",
|
||||
},
|
||||
}
|
||||
})
|
||||
info, err := d1.SwarmInfo()
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(info.Cluster.Spec.CAConfig.ExternalCAs, checker.HasLen, 1)
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestAPISwarmCAHash(c *check.C) {
|
||||
d1 := s.AddDaemon(c, true, true)
|
||||
d2 := s.AddDaemon(c, false, false)
|
||||
|
|
|
@ -50,6 +50,13 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) {
|
|||
c.Assert(out, checker.Contains, "minimum certificate expiry time")
|
||||
spec = getSpec()
|
||||
c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
|
||||
|
||||
// passing an external CA (this is without starting a root rotation) does not fail
|
||||
out, err = d.Cmd("swarm", "update", "--external-ca", "protocol=cfssl,url=https://something.org")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
||||
|
||||
spec = getSpec()
|
||||
c.Assert(spec.CAConfig.ExternalCAs, checker.HasLen, 1)
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
||||
|
@ -60,12 +67,14 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
|||
return sw.Spec
|
||||
}
|
||||
|
||||
cli.Docker(cli.Args("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s"),
|
||||
cli.Docker(cli.Args("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s",
|
||||
"--external-ca", "protocol=cfssl,url=https://something.org"),
|
||||
cli.Daemon(d.Daemon)).Assert(c, icmd.Success)
|
||||
|
||||
spec := getSpec()
|
||||
c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
|
||||
c.Assert(spec.Dispatcher.HeartbeatPeriod, checker.Equals, 11*time.Second)
|
||||
c.Assert(spec.CAConfig.ExternalCAs, checker.HasLen, 1)
|
||||
|
||||
c.Assert(d.Leave(true), checker.IsNil)
|
||||
time.Sleep(500 * time.Millisecond) // https://github.com/docker/swarmkit/issues/1421
|
||||
|
|
Loading…
Add table
Reference in a new issue