Skip to content

Commit 9ab7dca

Browse files
Fix issue 7301
1 parent 4e668b6 commit 9ab7dca

File tree

11 files changed

+193
-10
lines changed

11 files changed

+193
-10
lines changed

deps/rabbitmq_management/priv/www/js/tmpl/permissions.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="section">
1+
<div class="section" id="permissions">
22
<h2>Permissions</h2>
33
<div class="hider">
44
<h3>Current permissions</h3>
@@ -55,8 +55,8 @@ for (var i = 0; i < permissions.length; i++) {
5555
<td>
5656
<input type="hidden" name="vhost" value="<%= fmt_string(parent.name) %>"/>
5757
<select name="username">
58-
<% for (var i = 0; i < users.items.length; i++) { %>
59-
<option value="<%= fmt_string(users.items[i].name) %>"><%= fmt_string(users.items[i].name) %></option>
58+
<% for (var i = 0; i < users.length; i++) { %>
59+
<option value="<%= fmt_string(users[i].name) %>"><%= fmt_string(users[i].name) %></option>
6060
<% } %>
6161
</select>
6262
</td>

deps/rabbitmq_management/priv/www/js/tmpl/topic-permissions.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="section">
1+
<div class="section" id="topic-permissions">
22
<h2>Topic permissions</h2>
33
<div class="hider">
44
<h3>Current topic permissions</h3>
@@ -56,8 +56,8 @@ for (var i = 0; i < topic_permissions.length; i++) {
5656
<td>
5757
<input type="hidden" name="vhost" value="<%= fmt_string(parent.name) %>"/>
5858
<select name="username">
59-
<% for (var i = 0; i < users.items.length; i++) { %>
60-
<option value="<%= fmt_string(users.items[i].name) %>"><%= fmt_string(users.items[i].name) %></option>
59+
<% for (var i = 0; i < users.length; i++) { %>
60+
<option value="<%= fmt_string(users[i].name) %>"><%= fmt_string(users[i].name) %></option>
6161
<% } %>
6262
</select>
6363
</td>

deps/rabbitmq_management/priv/www/js/tmpl/vhost.ejs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<% } %>
99

1010
<% if (!disable_stats) { %>
11-
<div class="section">
11+
<div class="section" id="overview">
1212
<h2>Overview</h2>
1313
<div class="hider updatable">
1414
<%= queue_lengths('lengths-vhost', vhost) %>
15-
<% if (rates_mode != 'none') { %>
15+
<% if (rates_mode != 'none' && vhost.message_stats) { %>
1616
<%= message_rates('msg-rates-vhost', vhost.message_stats) %>
1717
<% } %>
1818
<%= data_rates('data-rates-vhost', vhost, 'Data rates') %>
@@ -44,6 +44,7 @@
4444
</td>
4545
</tr>
4646
<% } %>
47+
4748
</table>
4849
</td>
4950
</tr>
@@ -56,7 +57,7 @@
5657

5758
<%= format('topic-permissions', {'mode': 'vhost', 'topic_permissions': topic_permissions, 'users':users, 'parent': vhost, 'exchanges': exchanges}) %>
5859

59-
<div class="section-hidden">
60+
<div class="section-hidden" id="delete-vhost">
6061
<h2>Delete this vhost</h2>
6162
<div class="hider">
6263
<form action="#/vhosts" method="delete" class="confirm">

deps/rabbitmq_management/selenium/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,23 @@ make RABBITMQ_CONFIG_FILE=rabbitmq-localhost-keycloak.config start-rabbitmq
116116

117117
We do not have this issue when we run the headless suites because they use dedicated files
118118
for each suite. Doing the same when running locally, i.e using `localhost`, would be too tedious.
119+
120+
## Chrome vs Chrome driver version mismatch
121+
122+
If you find the following error when you first attempt to run one of the selenium tests
123+
```
124+
SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 108
125+
Current browser version is 110.0.5481.100 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
126+
```
127+
It is because your current Chrome version is newer than the `chromedriver` configured in package.json.
128+
```
129+
....
130+
"dependencies": {
131+
"chromedriver": "^110.0.0",
132+
...
133+
```
134+
To fix the problem, bump the version in your package.json to match your local chrome version and run again the
135+
following command:
136+
```
137+
npm install
138+
```

deps/rabbitmq_management/selenium/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "",
1212
"license": "ISC",
1313
"dependencies": {
14-
"chromedriver": "^108.0.0",
14+
"chromedriver": "^110.0.0",
1515
"ejs": "^3.1.8",
1616
"express": "^4.18.2",
1717
"geckodriver": "^3.0.2",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
# Name of the suite used to generate log and screen folders
6+
SUITE=$( basename "${BASH_SOURCE[0]}" .sh)
7+
8+
# Path to the test cases this suite should run. It is relative to the selenium/test folder
9+
TEST_CASES_PATH=/vhosts
10+
# Path to the folder where all configuration file reside. It is relative to the selenim/test folder
11+
TEST_CONFIG_PATH=/basic-auth
12+
13+
source $SCRIPT/suite_template
14+
15+
_setup () {
16+
start_rabbitmq
17+
}
18+
_save_logs() {
19+
save_container_logs rabbitmq
20+
}
21+
_teardown() {
22+
kill_container_if_exist rabbitmq
23+
}
24+
run

deps/rabbitmq_management/selenium/test/pageobjects/AdminTab.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const FILTERED_USER = By.css('span.filter-highlight')
1414
// RHM : RIGHT HAND MENU
1515
const USERS_ON_RHM = By.css('div#rhs ul li a[href="#/users"]')
1616
const LIMITS_ON_RHM = By.css('div#rhs ul li a[href="#/limits"]')
17+
const VHOSTS_ON_RHM = By.css('div#rhs ul li a[href="#/vhosts"]')
1718

1819
module.exports = class AdminTab extends OverviewPage {
1920
async isLoaded () {
@@ -25,6 +26,9 @@ module.exports = class AdminTab extends OverviewPage {
2526
async clickOnLimits() {
2627
await this.click(LIMITS_ON_RHM)
2728
}
29+
async clickOnVhosts() {
30+
await this.click(VHOSTS_ON_RHM)
31+
}
2832

2933
async searchForUser(user, regex = false) {
3034

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { By, Key, until, Builder } = require('selenium-webdriver')
2+
3+
const AdminTab = require('./AdminTab')
4+
5+
const VHOST_NAME = By.css('div#main h1 b')
6+
const OVERVIEW_SECTION = By.css('div#main div#overview')
7+
const PERMISSIONS_SECTION = By.css('div#main div#permissions')
8+
const TOPIC_PERMISSIONS_SECTION = By.css('div#main div#topic-permissions')
9+
10+
11+
module.exports = class VhostAdminTab extends AdminTab {
12+
async isLoaded () {
13+
await this.waitForDisplayed(VHOST_NAME)
14+
await this.waitForDisplayed(OVERVIEW_SECTION)
15+
await this.waitForDisplayed(PERMISSIONS_SECTION)
16+
return await this.waitForDisplayed(TOPIC_PERMISSIONS_SECTION)
17+
}
18+
19+
async getName() {
20+
return await this.getText(VHOST_NAME)
21+
}
22+
23+
24+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { By, Key, until, Builder } = require('selenium-webdriver')
2+
3+
const AdminTab = require('./AdminTab')
4+
5+
const SELECTED_VHOSTS_ON_RHM = By.css('div#rhs ul li a[href="#/vhosts"]')
6+
const FILTER_VHOST = By.css('div#main div.filter input#filter')
7+
const CHECKBOX_REGEX = By.css('div#main div.filter input#filter-regex-mode')
8+
9+
const VHOSTS_TABLE_ROWS = By.css('div#main table.list tbody tr')
10+
11+
module.exports = class VhostsAdminTab extends AdminTab {
12+
async isLoaded () {
13+
await this.waitForDisplayed(SELECTED_VHOSTS_ON_RHM)
14+
}
15+
async searchForVhosts(vhost, regex = false) {
16+
await this.sendKeys(FILTER_VHOST, vhost)
17+
await this.sendKeys(FILTER_VHOST, Key.RETURN)
18+
if (regex) {
19+
await this.click(CHECKBOX_REGEX)
20+
}
21+
await this.driver.sleep(250)
22+
await this.waitForDisplayed(VHOSTS_TABLE_ROWS)
23+
return this.driver.findElement(VHOSTS_TABLE_ROWS)
24+
}
25+
async hasVhosts(vhost, regex = false) {
26+
return await this.searchForVhosts(vhost, regex) != undefined
27+
}
28+
async clickOnVhost(vhost_rows, vhost) {
29+
let links = await vhost_rows.findElements(By.css("td a"))
30+
for (let link of links) {
31+
let text = await link.getText()
32+
if ( text === "/" ) return link.click()
33+
}
34+
throw "Vhost " + vhost + " not found"
35+
}
36+
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.ONESHELL:# single shell invocation for all lines in the recipe
2+
SHELL = bash# we depend on bash expansion for e.g. queue patterns
3+
4+
.DEFAULT_GOAL = help
5+
RABBITMQ_SERVER_ROOT = ../../../../../
6+
7+
8+
### TARGETS ###
9+
10+
help:
11+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
12+
13+
start-rabbitmq: ## Start RabbitMQ
14+
@(docker kill rabbitmq >/dev/null 2>&1 && docker rm rabbitmq)
15+
@(gmake --directory=${RABBITMQ_SERVER_ROOT} run-broker \
16+
RABBITMQ_ENABLED_PLUGINS="rabbitmq_management" \
17+
RABBITMQ_CONFIG_FILE=deps/rabbitmq_management/selenium/test/basic-auth/rabbitmq.config)
18+
19+
test: ## Run tests interactively e.g. make test [TEST=landing.js]
20+
@(RABBITMQ_URL=http://localhost:15672 RUN_LOCAL=true SCREENSHOTS_DIR=${PWD}/../../screens npm test $(PWD)/$(TEST))
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const { By, Key, until, Builder } = require('selenium-webdriver')
2+
require('chromedriver')
3+
const assert = require('assert')
4+
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require('../utils')
5+
6+
const LoginPage = require('../pageobjects/LoginPage')
7+
const OverviewPage = require('../pageobjects/OverviewPage')
8+
const AdminTab = require('../pageobjects/AdminTab')
9+
const VhostsAdminTab = require('../pageobjects/VhostsAdminTab')
10+
const VhostAdminTab = require('../pageobjects/VhostAdminTab')
11+
12+
describe('Virtual Hosts in Admin tab', function () {
13+
let login
14+
let overview
15+
let captureScreen
16+
17+
before(async function () {
18+
driver = buildDriver()
19+
await goToHome(driver)
20+
login = new LoginPage(driver)
21+
overview = new OverviewPage(driver)
22+
adminTab = new AdminTab(driver)
23+
vhostsTab = new VhostsAdminTab(driver)
24+
vhostTab = new VhostAdminTab(driver)
25+
captureScreen = captureScreensFor(driver, __filename)
26+
27+
await login.login('guest', 'guest')
28+
if (!await overview.isLoaded()) {
29+
throw new Error('Failed to login')
30+
}
31+
32+
})
33+
34+
it('find default vhost', async function () {
35+
await overview.clickOnAdminTab()
36+
await adminTab.clickOnVhosts()
37+
assert.equal(true, await vhostsTab.hasVhosts("/"))
38+
})
39+
it('find default vhost and view it', async function () {
40+
await overview.clickOnAdminTab()
41+
await adminTab.clickOnVhosts()
42+
await vhostsTab.clickOnVhost(await vhostsTab.searchForVhosts("/"), "/")
43+
if (!await vhostTab.isLoaded()) {
44+
throw new Error('Failed to load vhost')
45+
}
46+
assert.equal("/", await vhostTab.getName())
47+
})
48+
49+
50+
after(async function () {
51+
await teardown(driver, this, captureScreen)
52+
})
53+
})

0 commit comments

Comments
 (0)