mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e: add test cases for a user without password
This commit is contained in:
parent
5a67dd788d
commit
8257dfdb51
@ -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 {
|
||||
@ -1041,7 +1044,7 @@ func authTestEndpointHealth(cx ctlCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
func authTestCertCNAndUsername(cx ctlCtx) {
|
||||
func certCNAndUsername(cx ctlCtx, noPassword bool) {
|
||||
if err := authEnable(cx); err != nil {
|
||||
cx.t.Fatal(err)
|
||||
}
|
||||
@ -1049,8 +1052,14 @@ func authTestCertCNAndUsername(cx ctlCtx) {
|
||||
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)
|
||||
@ -1093,6 +1102,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)
|
||||
|
@ -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 {
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"go.etcd.io/coreos/etcd/auth/authpb"
|
||||
"go.etcd.io/etcd/auth/authpb"
|
||||
epb "go.etcd.io/etcd/etcdserver/api/v3election/v3electionpb"
|
||||
"go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
|
||||
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
|
||||
|
Loading…
x
Reference in New Issue
Block a user