1
0
mirror of https://github.com/redis/go-redis.git synced 2025-11-14 10:22:26 +03:00

fix(acl): Update the ACLGenPass function to use the bit parameter (#3597)

This commit is contained in:
destinyoooo
2025-11-11 23:28:23 +08:00
committed by GitHub
parent 9b7f1be092
commit 0f83314750
2 changed files with 14 additions and 1 deletions

View File

@@ -70,7 +70,12 @@ func (c cmdable) ACLSetUser(ctx context.Context, username string, rules ...strin
}
func (c cmdable) ACLGenPass(ctx context.Context, bit int) *StringCmd {
cmd := NewStringCmd(ctx, "acl", "genpass")
args := make([]interface{}, 0, 3)
args = append(args, "acl", "genpass")
if bit > 0 {
args = append(args, bit)
}
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}

View File

@@ -109,6 +109,14 @@ var _ = Describe("ACL user commands", Label("NonRedisEnterprise"), func() {
Expect(password).NotTo(BeEmpty())
})
It("gen password with length", func() {
bit := 128
password, err := client.ACLGenPass(ctx, bit).Result()
Expect(err).NotTo(HaveOccurred())
Expect(password).NotTo(BeEmpty())
Expect(len(password)).To(Equal(bit / 4))
})
It("setuser and deluser", func() {
res, err := client.ACLList(ctx).Result()
Expect(err).NotTo(HaveOccurred())