open-nomad/command/acl_bootstrap_test.go

35 lines
721 B
Go
Raw Normal View History

2017-09-11 17:46:17 +00:00
package command
import (
"testing"
2017-10-24 17:37:03 +00:00
"github.com/hashicorp/nomad/command/agent"
2017-09-11 17:46:17 +00:00
"github.com/mitchellh/cli"
2017-10-24 17:37:03 +00:00
"github.com/stretchr/testify/assert"
2017-09-11 17:46:17 +00:00
)
func TestACLBootstrapCommand_Implements(t *testing.T) {
t.Parallel()
2017-10-24 17:37:03 +00:00
assert := assert.New(t)
// create a acl-enabled server without bootstrapping the token
config := func(c *agent.Config) {
c.ACL.Enabled = true
c.ACL.PolicyTTL = 0
}
srv, _, url := testServer(t, true, config)
defer srv.Shutdown()
assert.Nil(srv.RootToken)
ui := new(cli.MockUi)
cmd := &ACLBootstrapCommand{Meta: Meta{Ui: ui, flagAddress: url}}
code := cmd.Run([]string{"-address=" + url})
assert.Equal(0, code)
out := ui.OutputWriter.String()
assert.Contains(out, "Secret ID")
2017-09-11 17:46:17 +00:00
}