Skip to content

Commit b719b23

Browse files
Merge pull request #7371 from rabbitmq/fix-7369
Fix 7369
2 parents fe1b7cb + 20269bf commit b719b23

22 files changed

+332
-170
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1>Exchanges</h1>
2-
<div class="section">
2+
<div class="section" id="exchanges-paging-section">
33
<%= paginate_ui(exchanges, 'exchanges') %>
4-
</div>
5-
<div class="updatable">
4+
</div>
5+
<div class="updatable" id="exchanges-table-section">
66
<% if (exchanges.items.length > 0) { %>
77
<table class="list">
88
<thead>
@@ -84,7 +84,7 @@
8484
</div>
8585
</div>
8686

87-
<div class="section-hidden">
87+
<div class="section-hidden" id="add-new-exchange">
8888
<h2>Add a new exchange</h2>
8989
<div class="hider">
9090
<form action="#/exchanges" method="put">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
<form action="<%= url %>" method="POST">
3+
<form action="<%= url %>" id="login_form" method="POST">
44
<input type="hidden" name="access_token" value="<%= access_token %>">
55
<input type="submit" value="<%= name %>">
66
</form>
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=/exchanges
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
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=/exchanges
10+
# Path to the folder where all configuration file reside. It is relative to the selenim/test folder
11+
TEST_CONFIG_PATH=/mgt-only
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/suites/suite_template

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ kill_container_if_exist() {
5252
docker stop $1 &> /dev/null || true && docker rm $1 &> /dev/null || true
5353
}
5454
wait_for_message() {
55+
attemps_left=10
5556
while ! docker logs $1 | grep -q "$2";
5657
do
5758
sleep 5
58-
echo "Waiting 5sec for $1 to start ..."
59+
echo "Waiting 5sec for $1 to start ($attemps_left attempts left )..."
60+
((attemps_left--))
61+
if [[ "$attemps_left" -lt 1 ]]; then
62+
echo "Timed out waiting"
63+
exit 1
64+
fi
5965
done
60-
6166
}
6267

6368
init_rabbitmq() {

deps/rabbitmq_management/selenium/test/basic-auth/happy-login.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ describe('An internal user with administrator tag', function () {
2121

2222
it('can log in into the management ui', async function () {
2323
await login.login('guest', 'guest')
24-
if (!await overview.isLoaded()) {
25-
throw new Error('Failed to login')
26-
}
24+
await overview.isLoaded()
2725
assert.equal(await overview.getUser(), 'User guest')
2826
})
2927

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+
RABBITMQ_CONFIG_FILE ?= basic-auth/rabbitmq.config
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/${RABBITMQ_CONFIG_FILE})
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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 ExchangesPage = require('../pageobjects/ExchangesPage')
9+
const ExchangePage = require('../pageobjects/ExchangePage')
10+
11+
describe('Exchange management', function () {
12+
let login
13+
let exchanges
14+
let exchange
15+
let overview
16+
let captureScreen
17+
18+
before(async function () {
19+
driver = buildDriver()
20+
await goToHome(driver)
21+
login = new LoginPage(driver)
22+
overview = new OverviewPage(driver)
23+
exchanges = new ExchangesPage(driver)
24+
exchange = new ExchangePage(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+
overview.clickOnExchangesTab()
32+
})
33+
34+
it('display summary of exchanges', async function () {
35+
assert.equal("All exchanges (7)", await exchanges.getPagingSectionHeaderText())
36+
})
37+
38+
it('list all default exchanges', async function () {
39+
actual_table = await exchanges.getExchangesTable(3)
40+
expected_table = [
41+
["(AMQP default)", "direct", "D"],
42+
["amq.direct", "direct", "D"],
43+
["amq.fanout", "fanout", "D"],
44+
["amq.headers", "headers", "D"],
45+
["amq.match", "headers", "D"],
46+
["amq.rabbitmq.trace", "topic", "D I"],
47+
["amq.topic", "topic", "D"]
48+
]
49+
assert.deepEqual(actual_table, expected_table)
50+
})
51+
52+
it('view one exchange', async function () {
53+
await exchanges.clickOnExchange("%2F", "amq.fanout")
54+
await exchange.isLoaded()
55+
assert.equal("amq.fanout", await exchange.getName())
56+
})
57+
58+
after(async function () {
59+
await teardown(driver, this, captureScreen)
60+
})
61+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[rabbitmq_management].
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{rabbit, [
3+
{auth_backends, [rabbit_auth_backend_internal]}
4+
]},
5+
{rabbitmq_management, [
6+
{login_session_timeout, 150} %% in minutes
7+
]},
8+
{rabbitmq_management_agent, [
9+
{disable_metrics_collector, true}
10+
]}
11+
12+
].
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{rabbit, [
3+
{auth_backends, [rabbit_auth_backend_oauth2]}
4+
]},
5+
{rabbitmq_management, [
6+
{login_session_timeout, 1}, %% in minutes
7+
{oauth_enabled, true},
8+
{oauth_initiated_logon_type, idp_initiated},
9+
{oauth_provider_url, "http://localhost:3000"}
10+
]},
11+
{rabbitmq_auth_backend_oauth2, [
12+
{resource_server_id, <<"rabbitmq">>},
13+
{preferred_username_claims, [<<"user_name">>]},
14+
{key_config, [
15+
{default_key, <<"legacy-token-key">>},
16+
{signing_keys,
17+
#{<<"legacy-token-key">> => {pem, <<"-----BEGIN PUBLIC KEY-----
18+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2dP+vRn+Kj+S/oGd49kq
19+
6+CKNAduCC1raLfTH7B3qjmZYm45yDl+XmgK9CNmHXkho9qvmhdksdzDVsdeDlhK
20+
IdcIWadhqDzdtn1hj/22iUwrhH0bd475hlKcsiZ+oy/sdgGgAzvmmTQmdMqEXqV2
21+
B9q9KFBmo4Ahh/6+d4wM1rH9kxl0RvMAKLe+daoIHIjok8hCO4cKQQEw/ErBe4SF
22+
2cr3wQwCfF1qVu4eAVNVfxfy/uEvG3Q7x005P3TcK+QcYgJxav3lictSi5dyWLgG
23+
QAvkknWitpRK8KVLypEj5WKej6CF8nq30utn15FQg0JkHoqzwiCqqeen8GIPteI7
24+
VwIDAQAB
25+
-----END PUBLIC KEY-----">>}
26+
}
27+
}]
28+
}
29+
]}
30+
].

0 commit comments

Comments
 (0)