1
0
mirror of https://github.com/redis/go-redis.git synced 2025-12-03 18:31:14 +03:00

verify pass auth on conn creation

This commit is contained in:
Nedyalko Dyakov
2025-10-29 16:06:35 +02:00
parent dccf01f396
commit 7201275eb5

View File

@@ -247,9 +247,19 @@ var _ = Describe("Client", func() {
It("should initialize idle connections created by MinIdleConns", func() {
opt := redisOptions()
passwrd := "asdf"
db0 := redis.NewClient(opt)
// set password
err := db0.Do(ctx, "CONFIG", "SET", "requirepass", passwrd).Err()
Expect(err).NotTo(HaveOccurred())
defer func() {
err = db0.Do(ctx, "CONFIG", "SET", "requirepass", "").Err()
Expect(err).NotTo(HaveOccurred())
Expect(db0.Close()).NotTo(HaveOccurred())
}()
opt.MinIdleConns = 5
opt.Password = "asdf" // Set password to require AUTH
opt.DB = 1 // Set DB to require SELECT
opt.Password = passwrd
opt.DB = 1 // Set DB to require SELECT
db := redis.NewClient(opt)
defer func() {