2016-11-22 16:18:28 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
2016-12-30 17:23:00 +00:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2016-11-22 16:18:28 +00:00
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSwarmSuite) TestSecretInspect(c *check.C) {
|
|
|
|
d := s.AddDaemon(c, true, true)
|
|
|
|
|
|
|
|
testName := "test_secret"
|
2016-12-09 09:17:53 +00:00
|
|
|
id := d.CreateSecret(c, swarm.SecretSpec{
|
2017-03-20 08:27:51 +00:00
|
|
|
Annotations: swarm.Annotations{
|
2016-11-22 16:18:28 +00:00
|
|
|
Name: testName,
|
|
|
|
},
|
2017-03-20 08:27:51 +00:00
|
|
|
Data: []byte("TESTINGDATA"),
|
2016-11-22 16:18:28 +00:00
|
|
|
})
|
|
|
|
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
|
|
|
|
|
2016-12-09 09:17:53 +00:00
|
|
|
secret := d.GetSecret(c, id)
|
2016-11-22 16:18:28 +00:00
|
|
|
c.Assert(secret.Spec.Name, checker.Equals, testName)
|
|
|
|
|
|
|
|
out, err := d.Cmd("secret", "inspect", testName)
|
|
|
|
c.Assert(err, checker.IsNil, check.Commentf(out))
|
|
|
|
|
|
|
|
var secrets []swarm.Secret
|
|
|
|
c.Assert(json.Unmarshal([]byte(out), &secrets), checker.IsNil)
|
|
|
|
c.Assert(secrets, checker.HasLen, 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSwarmSuite) TestSecretInspectMultiple(c *check.C) {
|
|
|
|
d := s.AddDaemon(c, true, true)
|
|
|
|
|
|
|
|
testNames := []string{
|
|
|
|
"test0",
|
|
|
|
"test1",
|
|
|
|
}
|
|
|
|
for _, n := range testNames {
|
2016-12-09 09:17:53 +00:00
|
|
|
id := d.CreateSecret(c, swarm.SecretSpec{
|
2017-03-20 08:27:51 +00:00
|
|
|
Annotations: swarm.Annotations{
|
2016-11-22 16:18:28 +00:00
|
|
|
Name: n,
|
|
|
|
},
|
2017-03-20 08:27:51 +00:00
|
|
|
Data: []byte("TESTINGDATA"),
|
2016-11-22 16:18:28 +00:00
|
|
|
})
|
|
|
|
c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
|
|
|
|
|
2016-12-09 09:17:53 +00:00
|
|
|
secret := d.GetSecret(c, id)
|
2016-11-22 16:18:28 +00:00
|
|
|
c.Assert(secret.Spec.Name, checker.Equals, n)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
args := []string{
|
|
|
|
"secret",
|
|
|
|
"inspect",
|
|
|
|
}
|
|
|
|
args = append(args, testNames...)
|
|
|
|
out, err := d.Cmd(args...)
|
|
|
|
c.Assert(err, checker.IsNil, check.Commentf(out))
|
|
|
|
|
|
|
|
var secrets []swarm.Secret
|
|
|
|
c.Assert(json.Unmarshal([]byte(out), &secrets), checker.IsNil)
|
|
|
|
c.Assert(secrets, checker.HasLen, 2)
|
|
|
|
}
|