Skip to content

Commit

Permalink
e2e: add test cases for a user without password
Browse files Browse the repository at this point in the history
  • Loading branch information
mitake committed Jun 19, 2018
1 parent ebb1385 commit 3709a11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/e2e/ctl_v3_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func TestCtlV3AuthCertCNAndUsername(t *testing.T) {
testCtl(t, authTestCertCNAndUsername, withCfg(configClientTLSCertAuth))
}
func TestCtlV3AuthJWTExpire(t *testing.T) { testCtl(t, authTestJWTExpire, withCfg(configJWT)) }
func TestCtlV3AuthCertCNAndUsernameNoPassword(t *testing.T) {
testCtl(t, authTestCertCNAndUsernameNoPassword, withCfg(configClientTLSCertAuth))
}

func authEnableTest(cx ctlCtx) {
if err := authEnable(cx); err != nil {
Expand Down Expand Up @@ -1030,16 +1033,22 @@ func authTestEndpointHealth(cx ctlCtx) {
}
}

func authTestCertCNAndUsername(cx ctlCtx) {
func certCNAndUsername(cx ctlCtx, noPassword bool) {
if err := authEnable(cx); err != nil {
cx.t.Fatal(err)
}

cx.user, cx.pass = "root", "root"
authSetupTestUser(cx)

if err := ctlV3User(cx, []string{"add", "example.com", "--interactive=false"}, "User example.com created", []string{""}); err != nil {
cx.t.Fatal(err)
if noPassword {
if err := ctlV3User(cx, []string{"add", "example.com", "--no-password"}, "User example.com created", []string{""}); err != nil {
cx.t.Fatal(err)
}
} else {
if err := ctlV3User(cx, []string{"add", "example.com", "--interactive=false"}, "User example.com created", []string{""}); err != nil {
cx.t.Fatal(err)
}
}
if err := spawnWithExpect(append(cx.PrefixArgs(), "role", "add", "test-role-cn"), "Role test-role-cn created"); err != nil {
cx.t.Fatal(err)
Expand Down Expand Up @@ -1082,6 +1091,14 @@ func authTestCertCNAndUsername(cx ctlCtx) {
}
}

func authTestCertCNAndUsername(cx ctlCtx) {
certCNAndUsername(cx, false)
}

func authTestCertCNAndUsernameNoPassword(cx ctlCtx) {
certCNAndUsername(cx, true)
}

func authTestJWTExpire(cx ctlCtx) {
if err := authEnable(cx); err != nil {
cx.t.Fatal(err)
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/ctl_v3_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func userAddTest(cx ctlCtx) {
expectedStr: "user name already exists",
stdIn: []string{"password"},
},
// Adds a user without password.
{
args: []string{"add", "userwopasswd", "--no-password"},
expectedStr: "User userwopasswd created",
stdIn: []string{},
},
}

for i, cmd := range cmdSet {
Expand Down

0 comments on commit 3709a11

Please sign in to comment.