mirror of
https://github.com/redis/go-redis.git
synced 2025-06-15 12:41:41 +03:00
feat: Add ACL LOG (#2536)
* feat: Add ACL LOG Signed-off-by: monkey92t <golang@88.com> --------- Signed-off-by: monkey92t <golang@88.com> Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com> Co-authored-by: ktsivkov <ktsivkov@gmail.com> Co-authored-by: Elena Kolevska <elena@kolevska.com> Co-authored-by: monkey92t <golang@88.com>
This commit is contained in:
committed by
GitHub
parent
fcb3506e79
commit
31ba855dde
@ -1985,6 +1985,55 @@ var _ = Describe("Commands", func() {
|
||||
|
||||
Expect(args).To(Equal(expectedArgs))
|
||||
})
|
||||
|
||||
It("should ACL LOG", func() {
|
||||
|
||||
err := client.Do(ctx, "acl", "setuser", "test", ">test", "on", "allkeys", "+get").Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
clientAcl := redis.NewClient(redisOptions())
|
||||
clientAcl.Options().Username = "test"
|
||||
clientAcl.Options().Password = "test"
|
||||
clientAcl.Options().DB = 0
|
||||
_ = clientAcl.Set(ctx, "mystring", "foo", 0).Err()
|
||||
_ = clientAcl.HSet(ctx, "myhash", "foo", "bar").Err()
|
||||
_ = clientAcl.SAdd(ctx, "myset", "foo", "bar").Err()
|
||||
|
||||
logEntries, err := client.ACLLog(ctx, 10).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(logEntries)).To(Equal(3))
|
||||
|
||||
for _, entry := range logEntries {
|
||||
Expect(entry.Count).To(BeNumerically("==", 1))
|
||||
Expect(entry.Reason).To(Equal("command"))
|
||||
Expect(entry.Context).To(Equal("toplevel"))
|
||||
Expect(entry.Object).NotTo(BeEmpty())
|
||||
Expect(entry.Username).To(Equal("test"))
|
||||
Expect(entry.AgeSeconds).To(BeNumerically(">=", 0))
|
||||
Expect(entry.ClientInfo).NotTo(BeNil())
|
||||
Expect(entry.EntryID).To(BeNumerically(">=", 0))
|
||||
Expect(entry.TimestampCreated).To(BeNumerically(">=", 0))
|
||||
Expect(entry.TimestampLastUpdated).To(BeNumerically(">=", 0))
|
||||
}
|
||||
|
||||
limitedLogEntries, err := client.ACLLog(ctx, 2).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(limitedLogEntries)).To(Equal(2))
|
||||
|
||||
})
|
||||
|
||||
It("should ACL LOG RESET", func() {
|
||||
// Call ACL LOG RESET
|
||||
resetCmd := client.ACLLogReset(ctx)
|
||||
Expect(resetCmd.Err()).NotTo(HaveOccurred())
|
||||
Expect(resetCmd.Val()).To(Equal("OK"))
|
||||
|
||||
// Verify that the log is empty after the reset
|
||||
logEntries, err := client.ACLLog(ctx, 10).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(logEntries)).To(Equal(0))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Describe("hashes", func() {
|
||||
|
Reference in New Issue
Block a user