Last active
November 29, 2021 12:47
-
-
Save dumanelif/9575c6c998254812aca721136b655eb3 to your computer and use it in GitHub Desktop.
Basic Authentication Page Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { browser, by, element, protractor } from 'protractor'; | |
import { VariableComponentPage } from '../variable.page-object'; | |
import { | |
AUTH_PROVIDER_TYPE_API, | |
AUTH_PROVIDER_TYPE_DATABASE, | |
AUTH_PROVIDER_TYPE_LDAP, | |
AUTH_PROVIDER_TYPE_SECRET_MANAGER | |
} from '../../../../common/constants/prefix-name.constants'; | |
import { AuthProviderDialogPage } from '../../../../common/page-objects/auth-provider.po'; | |
const expect = chai.expect; | |
export class PolicyBasicAuthenticationComponentPage { | |
createButton = element(by.id('jh-create-entity')); | |
dropDownButtons = element.all(by.css('app-policy-basic-authentication div table .btn-sm')); | |
deleteButton = element(by.id('delete-button')); | |
editButton = element(by.id('edit-button')); | |
queryNameInput = element(by.id('basic_field_queryName')); | |
async clickOnCreateButton() { | |
await this.createButton.click(); | |
} | |
async countDropButtons() { | |
return this.dropDownButtons.count(); | |
} | |
async clickOnDropButton() { | |
await this.dropDownButtons.first().click(); | |
} | |
async clickOnDeleteButton() { | |
await this.deleteButton.click(); | |
} | |
async clickOnEditButton() { | |
await this.editButton.click(); | |
} | |
async setQueryNameInput(queryName: string) { | |
await this.queryNameInput.clear(); | |
await this.queryNameInput.sendKeys(queryName); | |
} | |
async getQueryNameInput() { | |
return this.queryNameInput.getAttribute('value'); | |
} | |
} | |
export class PolicyBasicAuthenticationUpdateComponentPage { | |
saveButtonOnNonPageMode = element(by.id('save-entity-basic-auth-policy')); | |
saveButtonOnPageMode = element(by.id('basic-auth-pageMode-save-btn')); | |
cancelButton = element(by.id('cancel-save')); | |
nameInput = element(by.id('field_name')); | |
descriptionInput = element(by.id('field_description_basic_auth_policy')); | |
clearAuthCheckbox = element(by.id('field_clearAuth')); | |
addClientInfoHeaderCheckbox = element(by.id('field_addUserToHeader')); | |
userHeaderNameInput = element(by.id('field_userHeaderName')); | |
userNameVariableSelectButton = element(by.id('basic-auth-username-select-variable')); | |
passwordVariableSelectButton = element(by.id('basic-auth-password-select-variable')); | |
identityRoleSelectButton = element(by.id('auth_service_select')); | |
conditionsButton = element(by.id('condition')); | |
errorMessageCustomizationButton = element(by.id('errorCustomization')); | |
proxiesButton = element(by.id('proxies')); | |
async setNameInput(name) { | |
await this.nameInput.sendKeys(name); | |
} | |
async getNameInput() { | |
return this.nameInput.getAttribute('value'); | |
} | |
async setDescriptionInput(description) { | |
await this.descriptionInput.sendKeys(description); | |
} | |
async getDescriptionInput() { | |
return this.descriptionInput.getAttribute('value'); | |
} | |
async setUserHeaderNameInput(userHeaderName: string) { | |
await this.userHeaderNameInput.clear(); | |
await this.userHeaderNameInput.sendKeys(userHeaderName); | |
} | |
async getUserHeaderNameInput() { | |
return this.userHeaderNameInput.getAttribute('value'); | |
} | |
async clickOnSaveButtonOnPageMode() { | |
await this.saveButtonOnPageMode.click(); | |
} | |
async clickOnSaveButtonOnNonPageMode() { | |
await this.saveButtonOnNonPageMode.click(); | |
} | |
async clickOnClearAuthCheckbox() { | |
await this.clearAuthCheckbox.sendKeys(protractor.Key.SPACE); | |
} | |
async clickOnClientInfoHeaderCheckbox() { | |
await this.addClientInfoHeaderCheckbox.sendKeys(protractor.Key.SPACE); | |
} | |
async clickOnCancelButton() { | |
await this.cancelButton.click(); | |
} | |
async clickOnUserNameVariableSelectButton() { | |
await this.userNameVariableSelectButton.click(); | |
} | |
async clickOnPasswordVariableSelectButton() { | |
await this.passwordVariableSelectButton.click(); | |
} | |
async clickOnConditionsButton() { | |
await this.conditionsButton.click(); | |
} | |
async clickOnErrorMessageCustomizationButton() { | |
await this.errorMessageCustomizationButton.click(); | |
} | |
async clickOnProxiesButton() { | |
await this.proxiesButton.click(); | |
} | |
async clickOnIdentityRoleServiceSelectButton() { | |
await this.identityRoleSelectButton.click(); | |
} | |
async fillAndSaveBasicAuthPolicyLocally( | |
name: string, | |
description: string, | |
checkedAuth: boolean, | |
switchClientInfoHeader: boolean, | |
headerName: string, | |
usernameVariableName: string, | |
passwordVariableName: string, | |
providerType: string, | |
providerDialogId: string | |
) { | |
name && (await this.setNameInput(name)); | |
description && (await this.setDescriptionInput(description)); | |
checkedAuth && (await this.clickOnClearAuthCheckbox()); | |
switchClientInfoHeader && (await this.clickOnClientInfoHeaderCheckbox()); | |
if (switchClientInfoHeader && headerName) { | |
await this.setUserHeaderNameInput(headerName); | |
expect(await this.getUserHeaderNameInput()).to.eq(headerName); | |
} | |
const variableComponentPage = new VariableComponentPage(); | |
await variableComponentPage.openAndSelectFromVariable('basic-auth-username-select-variable', usernameVariableName, 0); | |
await variableComponentPage.openAndSelectFromVariable('basic-auth-password-select-variable', passwordVariableName, 0); | |
await this.clickOnIdentityRoleServiceSelectButton(); | |
const authProviderDialogPage = new AuthProviderDialogPage(); | |
await authProviderDialogPage.selectProviderType(providerType, providerDialogId); | |
if (providerType === AUTH_PROVIDER_TYPE_SECRET_MANAGER) { | |
await authProviderDialogPage.clickOnCancelButton(providerDialogId); | |
} else if (providerType === AUTH_PROVIDER_TYPE_DATABASE) { | |
} else if (providerType === AUTH_PROVIDER_TYPE_LDAP) { | |
await authProviderDialogPage.selectLdapConnection(); | |
} else if (providerType === AUTH_PROVIDER_TYPE_API) { | |
await authProviderDialogPage.selectFirstApiAuth(); | |
} | |
await browser.executeScript('window.scrollTo(0,0);'); | |
await this.clickOnSaveButtonOnNonPageMode(); | |
} | |
} | |
export class PolicyBasicAuthenticationDeleteDialogComponentPage { | |
private dialogTitle = element(by.id('delete-dialog-title')); | |
private confirmButton = element(by.id('delete-dialog-confirm')); | |
async getDialogTitle() { | |
return this.dialogTitle.getAttribute('jhiTranslate'); | |
} | |
async clickOnConfirmButton() { | |
await this.confirmButton.click(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment