@@ -9,68 +9,69 @@ import (
99 . "github.com/bsm/gomega"
1010)
1111
12- var TestUserName string = "goredis"
13- var _ = Describe ("ACL" , func () {
14- var client * redis.Client
15- var ctx context.Context
16-
17- BeforeEach (func () {
18- ctx = context .Background ()
19- opt := redisOptions ()
20- client = redis .NewClient (opt )
21- })
22-
23- It ("should ACL LOG" , Label ("NonRedisEnterprise" ), func () {
24- Expect (client .ACLLogReset (ctx ).Err ()).NotTo (HaveOccurred ())
25- err := client .Do (ctx , "acl" , "setuser" , "test" , ">test" , "on" , "allkeys" , "+get" ).Err ()
26- Expect (err ).NotTo (HaveOccurred ())
12+ var (
13+ TestUserName string = "goredis"
14+ _ = Describe ("ACL" , func () {
15+ var client * redis.Client
16+ var ctx context.Context
17+
18+ BeforeEach (func () {
19+ ctx = context .Background ()
20+ opt := redisOptions ()
21+ client = redis .NewClient (opt )
22+ })
23+
24+ It ("should ACL LOG" , Label ("NonRedisEnterprise" ), func () {
25+ Expect (client .ACLLogReset (ctx ).Err ()).NotTo (HaveOccurred ())
26+ err := client .Do (ctx , "acl" , "setuser" , "test" , ">test" , "on" , "allkeys" , "+get" ).Err ()
27+ Expect (err ).NotTo (HaveOccurred ())
2728
28- clientAcl := redis .NewClient (redisOptions ())
29- clientAcl .Options ().Username = "test"
30- clientAcl .Options ().Password = "test"
31- clientAcl .Options ().DB = 0
32- _ = clientAcl .Set (ctx , "mystring" , "foo" , 0 ).Err ()
33- _ = clientAcl .HSet (ctx , "myhash" , "foo" , "bar" ).Err ()
34- _ = clientAcl .SAdd (ctx , "myset" , "foo" , "bar" ).Err ()
29+ clientAcl := redis .NewClient (redisOptions ())
30+ clientAcl .Options ().Username = "test"
31+ clientAcl .Options ().Password = "test"
32+ clientAcl .Options ().DB = 0
33+ _ = clientAcl .Set (ctx , "mystring" , "foo" , 0 ).Err ()
34+ _ = clientAcl .HSet (ctx , "myhash" , "foo" , "bar" ).Err ()
35+ _ = clientAcl .SAdd (ctx , "myset" , "foo" , "bar" ).Err ()
3536
36- logEntries , err := client .ACLLog (ctx , 10 ).Result ()
37- Expect (err ).NotTo (HaveOccurred ())
38- Expect (len (logEntries )).To (Equal (4 ))
39-
40- for _ , entry := range logEntries {
41- Expect (entry .Reason ).To (Equal ("command" ))
42- Expect (entry .Context ).To (Equal ("toplevel" ))
43- Expect (entry .Object ).NotTo (BeEmpty ())
44- Expect (entry .Username ).To (Equal ("test" ))
45- Expect (entry .AgeSeconds ).To (BeNumerically (">=" , 0 ))
46- Expect (entry .ClientInfo ).NotTo (BeNil ())
47- Expect (entry .EntryID ).To (BeNumerically (">=" , 0 ))
48- Expect (entry .TimestampCreated ).To (BeNumerically (">=" , 0 ))
49- Expect (entry .TimestampLastUpdated ).To (BeNumerically (">=" , 0 ))
50- }
51-
52- limitedLogEntries , err := client .ACLLog (ctx , 2 ).Result ()
53- Expect (err ).NotTo (HaveOccurred ())
54- Expect (len (limitedLogEntries )).To (Equal (2 ))
37+ logEntries , err := client .ACLLog (ctx , 10 ).Result ()
38+ Expect (err ).NotTo (HaveOccurred ())
39+ Expect (len (logEntries )).To (Equal (4 ))
40+
41+ for _ , entry := range logEntries {
42+ Expect (entry .Reason ).To (Equal ("command" ))
43+ Expect (entry .Context ).To (Equal ("toplevel" ))
44+ Expect (entry .Object ).NotTo (BeEmpty ())
45+ Expect (entry .Username ).To (Equal ("test" ))
46+ Expect (entry .AgeSeconds ).To (BeNumerically (">=" , 0 ))
47+ Expect (entry .ClientInfo ).NotTo (BeNil ())
48+ Expect (entry .EntryID ).To (BeNumerically (">=" , 0 ))
49+ Expect (entry .TimestampCreated ).To (BeNumerically (">=" , 0 ))
50+ Expect (entry .TimestampLastUpdated ).To (BeNumerically (">=" , 0 ))
51+ }
52+
53+ limitedLogEntries , err := client .ACLLog (ctx , 2 ).Result ()
54+ Expect (err ).NotTo (HaveOccurred ())
55+ Expect (len (limitedLogEntries )).To (Equal (2 ))
5556
56- // cleanup after creating the user
57- err = client .Do (ctx , "acl" , "deluser" , "test" ).Err ()
58- Expect (err ).NotTo (HaveOccurred ())
59- })
57+ // cleanup after creating the user
58+ err = client .Do (ctx , "acl" , "deluser" , "test" ).Err ()
59+ Expect (err ).NotTo (HaveOccurred ())
60+ })
6061
61- It ("should ACL LOG RESET" , Label ("NonRedisEnterprise" ), func () {
62- // Call ACL LOG RESET
63- resetCmd := client .ACLLogReset (ctx )
64- Expect (resetCmd .Err ()).NotTo (HaveOccurred ())
65- Expect (resetCmd .Val ()).To (Equal ("OK" ))
62+ It ("should ACL LOG RESET" , Label ("NonRedisEnterprise" ), func () {
63+ // Call ACL LOG RESET
64+ resetCmd := client .ACLLogReset (ctx )
65+ Expect (resetCmd .Err ()).NotTo (HaveOccurred ())
66+ Expect (resetCmd .Val ()).To (Equal ("OK" ))
6667
67- // Verify that the log is empty after the reset
68- logEntries , err := client .ACLLog (ctx , 10 ).Result ()
69- Expect (err ).NotTo (HaveOccurred ())
70- Expect (len (logEntries )).To (Equal (0 ))
68+ // Verify that the log is empty after the reset
69+ logEntries , err := client .ACLLog (ctx , 10 ).Result ()
70+ Expect (err ).NotTo (HaveOccurred ())
71+ Expect (len (logEntries )).To (Equal (0 ))
72+ })
7173 })
72-
73- })
74+ )
7475var _ = Describe ("ACL user commands" , Label ("NonRedisEnterprise" ), func () {
7576 var client * redis.Client
7677 var ctx context.Context
0 commit comments