Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into issues/477
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerdv committed Aug 2, 2024
2 parents 1c1559e + 654978b commit 48aaa53
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 49 deletions.
67 changes: 33 additions & 34 deletions api/src/test/java/io/kafbat/ui/KafkaConsumerGroupTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.List;
import java.util.Properties;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
Expand All @@ -32,7 +31,6 @@ public class KafkaConsumerGroupTests extends AbstractIntegrationTest {
@Test
void shouldNotFoundWhenNoSuchConsumerGroupId() {
String groupId = "groupA";
String expError = "The group id does not exist";
webTestClient
.delete()
.uri("/api/clusters/{clusterName}/consumer-groups/{groupId}", LOCAL, groupId)
Expand All @@ -47,12 +45,13 @@ void shouldOkWhenConsumerGroupIsNotActive() {

//Create a consumer and subscribe to the topic
String groupId = UUID.randomUUID().toString();
val consumer = createTestConsumerWithGroupId(groupId);
consumer.subscribe(List.of(topicName));
consumer.poll(Duration.ofMillis(100));
try (val consumer = createTestConsumerWithGroupId(groupId)) {
consumer.subscribe(List.of(topicName));
consumer.poll(Duration.ofMillis(100));

//Unsubscribe from all topics to be able to delete this consumer
consumer.unsubscribe();
//Unsubscribe from all topics to be able to delete this consumer
consumer.unsubscribe();
}

//Delete the consumer when it's INACTIVE and check
webTestClient
Expand All @@ -69,24 +68,24 @@ void shouldBeBadRequestWhenConsumerGroupIsActive() {

//Create a consumer and subscribe to the topic
String groupId = UUID.randomUUID().toString();
val consumer = createTestConsumerWithGroupId(groupId);
consumer.subscribe(List.of(topicName));
consumer.poll(Duration.ofMillis(100));
try (val consumer = createTestConsumerWithGroupId(groupId)) {
consumer.subscribe(List.of(topicName));
consumer.poll(Duration.ofMillis(100));

//Try to delete the consumer when it's ACTIVE
String expError = "The group is not empty";
webTestClient
.delete()
.uri("/api/clusters/{clusterName}/consumer-groups/{groupId}", LOCAL, groupId)
.exchange()
.expectStatus()
.isBadRequest();
//Try to delete the consumer when it's ACTIVE
webTestClient
.delete()
.uri("/api/clusters/{clusterName}/consumer-groups/{groupId}", LOCAL, groupId)
.exchange()
.expectStatus()
.isBadRequest();
}
}

@Test
void shouldReturnConsumerGroupsWithPagination() throws Exception {
try (var groups1 = startConsumerGroups(3, "cgPageTest1");
var groups2 = startConsumerGroups(2, "cgPageTest2")) {
try (var ignored = startConsumerGroups(3, "cgPageTest1");
var ignored1 = startConsumerGroups(2, "cgPageTest2")) {
webTestClient
.get()
.uri("/api/clusters/{clusterName}/consumer-groups/paged?perPage=3&search=cgPageTest", LOCAL)
Expand Down Expand Up @@ -114,19 +113,19 @@ void shouldReturnConsumerGroupsWithPagination() throws Exception {
});

webTestClient
.get()
.uri("/api/clusters/{clusterName}/consumer-groups/paged?perPage=10&&search"
+ "=cgPageTest&orderBy=NAME&sortOrder=DESC", LOCAL)
.exchange()
.expectStatus()
.isOk()
.expectBody(ConsumerGroupsPageResponseDTO.class)
.value(page -> {
assertThat(page.getPageCount()).isEqualTo(1);
assertThat(page.getConsumerGroups().size()).isEqualTo(5);
assertThat(page.getConsumerGroups())
.isSortedAccordingTo(Comparator.comparing(ConsumerGroupDTO::getGroupId).reversed());
});
.get()
.uri("/api/clusters/{clusterName}/consumer-groups/paged?perPage=10&&search"
+ "=cgPageTest&orderBy=NAME&sortOrder=DESC", LOCAL)
.exchange()
.expectStatus()
.isOk()
.expectBody(ConsumerGroupsPageResponseDTO.class)
.value(page -> {
assertThat(page.getPageCount()).isEqualTo(1);
assertThat(page.getConsumerGroups().size()).isEqualTo(5);
assertThat(page.getConsumerGroups())
.isSortedAccordingTo(Comparator.comparing(ConsumerGroupDTO::getGroupId).reversed());
});

webTestClient
.get()
Expand Down Expand Up @@ -156,7 +155,7 @@ private Closeable startConsumerGroups(int count, String consumerGroupPrefix) {
return consumer;
})
.limit(count)
.collect(Collectors.toList());
.toList();
return () -> {
consumers.forEach(KafkaConsumer::close);
deleteTopic(topicName);
Expand Down
29 changes: 18 additions & 11 deletions api/src/test/java/io/kafbat/ui/service/acl/AclCsvTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.kafbat.ui.exception.ValidationException;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import org.apache.kafka.common.acl.AccessControlEntry;
import org.apache.kafka.common.acl.AclBinding;
import org.apache.kafka.common.acl.AclOperation;
Expand All @@ -15,6 +16,8 @@
import org.apache.kafka.common.resource.ResourceType;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;

class AclCsvTest {
Expand All @@ -29,22 +32,26 @@ class AclCsvTest {
);

@ParameterizedTest
@ValueSource(strings = {
"Principal,ResourceType, PatternType, ResourceName,Operation,PermissionType,Host\n"
+ "User:test1,TOPIC,LITERAL,*,READ,ALLOW,*\n"
+ "User:test2,GROUP,PREFIXED,group1,DESCRIBE,DENY,localhost",

//without header
"User:test1,TOPIC,LITERAL,*,READ,ALLOW,*\n"
+ "\n"
+ "User:test2,GROUP,PREFIXED,group1,DESCRIBE,DENY,localhost"
+ "\n"
})
@MethodSource
void parsesValidInputCsv(String csvString) {
Collection<AclBinding> parsed = AclCsv.parseCsv(csvString);
assertThat(parsed).containsExactlyInAnyOrderElementsOf(TEST_BINDINGS);
}

private static Stream<Arguments> parsesValidInputCsv() {
return Stream.of(
Arguments.of(
"Principal,ResourceType, PatternType, ResourceName,Operation,PermissionType,Host" + System.lineSeparator()
+ "User:test1,TOPIC,LITERAL,*,READ,ALLOW,*" + System.lineSeparator()
+ "User:test2,GROUP,PREFIXED,group1,DESCRIBE,DENY,localhost"),
Arguments.of(
//without header
"User:test1,TOPIC,LITERAL,*,READ,ALLOW,*" + System.lineSeparator()
+ System.lineSeparator()
+ "User:test2,GROUP,PREFIXED,group1,DESCRIBE,DENY,localhost"
+ System.lineSeparator()));
}

@ParameterizedTest
@ValueSource(strings = {
// columns > 7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void testSyncAclWithAclCsv() {

aclsService.syncAclWithAclCsv(
CLUSTER,
"Principal,ResourceType, PatternType, ResourceName,Operation,PermissionType,Host\n"
+ "User:test1,TOPIC,LITERAL,*,READ,ALLOW,*\n"
"Principal,ResourceType, PatternType, ResourceName,Operation,PermissionType,Host" + System.lineSeparator()
+ "User:test1,TOPIC,LITERAL,*,READ,ALLOW,*" + System.lineSeparator()
+ "User:test3,GROUP,PREFIXED,groupNew,DESCRIBE,DENY,localhost"
).block();

Expand Down
1 change: 1 addition & 0 deletions contract/src/main/resources/swagger/kafbat-ui-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,7 @@ components:
- UNASSIGNED
- TASK_FAILED
- RESTARTING
- STOPPED

ConnectorAction:
type: string
Expand Down
1 change: 1 addition & 0 deletions contract/src/main/resources/swagger/kafka-connect-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ components:
- PAUSED
- UNASSIGNED
- RESTARTING
- STOPPED
worker_id:
type: string
trace:
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export const theme = {
menu: {
primary: {
backgroundColor: {
normal: hexToRgba(Colors.brand[95], 0),
normal: Colors.brand[0],
hover: hexToRgba(Colors.brand[95], 0.03),
active: hexToRgba(Colors.brand[95], 0.05),
},
Expand Down Expand Up @@ -985,7 +985,7 @@ export const darkTheme: ThemeType = {
menu: {
primary: {
backgroundColor: {
normal: hexToRgba(Colors.brand[0], 0),
normal: Colors.brand[90],
hover: hexToRgba(Colors.brand[0], 0.05),
active: hexToRgba(Colors.brand[0], 0.1),
},
Expand Down

0 comments on commit 48aaa53

Please sign in to comment.