Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCAI-mlv committed Dec 9, 2024
1 parent 3e3a00f commit 4808d36
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion src/test/java/com/michelin/ns4kafka/service/AclServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,14 @@ void shouldFindAllAclForNamespace() {
Namespace ns = Namespace.builder()
.metadata(Metadata.builder()
.name("namespace1")
.cluster("local")
.build())
.build();

AccessControlEntry ace1 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.grantedTo("namespace1")
Expand All @@ -811,6 +813,7 @@ void shouldFindAllAclForNamespace() {
AccessControlEntry ace2 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.grantedTo("namespace2")
Expand All @@ -820,6 +823,7 @@ void shouldFindAllAclForNamespace() {
AccessControlEntry ace3 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.namespace("namespace2")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.grantedTo("namespace2")
Expand Down Expand Up @@ -1039,13 +1043,15 @@ void shouldFindAclGrantedByNamespaceByWildcardName() {
Namespace ns = Namespace.builder()
.metadata(Metadata.builder()
.name("namespace1")
.cluster("local")
.build())
.build();

AccessControlEntry acl1 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.name("ns1-acl-topic")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1057,6 +1063,7 @@ void shouldFindAclGrantedByNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns1-read-ns2")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1068,6 +1075,7 @@ void shouldFindAclGrantedByNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns1-connect-write-to-ns2")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.CONNECT)
Expand All @@ -1079,6 +1087,7 @@ void shouldFindAclGrantedByNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns2-acl-topic")
.namespace("namespace2")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1090,6 +1099,7 @@ void shouldFindAclGrantedByNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns3-read-topic-all")
.namespace("namespace3")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1110,13 +1120,15 @@ void shouldFindAclGrantedByNamespaceToOthersByWildcardName() {
Namespace ns = Namespace.builder()
.metadata(Metadata.builder()
.name("namespace1")
.cluster("local")
.build())
.build();

AccessControlEntry acl1 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.name("ns1-acl-topic")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1128,6 +1140,7 @@ void shouldFindAclGrantedByNamespaceToOthersByWildcardName() {
.metadata(Metadata.builder()
.name("ns1-read-ns2")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1139,6 +1152,7 @@ void shouldFindAclGrantedByNamespaceToOthersByWildcardName() {
.metadata(Metadata.builder()
.name("ns1-connect-write-to-ns2")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.CONNECT)
Expand All @@ -1150,6 +1164,7 @@ void shouldFindAclGrantedByNamespaceToOthersByWildcardName() {
.metadata(Metadata.builder()
.name("ns2-acl-topic")
.namespace("namespace2")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1161,6 +1176,7 @@ void shouldFindAclGrantedByNamespaceToOthersByWildcardName() {
.metadata(Metadata.builder()
.name("ns3-read-topic-all")
.namespace("namespace3")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1182,6 +1198,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns1-acl-topic")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1193,6 +1210,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("acl-ns2-read-to-ns1")
.namespace("namespace2")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1204,6 +1222,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns1-acl-connect")
.namespace("namespace1")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.CONNECT)
Expand All @@ -1215,6 +1234,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns2-acl-topic")
.namespace("namespace2")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1226,6 +1246,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns3-read-topic-all")
.namespace("namespace3")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
Expand All @@ -1237,6 +1258,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
.metadata(Metadata.builder()
.name("ns3-write-acl-ns1")
.namespace("namespace3")
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.GROUP)
Expand All @@ -1249,6 +1271,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
Namespace ns1 = Namespace.builder()
.metadata(Metadata.builder()
.name("namespace1")
.cluster("local")
.build())
.build();

Expand All @@ -1261,6 +1284,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
Namespace ns2 = Namespace.builder()
.metadata(Metadata.builder()
.name("namespace2")
.cluster("local")
.build())
.build();

Expand All @@ -1270,6 +1294,7 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
Namespace ns3 = Namespace.builder()
.metadata(Metadata.builder()
.name("namespace3")
.cluster("local")
.build())
.build();

Expand All @@ -1280,43 +1305,65 @@ void shouldFindAclRelatedToNamespaceByWildcardName() {
@Test
void shouldFindResourceWhereGivenNamespaceIsOwnerOf() {
Namespace ns = Namespace.builder()
.metadata(Metadata.builder().name("namespace1").build()).build();
.metadata(Metadata.builder()
.name("namespace1")
.cluster("local")
.build())
.build();
AccessControlEntry acl1 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
.permission(AccessControlEntry.Permission.OWNER)
.grantedTo("namespace1").build())
.build();

AccessControlEntry acl2 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
.permission(AccessControlEntry.Permission.READ)
.grantedTo("namespace1").build())
.build();

AccessControlEntry acl3 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.CONNECT)
.permission(AccessControlEntry.Permission.OWNER)
.grantedTo("namespace1").build())
.build();

AccessControlEntry acl4 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
.permission(AccessControlEntry.Permission.OWNER)
.grantedTo("namespace2").build())
.build();

AccessControlEntry acl5 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.TOPIC)
.permission(AccessControlEntry.Permission.READ)
.grantedTo("*").build())
.build();

AccessControlEntry acl6 = AccessControlEntry.builder()
.metadata(Metadata.builder()
.cluster("local")
.build())
.spec(AccessControlEntry.AccessControlEntrySpec.builder()
.resourceType(AccessControlEntry.ResourceType.GROUP)
.permission(AccessControlEntry.Permission.WRITE)
Expand Down

0 comments on commit 4808d36

Please sign in to comment.