diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js index ec4869939b..c350ddf904 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js @@ -128,6 +128,12 @@ var Artemis; ctrl.showDeleteAddress = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'deleteAddress'); ctrl.showCreateQueue = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'createQueue'); ctrl.showDeleteQueue = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'destroyQueue'); + ctrl.showConnections = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'listConnections'); + ctrl.showSessions = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'listSessions'); + ctrl.showConsumers = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'listConsumers'); + ctrl.showProducers = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'listProducers'); + ctrl.showAddresses = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'listAddresses'); + ctrl.showQueues = hasInvokeRights(jolokia, Artemis.getBrokerMBean(workspace, jolokia), 'listQueues'); function getTabs() { @@ -137,12 +143,24 @@ var Artemis; .filter(function (route) { return _.startsWith(route, '/artemis'); }); if (enabledRoutes.length > 0) { tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisStatus.title, TAB_CONFIG.artemisStatus.route)); - tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisConnections.title, TAB_CONFIG.artemisConnections.route)); - tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisSessions.title, TAB_CONFIG.artemisSessions.route)); - tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisConsumers.title, TAB_CONFIG.artemisConsumers.route)); - tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisProducers.title, TAB_CONFIG.artemisProducers.route)); - tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisAddresses.title, TAB_CONFIG.artemisAddresses.route)); - tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisQueues.title, TAB_CONFIG.artemisQueues.route)); + if (ctrl.showConnections) { + tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisConnections.title, TAB_CONFIG.artemisConnections.route)); + } + if (ctrl.showSessions) { + tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisSessions.title, TAB_CONFIG.artemisSessions.route)); + } + if (ctrl.showConsumers) { + tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisConsumers.title, TAB_CONFIG.artemisConsumers.route)); + } + if (ctrl.showProducers) { + tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisProducers.title, TAB_CONFIG.artemisProducers.route)); + } + if (ctrl.showAddresses) { + tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisAddresses.title, TAB_CONFIG.artemisAddresses.route)); + } + if (ctrl.showQueues) { + tabs.push(new Nav.HawtioTab(TAB_CONFIG.artemisQueues.title, TAB_CONFIG.artemisQueues.route)); + } tabs.push(new Nav.HawtioTab(TAB_CONFIG.attributes.title, TAB_CONFIG.attributes.route)); tabs.push(new Nav.HawtioTab(TAB_CONFIG.operations.title, TAB_CONFIG.operations.route)); tabs.push(new Nav.HawtioTab(TAB_CONFIG.chart.title, TAB_CONFIG.chart.route)); diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml index cc8940eb7f..e7fd3e7db0 100644 --- a/tests/smoke-tests/pom.xml +++ b/tests/smoke-tests/pom.xml @@ -260,12 +260,13 @@ create - amq + amq,connections,sessions,consumers,producers,addresses,queues admin admin false false ${basedir}/target/console + ${basedir}/target/classes/servers/console --http-host ${sts-http-host} diff --git a/tests/smoke-tests/src/main/resources/servers/console/artemis-roles.properties b/tests/smoke-tests/src/main/resources/servers/console/artemis-roles.properties new file mode 100644 index 0000000000..a63148d7e8 --- /dev/null +++ b/tests/smoke-tests/src/main/resources/servers/console/artemis-roles.properties @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +amq=admin +connections=connections +sessions=sessions +consumers=consumers +producers=producers +addresses=addresses +queues=queues \ No newline at end of file diff --git a/tests/smoke-tests/src/main/resources/servers/console/artemis-users.properties b/tests/smoke-tests/src/main/resources/servers/console/artemis-users.properties new file mode 100644 index 0000000000..704eb5b455 --- /dev/null +++ b/tests/smoke-tests/src/main/resources/servers/console/artemis-users.properties @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +admin=admin +connections=connections +sessions=sessions +consumers=consumers +producers=producers +addresses=addresses +queues=queues diff --git a/tests/smoke-tests/src/main/resources/servers/console/management.xml b/tests/smoke-tests/src/main/resources/servers/console/management.xml new file mode 100644 index 0000000000..653ba0d3f5 --- /dev/null +++ b/tests/smoke-tests/src/main/resources/servers/console/management.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java new file mode 100644 index 0000000000..32b3d5a615 --- /dev/null +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/TabsTest.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.tests.smoke.console; + +import org.apache.activemq.artemis.tests.smoke.console.pages.LoginPage; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.openqa.selenium.By; +import org.openqa.selenium.MutableCapabilities; +import org.openqa.selenium.NoSuchElementException; + +@RunWith(Parameterized.class) +public class TabsTest extends ConsoleTest { + + public TabsTest(MutableCapabilities browserOptions) { + super(browserOptions); + } + + @Test + public void testConnectionsTab() { + testTab("connections", "Connections"); + } + + @Test + public void testSessionsTab() { + testTab("sessions", "Sessions"); + } + + @Test + public void testConsumersTab() { + testTab("consumers", "Consumers"); + } + + @Test + public void testProducersTab() { + testTab("producers", "Producers"); + } + + @Test + public void testAddressesTab() { + testTab("addresses", "Addresses"); + } + + @Test + public void testQueuesTab() { + testTab("queues", "Queues"); + } + + private void testTab(String userpass, String tab) { + driver.get(webServerUrl + "/console"); + new LoginPage(driver).loginValidUser(userpass, userpass, DEFAULT_TIMEOUT); + driver.findElement(By.xpath("//a[contains(text(),'" + tab + "')]")); + } + + @Test + public void testConnectionsTabNegative() { + // use credentials for a valid user who cannot see the tab + testTabNegative("queues", "Connections"); + } + + @Test + public void testSessionsTabNegative() { + // use credentials for a valid user who cannot see the tab + testTabNegative("connections", "Sessions"); + } + + @Test + public void testConsumersTabNegative() { + // use credentials for a valid user who cannot see the tab + testTabNegative("connections", "Consumers"); + } + + @Test + public void testProducersTabNegative() { + // use credentials for a valid user who cannot see the tab + testTabNegative("connections", "roducers"); + } + + @Test + public void testAddressesTabNegative() { + // use credentials for a valid user who cannot see the tab + testTabNegative("connections", "Addresses"); + } + + @Test + public void testQueuesTabNegative() { + // use credentials for a valid user who cannot see the tab + testTabNegative("connections", "Queues"); + } + + private void testTabNegative(String userpass, String tab) { + driver.get(webServerUrl + "/console"); + 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 + } + } +}