Skip to content

Add support for acl dryrun command #2502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ type Cmdable interface {
GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd
GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd
GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd

ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
}

type StatefulCmdable interface {
Expand Down Expand Up @@ -3757,3 +3759,12 @@ func (c cmdable) GeoPos(ctx context.Context, key string, members ...string) *Geo
_ = c(ctx, cmd)
return cmd
}

func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd {
args := make([]interface{}, 0, 3+len(command))
args = append(args, "acl", "dryrun", username)
args = append(args, command...)
cmd := NewStringCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
6 changes: 6 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,12 @@ var _ = Describe("Commands", func() {
replace := client.Copy(ctx, "newKey", "key", redisOptions().DB, true)
Expect(replace.Val()).To(Equal(int64(1)))
})

It("should acl dryryn", func() {
dryRun := client.ACLDryRun(ctx, "default", "get", "randomKey")
Expect(dryRun.Err()).NotTo(HaveOccurred())
Expect(dryRun.Val()).To(Equal("OK"))
})
})

Describe("hashes", func() {
Expand Down