From 79f9ec5dfed05d76295926550c824da48c4f94dc Mon Sep 17 00:00:00 2001 From: Tommi Vainikainen Date: Fri, 15 Nov 2024 13:40:02 +0200 Subject: [PATCH] Fix typo in operations parsing --- .../kafka/auth/json/AclOperationType.java | 2 +- .../auth/json/reader/AclJsonReaderTest.java | 8 ++ src/test/resources/acl_all_operations.json | 128 ++++++++++++++++++ 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/acl_all_operations.json diff --git a/src/main/java/io/aiven/kafka/auth/json/AclOperationType.java b/src/main/java/io/aiven/kafka/auth/json/AclOperationType.java index 346c967..e9e90f2 100644 --- a/src/main/java/io/aiven/kafka/auth/json/AclOperationType.java +++ b/src/main/java/io/aiven/kafka/auth/json/AclOperationType.java @@ -21,7 +21,7 @@ public enum AclOperationType { All(org.apache.kafka.common.acl.AclOperation.ALL), Read(org.apache.kafka.common.acl.AclOperation.READ), Write(org.apache.kafka.common.acl.AclOperation.WRITE), - Create1(org.apache.kafka.common.acl.AclOperation.CREATE), + Create(org.apache.kafka.common.acl.AclOperation.CREATE), Delete(org.apache.kafka.common.acl.AclOperation.DELETE), Alter(org.apache.kafka.common.acl.AclOperation.ALTER), Describe(org.apache.kafka.common.acl.AclOperation.DESCRIBE), diff --git a/src/test/java/io/aiven/kafka/auth/json/reader/AclJsonReaderTest.java b/src/test/java/io/aiven/kafka/auth/json/reader/AclJsonReaderTest.java index 4e15f81..a56ea42 100644 --- a/src/test/java/io/aiven/kafka/auth/json/reader/AclJsonReaderTest.java +++ b/src/test/java/io/aiven/kafka/auth/json/reader/AclJsonReaderTest.java @@ -122,4 +122,12 @@ public final void parseWrongOperations() { final var jsonReader = new AclJsonReader(path); assertThrows(JsonParseException.class, jsonReader::read); } + + @Test + public final void parseAllOperations() { + final var path = new File(this.getClass().getResource("/acl_all_operations.json").getPath()).toPath(); + final var jsonReader = new AclJsonReader(path); + final var acls = jsonReader.read(); + assertThat(acls).isNotEmpty(); + } } diff --git a/src/test/resources/acl_all_operations.json b/src/test/resources/acl_all_operations.json new file mode 100644 index 0000000..f757dac --- /dev/null +++ b/src/test/resources/acl_all_operations.json @@ -0,0 +1,128 @@ +[ + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Alter"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Alter"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["AlterConfigs"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["AlterConfigs"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["ClusterAction"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Create"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Create"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["CreateTokens"], + "resource": "^User:user2$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Delete"], + "resource": "^Group:group1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Delete"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Describe"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Describe"], + "resource": "^DelegationToken:foobar$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Describe", "Read"], + "resource": "^Group:group1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Describe"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Describe", "Write"], + "resource": "^TransactionalId:foobar$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["DescribeConfigs"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["DescribeConfigs"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["DescribeConfigs"], + "resource": "^User:user2$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["IdempotentWrite"], + "resource": "^Cluster:kafka-cluster$" + }, + { + "principal_type": "User", + "principal": "^user1$", + "operations": ["Read", "Write"], + "resource": "^Topic:topic1$" + }, + { + "principal_type": "User", + "principal": "^all$", + "operations": ["All"], + "resource": "^Topic:topic1$" + } +] \ No newline at end of file