Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private CssSelectors() {}
.withElementButton().withComponentMenu().withSubComponentItem()
.build();

public static final String BODY_EMPTY_STATE = "body > div > div.pf-v6-c-page > div.pf-v6-c-page__main-container:nth-of-type(2) > main.pf-v6-c-page__main > section.pf-v6-c-page__main-section:nth-of-type(2) > div.pf-v6-c-page__main-body > div.pf-v6-c-empty-state > div.pf-v6-c-empty-state__content > div.pf-v6-c-empty-state__body";

// Kafka credentials login page

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.github.streamshub.systemtests.auth;

import com.github.streamshub.console.support.Identifiers;
import com.github.streamshub.systemtests.AbstractST;
import com.github.streamshub.systemtests.TestCaseConfig;
import com.github.streamshub.systemtests.clients.KafkaClients;
import com.github.streamshub.systemtests.clients.KafkaClientsBuilder;
import com.github.streamshub.systemtests.constants.AuthTestConstants;
import com.github.streamshub.systemtests.constants.Constants;
import com.github.streamshub.systemtests.constants.TestTags;
import com.github.streamshub.systemtests.constants.TimeConstants;
import com.github.streamshub.systemtests.enums.FilterType;
import com.github.streamshub.systemtests.locators.ClusterOverviewPageSelectors;
import com.github.streamshub.systemtests.locators.CssSelectors;
Expand All @@ -20,6 +22,7 @@
import com.github.streamshub.systemtests.setup.keycloak.KeycloakOperatorSetup;
import com.github.streamshub.systemtests.setup.keycloak.KeycloakTestConfig;
import com.github.streamshub.systemtests.setup.strimzi.KafkaSetup;
import com.github.streamshub.systemtests.utils.Utils;
import com.github.streamshub.systemtests.utils.WaitUtils;
import com.github.streamshub.systemtests.utils.playwright.PwPageUrls;
import com.github.streamshub.systemtests.utils.playwright.PwUtils;
Expand All @@ -44,6 +47,7 @@
import org.junit.jupiter.api.TestMethodOrder;

import static com.github.streamshub.systemtests.utils.Utils.getTestCaseConfig;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag(TestTags.REGRESSION)
Expand Down Expand Up @@ -112,12 +116,11 @@ void testAccessDevUser() {
PwUtils.waitForLocatorCount(tcc, 1, TopicsPageSelectors.TPS_TABLE_ROWS, false);
PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_NO_RESULTS_FOUND, "No results found", false);

// TODO: enable once fixed
// // Logout and check user is no longer logged in
// PwUtils.logoutUser(tcc, AuthTestConstants.USER_DEV_BOB, true);
// PwUtils.navigate(tcc, PwPageUrls.getKafkaBaseUrl(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME));
// Utils.sleepWait(TimeConstants.UI_COMPONENT_REACTION_INTERVAL_SHORT);
// assertNotEquals(tcc.page().url(), ConsoleUtils.getConsoleUiUrl(tcc.consoleInstanceName(), true));
PwUtils.logoutUser(tcc, AuthTestConstants.USER_DEV_BOB, true);
PwUtils.navigate(tcc, PwPageUrls.getKafkaBaseUrl(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME));
Utils.sleepWait(TimeConstants.UI_COMPONENT_REACTION_INTERVAL_SHORT);
assertNotEquals(tcc.page().url(), ConsoleUtils.getConsoleUiUrl(tcc.consoleInstanceName(), true));
}

