|
| 1 | +package pika_integration |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "time" |
| 6 | + |
| 7 | + . "github.com/bsm/ginkgo/v2" |
| 8 | + . "github.com/bsm/gomega" |
| 9 | + "github.com/redis/go-redis/v9" |
| 10 | +) |
| 11 | + |
| 12 | +var _ = Describe("Acl test", func() { |
| 13 | + ctx := context.TODO() |
| 14 | + var client *redis.Client |
| 15 | + |
| 16 | + BeforeEach(func() { |
| 17 | + client = redis.NewClient(PikaOption(SINGLEADDR)) |
| 18 | + Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred()) |
| 19 | + time.Sleep(1 * time.Second) |
| 20 | + }) |
| 21 | + |
| 22 | + AfterEach(func() { |
| 23 | + Expect(client.Close()).NotTo(HaveOccurred()) |
| 24 | + }) |
| 25 | + |
| 26 | + It("should acl dryrun", func() { |
| 27 | + dryRun := client.ACLDryRun(ctx, "default", "get", "randomKey") |
| 28 | + |
| 29 | + Expect(dryRun.Err()).NotTo(HaveOccurred()) |
| 30 | + Expect(dryRun.Val()).To(Equal("OK")) |
| 31 | + }) |
| 32 | + |
| 33 | + It("should ACL LOG RESET", Label("NonRedisEnterprise"), func() { |
| 34 | + // Call ACL LOG RESET |
| 35 | + resetCmd := client.ACLLogReset(ctx) |
| 36 | + Expect(resetCmd.Err()).NotTo(HaveOccurred()) |
| 37 | + Expect(resetCmd.Val()).To(Equal("OK")) |
| 38 | + |
| 39 | + // Verify that the log is empty after the reset |
| 40 | + logEntries, err := client.ACLLog(ctx, 10).Result() |
| 41 | + Expect(err).NotTo(HaveOccurred()) |
| 42 | + Expect(len(logEntries)).To(Equal(0)) |
| 43 | + }) |
| 44 | +}) |
0 commit comments