Skip to content

Commit

Permalink
Fix ACL SETUSER when adding specified categories #1839
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanNagar authored and mp911de committed Sep 3, 2021
1 parent edb28c9 commit 53e8272
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/AclSetuserArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public <K, V> void build(CommandArgs<K, V> args) {
}
}

if (removeCategories != null) {
if (addCategories != null) {
for (AclCategory category : addCategories) {
args.add("+@" + category.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ void aclSetuser() {
assertThat(redis.aclDeluser("foo")).isNotNull();
}

@Test
void aclSetuserWithCategories() {
assertThat(redis.aclDeluser("foo")).isNotNull();
AclSetuserArgs args = AclSetuserArgs.Builder.on().addCategory(AclCategory.CONNECTION);
assertThat(redis.aclSetuser("foo", args)).isEqualTo("OK");
assertThat(redis.aclGetuser("foo")).contains("-@all +@connection");
assertThat(redis.aclDeluser("foo")).isNotNull();
}

@Test
void aclUsers() {
assertThat(redis.aclUsers()).hasSize(1).first().isEqualTo("default");
Expand Down

0 comments on commit 53e8272

Please sign in to comment.