1
0
mirror of https://github.com/redis/go-redis.git synced 2025-11-10 00:00:57 +03:00

feat(acl): add acl support and test (#3576)

* feat: add acl support and command test

* validate client name before kill it

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
This commit is contained in:
destinyoooo
2025-11-05 00:19:09 +08:00
committed by GitHub
parent 71bb3cae4f
commit e2f6700d79
3 changed files with 60 additions and 0 deletions

View File

@@ -199,6 +199,29 @@ var _ = Describe("Commands", func() {
Expect(r.Val()).To(Equal(int64(0)))
})
It("should ClientKillByFilter with kill myself", func() {
opt := redisOptions()
opt.ClientName = "killmyid"
db := redis.NewClient(opt)
Expect(db.Ping(ctx).Err()).NotTo(HaveOccurred())
defer func() {
Expect(db.Close()).NotTo(HaveOccurred())
}()
val, err := client.ClientList(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).Should(ContainSubstring("name=killmyid"))
myid := db.ClientID(ctx).Val()
killed := client.ClientKillByFilter(ctx, "ID", strconv.FormatInt(myid, 10))
Expect(killed.Err()).NotTo(HaveOccurred())
Expect(killed.Val()).To(BeNumerically("==", 1))
val, err = client.ClientList(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).ShouldNot(ContainSubstring("name=killmyid"))
})
It("should ClientKillByFilter with MAXAGE", Label("NonRedisEnterprise"), func() {
SkipBeforeRedisVersion(7.4, "doesn't work with older redis stack images")
var s []string