Skip to content

Fix 7369 (backport #7371) #7373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2023
Merged
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
8 changes: 4 additions & 4 deletions deps/rabbitmq_management/priv/www/js/tmpl/exchanges.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h1>Exchanges</h1>
<div class="section">
<div class="section" id="exchanges-paging-section">
<%= paginate_ui(exchanges, 'exchanges') %>
</div>
<div class="updatable">
</div>
<div class="updatable" id="exchanges-table-section">
<% if (exchanges.items.length > 0) { %>
<table class="list">
<thead>
Expand Down Expand Up @@ -84,7 +84,7 @@
</div>
</div>

<div class="section-hidden">
<div class="section-hidden" id="add-new-exchange">
<h2>Add a new exchange</h2>
<div class="hider">
<form action="#/exchanges" method="put">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


<form action="<%= url %>" method="POST">
<form action="<%= url %>" id="login_form" method="POST">
<input type="hidden" name="access_token" value="<%= access_token %>">
<input type="submit" value="<%= name %>">
</form>
24 changes: 24 additions & 0 deletions deps/rabbitmq_management/selenium/suites/exchanges.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Name of the suite used to generate log and screen folders
SUITE=$( basename "${BASH_SOURCE[0]}" .sh)

# Path to the test cases this suite should run. It is relative to the selenium/test folder
TEST_CASES_PATH=/exchanges
# Path to the folder where all configuration file reside. It is relative to the selenim/test folder
TEST_CONFIG_PATH=/basic-auth

source $SCRIPT/suite_template

_setup () {
start_rabbitmq
}
_save_logs() {
save_container_logs rabbitmq
}
_teardown() {
kill_container_if_exist rabbitmq
}
run
24 changes: 24 additions & 0 deletions deps/rabbitmq_management/selenium/suites/mgt-only-exchanges.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Name of the suite used to generate log and screen folders
SUITE=$( basename "${BASH_SOURCE[0]}" .sh)

# Path to the test cases this suite should run. It is relative to the selenium/test folder
TEST_CASES_PATH=/exchanges
# Path to the folder where all configuration file reside. It is relative to the selenim/test folder
TEST_CONFIG_PATH=/mgt-only

source $SCRIPT/suite_template

_setup () {
start_rabbitmq
}
_save_logs() {
save_container_logs rabbitmq
}
_teardown() {
kill_container_if_exist rabbitmq
}
run
9 changes: 7 additions & 2 deletions deps/rabbitmq_management/selenium/suites/suite_template
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ kill_container_if_exist() {
docker stop $1 &> /dev/null || true && docker rm $1 &> /dev/null || true
}
wait_for_message() {
attemps_left=10
while ! docker logs $1 | grep -q "$2";
do
sleep 5
echo "Waiting 5sec for $1 to start ..."
echo "Waiting 5sec for $1 to start ($attemps_left attempts left )..."
((attemps_left--))
if [[ "$attemps_left" -lt 1 ]]; then
echo "Timed out waiting"
exit 1
fi
done

}

init_rabbitmq() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ describe('An internal user with administrator tag', function () {

it('can log in into the management ui', async function () {
await login.login('guest', 'guest')
if (!await overview.isLoaded()) {
throw new Error('Failed to login')
}
await overview.isLoaded()
assert.equal(await overview.getUser(), 'User guest')
})

Expand Down
20 changes: 20 additions & 0 deletions deps/rabbitmq_management/selenium/test/exchanges/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.ONESHELL:# single shell invocation for all lines in the recipe
SHELL = bash# we depend on bash expansion for e.g. queue patterns

.DEFAULT_GOAL = help
RABBITMQ_SERVER_ROOT = ../../../../../
RABBITMQ_CONFIG_FILE ?= basic-auth/rabbitmq.config

### TARGETS ###

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

start-rabbitmq: ## Start RabbitMQ
@(docker kill rabbitmq >/dev/null 2>&1 && docker rm rabbitmq)
@(gmake --directory=${RABBITMQ_SERVER_ROOT} run-broker \
RABBITMQ_ENABLED_PLUGINS="rabbitmq_management" \
RABBITMQ_CONFIG_FILE=deps/rabbitmq_management/selenium/test/${RABBITMQ_CONFIG_FILE})

test: ## Run tests interactively e.g. make test [TEST=landing.js]
@(RABBITMQ_URL=http://localhost:15672 RUN_LOCAL=true SCREENSHOTS_DIR=${PWD}/../../screens npm test $(PWD)/$(TEST))
61 changes: 61 additions & 0 deletions deps/rabbitmq_management/selenium/test/exchanges/management.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const { By, Key, until, Builder } = require('selenium-webdriver')
require('chromedriver')
const assert = require('assert')
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require('../utils')

const LoginPage = require('../pageobjects/LoginPage')
const OverviewPage = require('../pageobjects/OverviewPage')
const ExchangesPage = require('../pageobjects/ExchangesPage')
const ExchangePage = require('../pageobjects/ExchangePage')

describe('Exchange management', function () {
let login
let exchanges
let exchange
let overview
let captureScreen

before(async function () {
driver = buildDriver()
await goToHome(driver)
login = new LoginPage(driver)
overview = new OverviewPage(driver)
exchanges = new ExchangesPage(driver)
exchange = new ExchangePage(driver)
captureScreen = captureScreensFor(driver, __filename)

await login.login('guest', 'guest')
if (!await overview.isLoaded()) {
throw new Error('Failed to login')
}
overview.clickOnExchangesTab()
})

it('display summary of exchanges', async function () {
assert.equal("All exchanges (7)", await exchanges.getPagingSectionHeaderText())
})

it('list all default exchanges', async function () {
actual_table = await exchanges.getExchangesTable(3)
expected_table = [
["(AMQP default)", "direct", "D"],
["amq.direct", "direct", "D"],
["amq.fanout", "fanout", "D"],
["amq.headers", "headers", "D"],
["amq.match", "headers", "D"],
["amq.rabbitmq.trace", "topic", "D I"],
["amq.topic", "topic", "D"]
]
assert.deepEqual(actual_table, expected_table)
})

it('view one exchange', async function () {
await exchanges.clickOnExchange("%2F", "amq.fanout")
await exchange.isLoaded()
assert.equal("amq.fanout", await exchange.getName())
})

after(async function () {
await teardown(driver, this, captureScreen)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[rabbitmq_management].
12 changes: 12 additions & 0 deletions deps/rabbitmq_management/selenium/test/mgt-only/rabbitmq.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{rabbit, [
{auth_backends, [rabbit_auth_backend_internal]}
]},
{rabbitmq_management, [
{login_session_timeout, 150} %% in minutes
]},
{rabbitmq_management_agent, [
{disable_metrics_collector, true}
]}

].
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{rabbit, [
{auth_backends, [rabbit_auth_backend_oauth2]}
]},
{rabbitmq_management, [
{login_session_timeout, 1}, %% in minutes
{oauth_enabled, true},
{oauth_initiated_logon_type, idp_initiated},
{oauth_provider_url, "http://localhost:3000"}
]},
{rabbitmq_auth_backend_oauth2, [
{resource_server_id, <<"rabbitmq">>},
{preferred_username_claims, [<<"user_name">>]},
{key_config, [
{default_key, <<"legacy-token-key">>},
{signing_keys,
#{<<"legacy-token-key">> => {pem, <<"-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2dP+vRn+Kj+S/oGd49kq
6+CKNAduCC1raLfTH7B3qjmZYm45yDl+XmgK9CNmHXkho9qvmhdksdzDVsdeDlhK
IdcIWadhqDzdtn1hj/22iUwrhH0bd475hlKcsiZ+oy/sdgGgAzvmmTQmdMqEXqV2
B9q9KFBmo4Ahh/6+d4wM1rH9kxl0RvMAKLe+daoIHIjok8hCO4cKQQEw/ErBe4SF
2cr3wQwCfF1qVu4eAVNVfxfy/uEvG3Q7x005P3TcK+QcYgJxav3lictSi5dyWLgG
QAvkknWitpRK8KVLypEj5WKej6CF8nq30utn15FQg0JkHoqzwiCqqeen8GIPteI7
VwIDAQAB
-----END PUBLIC KEY-----">>}
}
}]
}
]}
].
Loading