Fix unauthorized.js test

This commit is contained in:
Marcial Rosales 2024-01-28 12:02:15 +01:00
parent 16bdeff55a
commit d69fc0e8b9
4 changed files with 21 additions and 21 deletions

View File

@ -19,6 +19,8 @@ auth_oauth2.resource_servers.1.id = rabbit_prod
auth_oauth2.resource_servers.1.oauth_provider_id = prodkeycloak auth_oauth2.resource_servers.1.oauth_provider_id = prodkeycloak
auth_oauth2.resource_servers.2.id = rabbit_dev auth_oauth2.resource_servers.2.id = rabbit_dev
auth_oauth2.resource_servers.2.oauth_provider_id = devkeycloak auth_oauth2.resource_servers.2.oauth_provider_id = devkeycloak
auth_oauth2.resource_servers.3.id = rabbit_internal
auth_oauth2.resource_servers.3.oauth_provider_id = devkeycloak
## Oauth providers ## Oauth providers
auth_oauth2.oauth_providers.devkeycloak.issuer = ${DEVKEYCLOAK_URL} auth_oauth2.oauth_providers.devkeycloak.issuer = ${DEVKEYCLOAK_URL}
@ -45,3 +47,6 @@ management.oauth_resource_servers.2.id = rabbit_dev
management.oauth_resource_servers.2.oauth_client_id = rabbit_dev_mgt_ui management.oauth_resource_servers.2.oauth_client_id = rabbit_dev_mgt_ui
management.oauth_resource_servers.2.label = RabbitMQ Development management.oauth_resource_servers.2.label = RabbitMQ Development
management.oauth_resource_servers.2.oauth_scopes = openid profile rabbitmq.tag:management management.oauth_resource_servers.2.oauth_scopes = openid profile rabbitmq.tag:management
management.oauth_resource_servers.3.id = rabbit_internal
management.oauth_resource_servers.3.disabled = true

View File

@ -18,7 +18,8 @@ describe('A user which accesses any protected URL without a session where basic
}) })
it('should be presented with a login button to log in using OAuth 2.0', async function () { it('should be presented with a login button to log in using OAuth 2.0', async function () {
assert.ok(await homePage.isOAuth2SectionVisible()) assert.ok(await homePage.getOAuth2Section())
console.log("had oauth section")
assert.equal(await homePage.getLoginButton(), 'Click here to log in') assert.equal(await homePage.getLoginButton(), 'Click here to log in')
}) })

View File

@ -133,12 +133,13 @@ module.exports = class BasePage {
} }
async isDisplayed(locator) { async isDisplayed(locator) {
try { try {
element = await this.driver.findElement(locator) return this.driver.wait(until.elementIsVisible(element), this.timeout / 2,
return Promise.resolve(element.isDisplayed()) 'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
}catch(e) { this.polling / 2)
return Promise.resolve(false) }catch(error) {
} return Promise.resolve(false)
}
} }
async waitForLocated (locator) { async waitForLocated (locator) {
@ -163,6 +164,7 @@ module.exports = class BasePage {
} }
} }
async waitForDisplayed (locator) { async waitForDisplayed (locator) {
return this.waitForVisible(await this.waitForLocated(locator)) return this.waitForVisible(await this.waitForLocated(locator))
} }

View File

@ -69,22 +69,14 @@ module.exports = class SSOHomePage extends BasePage {
} }
async isOAuth2SectionVisible() { async isOAuth2SectionVisible() {
//return this.isDisplayed(SECTION_LOGIN_WITH_OAUTH) return this.isDisplayed(SECTION_LOGIN_WITH_OAUTH)
try { }
await this.waitForDisplayed(SECTION_LOGIN_WITH_OAUTH) async getOAuth2Section() {
return Promise.resolve(true) await this.waitForDisplayed(SECTION_LOGIN_WITH_OAUTH)
} catch (e) {
return Promise.resolve(false)
}
} }
async isBasicAuthSectionVisible() { async isBasicAuthSectionVisible() {
//return this.isDisplayed(SECTION_LOGIN_WITH_BASIC_AUTH) return this.isDisplayed(SECTION_LOGIN_WITH_BASIC_AUTH)
try {
await this.waitForDisplayed(SECTION_LOGIN_WITH_BASIC_AUTH)
return Promise.resolve(true)
} catch (e) {
return Promise.resolve(false)
}
} }
async toggleBasicAuthSection() { async toggleBasicAuthSection() {
await this.click(SECTION_LOGIN_WITH_BASIC_AUTH) await this.click(SECTION_LOGIN_WITH_BASIC_AUTH)