mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-12 20:20:16 +08:00
support auth
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"github.com/hdt3213/godis/config"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/connection"
|
||||
"github.com/hdt3213/godis/redis/reply/asserts"
|
||||
"testing"
|
||||
)
|
||||
@@ -16,6 +19,21 @@ func TestExec(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuth(t *testing.T) {
|
||||
passwd := utils.RandString(10)
|
||||
config.Properties.RequirePass = passwd
|
||||
defer func() {
|
||||
config.Properties.RequirePass = ""
|
||||
}()
|
||||
conn := &connection.FakeConn{}
|
||||
ret := testCluster.Exec(conn, toArgs("GET", "a"))
|
||||
asserts.AssertErrReply(t, ret, "NOAUTH Authentication required")
|
||||
ret = testCluster.Exec(conn, toArgs("AUTH", passwd))
|
||||
asserts.AssertStatusReply(t, ret, "OK")
|
||||
ret = testCluster.Exec(conn, toArgs("GET", "a"))
|
||||
asserts.AssertNotError(t, ret)
|
||||
}
|
||||
|
||||
func TestRelay(t *testing.T) {
|
||||
testCluster2 := MakeTestCluster([]string{"127.0.0.1:6379"})
|
||||
key := RandString(4)
|
||||
|
Reference in New Issue
Block a user