[
https://issues.apache.org/jira/browse/ARTEMIS-5946?focusedWorklogId=1009057&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1009057
]
ASF GitHub Bot logged work on ARTEMIS-5946:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Mar/26 11:37
Start Date: 11/Mar/26 11:37
Worklog Time Spent: 10m
Work Description: brusdev commented on code in PR #6242:
URL: https://github.com/apache/artemis/pull/6242#discussion_r2917801476
##########
tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java:
##########
@@ -16,103 +16,76 @@
*/
package org.apache.activemq.artemis.tests.smoke.console;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import
org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.smoke.console.pages.LoginPage;
+import org.apache.activemq.artemis.tests.smoke.console.pages.StatusPage;
+import org.junit.Assert;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
+import java.util.Collections;
+import java.util.Set;
+
//Parameters set in super class
@ExtendWith(ParameterizedTestExtension.class)
public class TabsTest extends ArtemisTest {
- public TabsTest(String browser, String serverName) {
- super(browser, serverName);
- }
-
- @TestTemplate
- public void testConnectionsTab() {
- testTab("connections", "Connections");
- }
-
- @TestTemplate
- public void testSessionsTab() {
- testTab("sessions", "Sessions");
- }
-
- @TestTemplate
- public void testConsumersTab() {
- testTab("consumers", "Consumers");
- }
-
- @TestTemplate
- public void testProducersTab() {
- testTab("producers", "Producers");
- }
-
- @TestTemplate
- public void testAddressesTab() {
- testTab("addresses", "Addresses");
- }
+ private final String TAB_CONNECTIONS = "Connections";
- @TestTemplate
- public void testQueuesTab() {
- testTab("queues", "Queues");
- }
+ private final String TAB_SESSIONS = "Sessions";
- private void testTab(String userpass, String tab) {
- loadLandingPage();
- new LoginPage(driver).loginValidUser(userpass, userpass,
DEFAULT_TIMEOUT);
- driver.findElement(By.xpath("//button/span[contains(text(),'" + tab +
"')]"));
- }
+ private final String TAB_CONSUMERS = "Consumers";
- @TestTemplate
- public void testConnectionsTabNegative() {
- // use credentials for a valid user who cannot see the tab
- testTabNegative("queues", "Connections");
- }
+ private final String TAB_PRODUCERS = "Producers";
- @TestTemplate
- public void testSessionsTabNegative() {
- // use credentials for a valid user who cannot see the tab
- testTabNegative("connections", "Sessions");
- }
+ private final String TAB_ADDRESSES = "Addresses";
- @TestTemplate
- public void testConsumersTabNegative() {
- // use credentials for a valid user who cannot see the tab
- testTabNegative("connections", "Consumers");
- }
+ private final String TAB_QUEUES = "Queues";
- @TestTemplate
- public void testProducersTabNegative() {
- // use credentials for a valid user who cannot see the tab
- testTabNegative("connections", "roducers");
- }
+ private final String[] TABS = new String[]{TAB_CONNECTIONS, TAB_SESSIONS,
TAB_CONSUMERS, TAB_PRODUCERS, TAB_ADDRESSES, TAB_QUEUES};
- @TestTemplate
- public void testAddressesTabNegative() {
- // use credentials for a valid user who cannot see the tab
- testTabNegative("connections", "Addresses");
+ public TabsTest(String browser, String serverName) {
+ super(browser, serverName);
}
@TestTemplate
- public void testQueuesTabNegative() {
- // use credentials for a valid user who cannot see the tab
- testTabNegative("connections", "Queues");
+ public void testVisibleTabs() {
+ testTabs(SERVER_ADMIN_USERNAME, false, Set.of(TABS));
+ testTabs("connections", true, Collections.singleton(TAB_CONNECTIONS));
+ testTabs("sessions", true, Collections.singleton(TAB_SESSIONS));
+ testTabs("consumers", true, Collections.singleton(TAB_CONSUMERS));
+ testTabs("producers", true, Collections.singleton(TAB_PRODUCERS));
+ testTabs("addresses", true, Collections.singleton(TAB_ADDRESSES));
+ testTabs("queues", true, Collections.singleton(TAB_QUEUES));
}
- private void testTabNegative(String userpass, String tab) {
+ private void testTabs(String userpass, boolean isAlertExpected, Set<String>
visibleTabs) {
loadLandingPage();
- new LoginPage(driver).loginValidUser(userpass, userpass,
DEFAULT_TIMEOUT);
- try {
- driver.findElement(By.xpath("//a[contains(text(),'" + tab + "')]"));
- fail("User " + userpass + " should not have been able to see the " +
tab + " tab.");
- } catch (NoSuchElementException e) {
- // expected
+
+ StatusPage statusPage = new LoginPage(driver).loginValidUser(userpass,
userpass, DEFAULT_TIMEOUT);
+
+ assertEquals(isAlertExpected, statusPage.countAlerts() > 0);
+ statusPage.closeAlerts();
+
+ for (String tab : TABS) {
+ By tabLocator = By.xpath("//button/span[contains(text(),'" + tab +
"')]");
+ if (visibleTabs.contains(tab)) {
+ driver.findElement(tabLocator);
+ } else {
+ try {
+ driver.findElement(tabLocator);
+ fail("User " + userpass + " should not have been able to see
the " + tab + " tab.");
+ } catch (Exception e) {
+ Assert.assertEquals(NoSuchElementException.class, e.getClass());
Review Comment:
Good catch!
Issue Time Tracking
-------------------
Worklog Id: (was: 1009057)
Time Spent: 20m (was: 10m)
> Update to Artemis Console 1.7.0
> -------------------------------
>
> Key: ARTEMIS-5946
> URL: https://issues.apache.org/jira/browse/ARTEMIS-5946
> Project: Artemis
> Issue Type: Dependency upgrade
> Components: Web Console
> Reporter: Domenico Francesco Bruscino
> Assignee: Domenico Francesco Bruscino
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Update to Artemis Console 1.7.0
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]