Commit c95fdc7d authored by Chelsea Holland Komlo's avatar Chelsea Holland Komlo
Browse files

add failure test cases

parent 2faf35c5
Showing with 44 additions and 1 deletion
+44 -1
......@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestACLBootstrapCommand_Implements(t *testing.T) {
func TestACLBootstrapCommand(t *testing.T) {
t.Parallel()
assert := assert.New(t)
......@@ -32,3 +32,46 @@ func TestACLBootstrapCommand_Implements(t *testing.T) {
out := ui.OutputWriter.String()
assert.Contains(out, "Secret ID")
}
// If a bootsrap token has already been created, attempts to create more should
// fail.
func TestACLBootstrapCommand_ExistingBootstrapToken(t *testing.T) {
t.Parallel()
assert := assert.New(t)
config := func(c *agent.Config) {
c.ACL.Enabled = true
}
srv, _, url := testServer(t, true, config)
defer srv.Shutdown()
assert.NotNil(srv.RootToken)
ui := new(cli.MockUi)
cmd := &ACLBootstrapCommand{Meta: Meta{Ui: ui, flagAddress: url}}
code := cmd.Run([]string{"-address=" + url})
assert.Equal(1, code)
out := ui.OutputWriter.String()
assert.NotContains(out, "Secret ID")
}
// Attempting to bootstrap a token on a non-ACL enabled server should fail.
func TestACLBootstrapCommand_NonACLServer(t *testing.T) {
t.Parallel()
assert := assert.New(t)
srv, _, url := testServer(t, true, nil)
defer srv.Shutdown()
ui := new(cli.MockUi)
cmd := &ACLBootstrapCommand{Meta: Meta{Ui: ui, flagAddress: url}}
code := cmd.Run([]string{"-address=" + url})
assert.Equal(1, code)
out := ui.OutputWriter.String()
assert.NotContains(out, "Secret ID")
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment