Skip to content

Commit 0f83314

Browse files
authored
fix(acl): Update the ACLGenPass function to use the bit parameter (#3597)
1 parent 9b7f1be commit 0f83314

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

acl_commands.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ func (c cmdable) ACLSetUser(ctx context.Context, username string, rules ...strin
7070
}
7171

7272
func (c cmdable) ACLGenPass(ctx context.Context, bit int) *StringCmd {
73-
cmd := NewStringCmd(ctx, "acl", "genpass")
73+
args := make([]interface{}, 0, 3)
74+
args = append(args, "acl", "genpass")
75+
if bit > 0 {
76+
args = append(args, bit)
77+
}
78+
cmd := NewStringCmd(ctx, args...)
7479
_ = c(ctx, cmd)
7580
return cmd
7681
}

acl_commands_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ var _ = Describe("ACL user commands", Label("NonRedisEnterprise"), func() {
109109
Expect(password).NotTo(BeEmpty())
110110
})
111111

112+
It("gen password with length", func() {
113+
bit := 128
114+
password, err := client.ACLGenPass(ctx, bit).Result()
115+
Expect(err).NotTo(HaveOccurred())
116+
Expect(password).NotTo(BeEmpty())
117+
Expect(len(password)).To(Equal(bit / 4))
118+
})
119+
112120
It("setuser and deluser", func() {
113121
res, err := client.ACLList(ctx).Result()
114122
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)