Skip to content
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
2 changes: 1 addition & 1 deletion deps/rabbitmq_management/priv/www/js/tmpl/popup.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<%= text %>
<br/>
<br/>
<span>Close</span>
<span id="close">Close</span>
</div>
4 changes: 2 additions & 2 deletions deps/rabbitmq_management/priv/www/js/tmpl/vhosts.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<h1>Virtual Hosts</h1>

<div class="section">
<div class="section" id="vhosts">
<h2>All virtual hosts</h2>
<div class="hider">
<%= filter_ui(vhosts) %>
<div class="updatable">
<% if (vhosts.length > 0) { %>
<table class="list">
<table class="list" >
<thead>
<tr>
<%= group_heading('vhosts', 'Overview', [true, true, true]) %>
Expand Down
Empty file.
37 changes: 36 additions & 1 deletion selenium/test/exchanges/management.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { By, Key, until, Builder } = require('selenium-webdriver')
require('chromedriver')
const assert = require('assert')
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require('../utils')
const { buildDriver, goToHome, captureScreensFor, teardown, doWhile } = require('../utils')

const LoginPage = require('../pageobjects/LoginPage')
const OverviewPage = require('../pageobjects/OverviewPage')
Expand Down Expand Up @@ -66,6 +66,41 @@ describe('Exchange management', function () {
assert.equal("amq.fanout", await exchange.getName())
})

it('queue selectable columns', async function () {
await overview.clickOnOverviewTab()
await overview.clickOnExchangesTab()
await doWhile(async function() { return exchanges.getExchangesTable() },
function(table) {
return table.length > 0
})

await exchanges.clickOnSelectTableColumns()
let table = await exchanges.getSelectableTableColumns()

assert.equal(2, table.length)
let overviewGroup = {
"name" : "Overview:",
"columns": [
{"name:":"Type","id":"checkbox-exchanges-type"},
{"name:":"Features (with policy)","id":"checkbox-exchanges-features"},
{"name:":"Features (no policy)","id":"checkbox-exchanges-features_no_policy"},
{"name:":"Policy","id":"checkbox-exchanges-policy"}
]
}
assert.equal(JSON.stringify(table[0]), JSON.stringify(overviewGroup))

let messageRatesGroup = {
"name" : "Message rates:",
"columns": [
{"name:":"rate in","id":"checkbox-exchanges-rate-in"},
{"name:":"rate out","id":"checkbox-exchanges-rate-out"}
]
}
assert.equal(JSON.stringify(table[1]), JSON.stringify(messageRatesGroup))

})


after(async function () {
await teardown(driver, this, captureScreen)
})
Expand Down
112 changes: 112 additions & 0 deletions selenium/test/mgt-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest
const {log, error} = require('./utils.js')

const baseUrl = randomly_pick_baseurl(process.env.RABBITMQ_URL || 'http://localhost:15672/')
const otherBaseUrl = randomly_pick_baseurl(process.env.OTHER_RABBITMQ_URL || 'http://localhost:15675/')
const hostname = process.env.RABBITMQ_HOSTNAME || 'localhost'
const otherHostname = process.env.OTHER_RABBITMQ_HOSTNAME || 'localhost'

function randomly_pick_baseurl (baseUrl) {
urls = baseUrl.split(",")
return urls[getRandomInt(urls.length)]
}
function getRandomInt(max) {
return Math.floor(Math.random() * max)
}

module.exports = {

getManagementUrl: () => {
return baseUrl
},

geOtherManagementUrl: () => {
return otherBaseUrl
},

setPolicy: (url, vhost, name, pattern, definition, appliedTo = "queues") => {
let policy = {
"pattern": pattern,
"apply-to": appliedTo,
"definition": definition
}
log("Setting policy " + JSON.stringify(policy)
+ " with name " + name + " for vhost " + vhost + " on "+ url)
const req = new XMLHttpRequest()
let base64Credentials = btoa('administrator-only' + ":" + 'guest')
let finalUrl = url + "/api/policies/" + encodeURIComponent(vhost) + "/" +
encodeURIComponent(name)
req.open('PUT', finalUrl, false)
req.setRequestHeader("Authorization", "Basic " + base64Credentials)
req.setRequestHeader('Content-Type', 'application/json')

req.send(JSON.stringify(policy))
if (req.status == 200 || req.status == 204 || req.status == 201) {
log("Succesfully set policy " + name)
return
}else {
error("status:" + req.status + " : " + req.responseText)
throw new Error(req.responseText)
}
},
deletePolicy: (url, vhost, name) => {
log("Deleting policy " + name + " on vhost " + vhost)
const req = new XMLHttpRequest()
let base64Credentials = btoa('administrator-only' + ":" + 'guest')
let finalUrl = url + "/api/policies/" + encodeURIComponent(vhost) + "/" +
encodeURIComponent(name)
req.open('DELETE', finalUrl, false)
req.setRequestHeader("Authorization", "Basic " + base64Credentials)

req.send()
if (req.status == 200 || req.status == 204) {
log("Succesfully deleted policy " + name)
return
}else {
error("status:" + req.status + " : " + req.responseText)
throw new Error(req.responseText)
}
},
createVhost: (url, name, description = "", tags = []) => {
let vhost = {
"description": description,
"tags": tags
}
log("Create vhost " + JSON.stringify(vhost)
+ " with name " + name + " on " + url)
const req = new XMLHttpRequest()
let base64Credentials = btoa('administrator-only' + ":" + 'guest')
let finalUrl = url + "/api/vhosts/" + encodeURIComponent(name)
req.open('PUT', finalUrl, false)
req.setRequestHeader("Authorization", "Basic " + base64Credentials)
req.setRequestHeader('Content-Type', 'application/json')

req.send(JSON.stringify(vhost))
if (req.status == 200 || req.status == 204 || req.status == 201) {
log("Succesfully created vhost " + name)
return
}else {
error("status:" + req.status + " : " + req.responseText)
throw new Error(req.responseText)
}
},
deleteVhost: (url, vhost) => {
log("Deleting vhost " + vhost)
const req = new XMLHttpRequest()
let base64Credentials = btoa('administrator-only' + ":" + 'guest')
let finalUrl = url + "/api/vhosts/" + encodeURIComponent(vhost)
req.open('DELETE', finalUrl, false)
req.setRequestHeader("Authorization", "Basic " + base64Credentials)

req.send()
if (req.status == 200 || req.status == 204) {
log("Succesfully deleted vhost " + vhost)
return
}else {
error("status:" + req.status + " : " + req.responseText)
throw new Error(req.responseText)
}
}


}
53 changes: 46 additions & 7 deletions selenium/test/pageobjects/BasePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ const EXCHANGES_TAB = By.css('div#menu ul#tabs li#exchanges')
const ADMIN_TAB = By.css('div#menu ul#tabs li#admin')
const STREAM_CONNECTIONS_TAB = By.css('div#menu ul#tabs li#stream-connections')

const FORM_POPUP = By.css('div.form-popup-warn')
const FORM_POPUP_CLOSE_BUTTON = By.css('div.form-popup-warn span')
const FORM_POPUP_WARNING = By.css('div.form-popup-warn')
const FORM_POPUP_WARNING_CLOSE_BUTTON = By.css('div.form-popup-warn span#close')

const FORM_POPUP_OPTIONS = By.css('div.form-popup-options')
const ADD_MINUS_BUTTON = By.css('div#main table.list thead tr th.plus-minus')
const TABLE_COLUMNS_POPUP = By.css('div.form-popup-options table.form')
const FORM_POPUP_OPTIONS_CLOSE_BUTTON = By.css('div.form-popup-options span#close')

module.exports = class BasePage {
driver
Expand Down Expand Up @@ -136,6 +141,7 @@ module.exports = class BasePage {
}



async getTable(tableLocator, firstNColumns, rowClass) {
const table = await this.waitForDisplayed(tableLocator)
const rows = await table.findElements(rowClass == undefined ?
Expand All @@ -145,15 +151,17 @@ module.exports = class BasePage {
let columns = await row.findElements(By.css('td'))
let table_row = []
for (let column of columns) {
if (table_row.length < firstNColumns) table_row.push(await column.getText())
if (firstNColumns == undefined || table_row.length < firstNColumns) {
table_row.push(await column.getText())
}
}
table_model.push(table_row)
}
return table_model
}
async isPopupWarningDisplayed() {
try {
let element = await driver.findElement(FORM_POPUP)
let element = await driver.findElement(FORM_POPUP_WARNING)
return element.isDisplayed()
} catch(e) {
return Promise.resolve(false)
Expand All @@ -171,7 +179,7 @@ module.exports = class BasePage {
}

async isPopupWarningNotDisplayed() {
return this.isElementNotVisible(FORM_POPUP)
return this.isElementNotVisible(FORM_POPUP_WARNING)
}

async isElementNotVisible(locator) {
Expand All @@ -191,14 +199,45 @@ module.exports = class BasePage {
}
}
async getPopupWarning() {
let element = await driver.findElement(FORM_POPUP)
let element = await driver.findElement(FORM_POPUP_WARNING)
return this.driver.wait(until.elementIsVisible(element), this.timeout,
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
this.polling).getText().then((value) => value.substring(0, value.search('\n\nClose')))
}
async closePopupWarning() {
return this.click(FORM_POPUP_CLOSE_BUTTON)
return this.click(FORM_POPUP_WARNING_CLOSE_BUTTON)
}
async clickOnSelectTableColumns() {
return this.click(ADD_MINUS_BUTTON)
}
async getSelectableTableColumns() {
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
const rows = await table.findElements(By.css('tbody tr'))
let table_model = []
for (let i = 1; i < rows.length; i++) { // skip first row
let groupNameLabel = await rows[i].findElement(By.css('th label'))
let groupName = await groupNameLabel.getText()
let columns = await rows[i].findElements(By.css('td label'))
let table_row = []
for (let column of columns) {
let checkbox = await column.findElement(By.css('input'))
table_row.push({"name:" : await column.getText(), "id" : await checkbox.getAttribute("id")})
}
let group = {"name": groupName, "columns": table_row}
table_model.push(group)
}
return table_model
}
async selectTableColumnsById(arrayOfColumnsIds) {
await this.clickOnSelectTableColumns()
const table = await this.waitForDisplayed(TABLE_COLUMNS_POPUP)
for (let id of arrayOfColumnsIds) {
let checkbox = await table.findElement(By.css('tbody tr input#'+id))
await checkbox.click()
}
await this.click(FORM_POPUP_OPTIONS_CLOSE_BUTTON)
}

async isDisplayed(locator) {
try {
let element = await driver.findElement(locator)
Expand Down
12 changes: 9 additions & 3 deletions selenium/test/pageobjects/VhostsAdminTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ const { By, Key, until, Builder } = require('selenium-webdriver')

const AdminTab = require('./AdminTab')

const MAIN_SECTION = By.css('div#main div#vhosts.section')

const SELECTED_VHOSTS_ON_RHM = By.css('div#rhs ul li a[href="#/vhosts"]')
const FILTER_VHOST = By.css('div#main div.filter input#filter')
const CHECKBOX_REGEX = By.css('div#main div.filter input#filter-regex-mode')

const VHOSTS_TABLE_ROWS = By.css('div#main table.list tbody tr')
const TABLE_SECTION = By.css('div#main div#vhosts.section table.list')

module.exports = class VhostsAdminTab extends AdminTab {
async isLoaded () {
await this.waitForDisplayed(SELECTED_VHOSTS_ON_RHM)
await this.waitForDisplayed(MAIN_SECTION)
}
async searchForVhosts(vhost, regex = false) {
await this.sendKeys(FILTER_VHOST, vhost)
await this.sendKeys(FILTER_VHOST, Key.RETURN)
//await this.sendKeys(FILTER_VHOST, Key.RETURN)
if (regex) {
await this.click(CHECKBOX_REGEX)
}
Expand All @@ -28,9 +31,12 @@ module.exports = class VhostsAdminTab extends AdminTab {
const links = await vhost_rows.findElements(By.css("td a"))
for (let link of links) {
let text = await link.getText()
if ( text === "/" ) return link.click()
if ( text === vhost ) return link.click()
}
throw "Vhost " + vhost + " not found"
}
async getVhostsTable(firstNColumns) {
return this.getTable(TABLE_SECTION, firstNColumns)
}

}
Loading
Loading