@@ -1985,6 +1985,55 @@ var _ = Describe("Commands", func() {
19851985
19861986 Expect (args ).To (Equal (expectedArgs ))
19871987 })
1988+
1989+ It ("should ACL LOG" , func () {
1990+
1991+ err := client .Do (ctx , "acl" , "setuser" , "test" , ">test" , "on" , "allkeys" , "+get" ).Err ()
1992+ Expect (err ).NotTo (HaveOccurred ())
1993+
1994+ clientAcl := redis .NewClient (redisOptions ())
1995+ clientAcl .Options ().Username = "test"
1996+ clientAcl .Options ().Password = "test"
1997+ clientAcl .Options ().DB = 0
1998+ _ = clientAcl .Set (ctx , "mystring" , "foo" , 0 ).Err ()
1999+ _ = clientAcl .HSet (ctx , "myhash" , "foo" , "bar" ).Err ()
2000+ _ = clientAcl .SAdd (ctx , "myset" , "foo" , "bar" ).Err ()
2001+
2002+ logEntries , err := client .ACLLog (ctx , 10 ).Result ()
2003+ Expect (err ).NotTo (HaveOccurred ())
2004+ Expect (len (logEntries )).To (Equal (3 ))
2005+
2006+ for _ , entry := range logEntries {
2007+ Expect (entry .Count ).To (BeNumerically ("==" , 1 ))
2008+ Expect (entry .Reason ).To (Equal ("command" ))
2009+ Expect (entry .Context ).To (Equal ("toplevel" ))
2010+ Expect (entry .Object ).NotTo (BeEmpty ())
2011+ Expect (entry .Username ).To (Equal ("test" ))
2012+ Expect (entry .AgeSeconds ).To (BeNumerically (">=" , 0 ))
2013+ Expect (entry .ClientInfo ).NotTo (BeNil ())
2014+ Expect (entry .EntryID ).To (BeNumerically (">=" , 0 ))
2015+ Expect (entry .TimestampCreated ).To (BeNumerically (">=" , 0 ))
2016+ Expect (entry .TimestampLastUpdated ).To (BeNumerically (">=" , 0 ))
2017+ }
2018+
2019+ limitedLogEntries , err := client .ACLLog (ctx , 2 ).Result ()
2020+ Expect (err ).NotTo (HaveOccurred ())
2021+ Expect (len (limitedLogEntries )).To (Equal (2 ))
2022+
2023+ })
2024+
2025+ It ("should ACL LOG RESET" , func () {
2026+ // Call ACL LOG RESET
2027+ resetCmd := client .ACLLogReset (ctx )
2028+ Expect (resetCmd .Err ()).NotTo (HaveOccurred ())
2029+ Expect (resetCmd .Val ()).To (Equal ("OK" ))
2030+
2031+ // Verify that the log is empty after the reset
2032+ logEntries , err := client .ACLLog (ctx , 10 ).Result ()
2033+ Expect (err ).NotTo (HaveOccurred ())
2034+ Expect (len (logEntries )).To (Equal (0 ))
2035+ })
2036+
19882037 })
19892038
19902039 Describe ("hashes" , func () {
0 commit comments