/**
Expand Down Expand Up @@ -204,17 +207,16 @@ void testAccessAdminUser() {
PwUtils.waitForLocatorAndClick(tcc, TopicsPageSelectors.TPS_TOP_TOOLBAR_FILTER_SEARCH_BUTTON);
PwUtils.waitForLocatorCount(tcc, AuthTestConstants.ADMIN_REPLICATED_TOPICS_COUNT, TopicsPageSelectors.TPS_TABLE_ROWS, false);

// TODO: enable once fixed
// // Logout and check user is no longer logged in
// PwUtils.logoutUser(tcc, AuthTestConstants.USER_ADMIN_ALICE, true);
// // Dev
// PwUtils.navigate(tcc, PwPageUrls.getKafkaBaseUrl(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME));
// Utils.sleepWait(TimeConstants.UI_COMPONENT_REACTION_INTERVAL_SHORT);
// assertNotEquals(tcc.page().url(), ConsoleUtils.getConsoleUiUrl(tcc.consoleInstanceName(), true));
// // Admin
// PwUtils.navigate(tcc, PwPageUrls.getKafkaBaseUrl(tcc, AuthTestConstants.TEAM_ADMIN_KAFKA_NAME));
// Utils.sleepWait(TimeConstants.UI_COMPONENT_REACTION_INTERVAL_SHORT);
// assertNotEquals(tcc.page().url(), ConsoleUtils.getConsoleUiUrl(tcc.consoleInstanceName(), true));
PwUtils.logoutUser(tcc, AuthTestConstants.USER_ADMIN_ALICE, true);
// Dev
PwUtils.navigate(tcc, PwPageUrls.getKafkaBaseUrl(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME));
Utils.sleepWait(TimeConstants.UI_COMPONENT_REACTION_INTERVAL_SHORT);
assertNotEquals(tcc.page().url(), ConsoleUtils.getConsoleUiUrl(tcc.consoleInstanceName(), true));
// Admin
PwUtils.navigate(tcc, PwPageUrls.getKafkaBaseUrl(tcc, AuthTestConstants.TEAM_ADMIN_KAFKA_NAME));
Utils.sleepWait(TimeConstants.UI_COMPONENT_REACTION_INTERVAL_SHORT);
assertNotEquals(tcc.page().url(), ConsoleUtils.getConsoleUiUrl(tcc.consoleInstanceName(), true));
}

/**
Expand Down Expand Up @@ -274,13 +276,29 @@ void testAccessTopicsViewUser() {
PwUtils.navigate(tcc, PwPageUrls.getNodesPage(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME));
PwUtils.waitForContainsText(tcc, NodesPageSelectors.PAGES_NOT_AUTHORIZED_CONTENT, "403", true);

// TODO: enable once fixed
// LOGGER.info("Verify consumer groups page is unavailable");
// PwUtils.navigate(tcc, PwPageUrls.getGroupsMembersPage(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME, ""));
// PwUtils.waitForContainsText(tcc, CssSelectors.PAGES_NOT_AUTHORIZED_CONTENT, "403 Forbidden", true);
//
LOGGER.info("Verify consumer groups page is unavailable");
String newTopicName = AuthTestConstants.TEAM_DEV_TOPIC_PREFIX + "unathorized-groups";
KafkaClients clients = new KafkaClientsBuilder()
.withNamespaceName(tcc.namespace())
.withTopicName(newTopicName)
.withMessageCount(Constants.MESSAGE_COUNT)
.withDelayMs(0)
.withProducerName(KafkaNamingUtils.producerName(newTopicName))
.withConsumerName(KafkaNamingUtils.consumerName(newTopicName))
.withConsumerGroup(KafkaNamingUtils.consumerGroupName(newTopicName))
.withBootstrapAddress(KafkaUtils.getPlainScramShaBootstrapAddress(AuthTestConstants.TEAM_DEV_KAFKA_NAME))
.withUsername(KafkaNamingUtils.kafkaUserName(AuthTestConstants.TEAM_DEV_KAFKA_NAME))
.withAdditionalConfig(KafkaClientsUtils.getScramShaConfig(tcc.namespace(), KafkaNamingUtils.kafkaUserName(AuthTestConstants.TEAM_DEV_KAFKA_NAME), SecurityProtocol.SASL_PLAINTEXT))
.build();

KubeResourceManager.get().createResourceAsyncWait(clients.producer(), clients.consumer());
WaitUtils.waitForClientsSuccess(clients);
String consumerGroupEncodedName = Identifiers.encode(KafkaNamingUtils.consumerGroupName(newTopicName));
PwUtils.navigate(tcc, PwPageUrls.getGroupsMembersPage(tcc, AuthTestConstants.TEAM_DEV_KAFKA_NAME, consumerGroupEncodedName));
PwUtils.waitForContainsText(tcc, CssSelectors.BODY_EMPTY_STATE, "403 Forbidden", true);

// Logout and check user is no longer logged in
//PwUtils.logoutUser(tcc, AuthTestConstants.USER_TOPICONLY_FRANK, true);
PwUtils.logoutUser(tcc, AuthTestConstants.USER_TOPICONLY_FRANK, true);
}

/**
Expand Down Expand Up @@ -373,9 +391,8 @@ void testAccessGroupsViewUser() {

LOGGER.info("Wait for producer and consumer clients on topic '{}' to complete successfully", newTopicName);
WaitUtils.waitForClientsSuccess(clients);
// TODO: enable once fixed
// Logout and check user is no longer logged in
//PwUtils.logoutUser(tcc, AuthTestConstants.USER_CONSUMERONLY_GRACE, true);
PwUtils.logoutUser(tcc, AuthTestConstants.USER_CONSUMERONLY_GRACE, true);
}

@BeforeAll
Expand Down
Loading