2021-03-05 20:55:01 +00:00
|
|
|
export default class ProviderPage {
|
2021-05-06 08:38:45 +00:00
|
|
|
// KerberosSettingsRequired required input values
|
|
|
|
private kerberosNameInput = "data-testid=kerberos-name";
|
|
|
|
private kerberosRealmInput = "data-testid=kerberos-realm";
|
|
|
|
private kerberosPrincipalInput = "data-testid=kerberos-principal";
|
|
|
|
private kerberosKeytabInput = "data-testid=kerberos-keytab";
|
|
|
|
|
|
|
|
// LdapSettingsGeneral required input values
|
|
|
|
private ldapNameInput = "data-testid=ldap-name";
|
|
|
|
private ldapVendorInput = "#kc-vendor";
|
|
|
|
private ldapVendorList = "#kc-vendor + ul";
|
|
|
|
|
|
|
|
// LdapSettingsConnection required input values
|
|
|
|
private ldapConnectionUrlInput = "data-testid=ldap-connection-url";
|
|
|
|
private ldapBindTypeInput = "#kc-bind-type";
|
|
|
|
private ldapBindTypeList = "#kc-bind-type + ul";
|
|
|
|
private ldapBindDnInput = "data-testid=ldap-bind-dn";
|
|
|
|
private ldapBindCredsInput = "data-testid=ldap-bind-credentials";
|
|
|
|
|
|
|
|
// LdapSettingsSearching required input values
|
|
|
|
private ldapUsersDnInput = "data-testid=ldap-users-dn";
|
|
|
|
private ldapUserLdapAttInput = "data-testid=ldap-username-attribute";
|
|
|
|
private ldapRdnLdapAttInput = "data-testid=ldap-rdn-attribute";
|
|
|
|
private ldapUuidLdapAttInput = "data-testid=ldap-uuid-attribute";
|
|
|
|
private ldapUserObjClassesInput = "data-testid=ldap-user-object-classes";
|
|
|
|
|
|
|
|
// SettingsCache input values
|
|
|
|
private cacheDayInput = "#kc-eviction-day";
|
|
|
|
private cacheDayList = "#kc-eviction-day + ul";
|
|
|
|
private cacheHourInput = "#kc-eviction-hour";
|
|
|
|
private cacheHourList = "#kc-eviction-hour + ul";
|
|
|
|
private cacheMinuteInput = "#kc-eviction-minute";
|
|
|
|
private cacheMinuteList = "#kc-eviction-minute + ul";
|
|
|
|
private cachePolicyInput = "#kc-cache-policy";
|
|
|
|
private cachePolicyList = "#kc-cache-policy + ul";
|
|
|
|
|
|
|
|
// Mapper required input values
|
|
|
|
private userModelAttInput = "data-testid=mapper-userModelAttribute-fld";
|
|
|
|
private ldapAttInput = "data-testid=mapper-ldapAttribute-fld";
|
|
|
|
private userModelAttNameInput =
|
|
|
|
"data-testid=mapper-userModelAttributeName-fld";
|
|
|
|
private attValueInput = "data-testid=mapper-attributeValue-fld";
|
|
|
|
private ldapFullNameAttInput = "data-testid=mapper-fullNameAttribute-fld";
|
|
|
|
private ldapAttNameInput = "data-testid=mapper-ldapAttributeName-fld";
|
|
|
|
private ldapAttValueInput = "data-testid=mapper-ldapAttributeValue-fld";
|
|
|
|
private groupInput = "data-testid=mapper-group-fld";
|
2021-06-03 20:47:47 +00:00
|
|
|
private ldapDnInput = "data-testid=ldap-dn";
|
2021-05-06 08:38:45 +00:00
|
|
|
|
|
|
|
// mapper types
|
|
|
|
private msadUserAcctMapper = "msad-user-account-control-mapper";
|
|
|
|
private msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper";
|
|
|
|
private userAttLdapMapper = "user-attribute-ldap-mapper";
|
|
|
|
private hcAttMapper = "hardcoded-attribute-mapper";
|
|
|
|
private certLdapMapper = "certificate-ldap-mapper";
|
|
|
|
private fullNameLdapMapper = "full-name-ldap-mapper";
|
|
|
|
private hcLdapAttMapper = "hardcoded-ldap-attribute-mapper";
|
|
|
|
private hcLdapGroupMapper = "hardcoded-ldap-group-mapper";
|
2021-06-03 20:47:47 +00:00
|
|
|
private groupLdapMapper = "group-ldap-mapper";
|
2021-06-04 16:33:38 +00:00
|
|
|
private roleLdapMapper = "role-ldap-mapper";
|
|
|
|
private hcLdapRoleMapper = "hardcoded-ldap-role-mapper";
|
|
|
|
|
|
|
|
private tab = "#pf-tab-serviceAccount-serviceAccount";
|
|
|
|
private scopeTab = "scopeTab";
|
|
|
|
private assignRole = "assignRole";
|
|
|
|
private unAssign = "unAssignRole";
|
|
|
|
private assign = "assign";
|
|
|
|
private hide = "#hideInheritedRoles";
|
|
|
|
private assignedRolesTable = "assigned-roles";
|
|
|
|
private namesColumn = 'td[data-label="Name"]:visible';
|
|
|
|
|
|
|
|
private rolesTab = "#pf-tab-roles-roles";
|
2021-06-16 11:35:03 +00:00
|
|
|
private createRoleBtn = "data-testid=no-roles-for-this-client-empty-action";
|
2021-06-04 16:33:38 +00:00
|
|
|
private realmRolesSaveBtn = "data-testid=realm-roles-save-button";
|
|
|
|
private roleNameField = "#kc-name";
|
|
|
|
private clientIdSelect = "#kc-client-id";
|
2021-05-06 08:38:45 +00:00
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
private groupName = "aa-uf-mappers-group";
|
2021-06-04 16:33:38 +00:00
|
|
|
private clientName = "aa-uf-mappers-client";
|
|
|
|
private roleName = "aa-uf-mappers-role";
|
2021-02-23 20:49:57 +00:00
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
changeCacheTime(unit: string, time: string) {
|
|
|
|
switch (unit) {
|
|
|
|
case "day":
|
|
|
|
cy.get(this.cacheDayInput).click();
|
|
|
|
cy.get(this.cacheDayList).contains(time).click();
|
|
|
|
break;
|
|
|
|
case "hour":
|
|
|
|
cy.get(this.cacheHourInput).click();
|
|
|
|
cy.get(this.cacheHourList).contains(time).click();
|
|
|
|
break;
|
|
|
|
case "minute":
|
|
|
|
cy.get(this.cacheMinuteInput).click();
|
|
|
|
cy.get(this.cacheMinuteList).contains(time).click();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log("Invalid cache time, must be 'day', 'hour', or 'minute'.");
|
|
|
|
break;
|
|
|
|
}
|
2021-03-02 15:23:21 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteCardFromCard(card: string) {
|
|
|
|
cy.get(`[data-testid=${card}-dropdown]`).click();
|
|
|
|
cy.get('[data-testid="card-delete"]').click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
deleteCardFromMenu(providerType: string, card: string) {
|
2021-03-02 15:23:21 +00:00
|
|
|
this.clickExistingCard(card);
|
|
|
|
cy.get('[data-testid="action-dropdown"]').click();
|
2021-03-05 20:55:01 +00:00
|
|
|
cy.get(`[data-testid="delete-${providerType}-cmd"]`).click();
|
|
|
|
return this;
|
|
|
|
}
|
2021-04-28 05:50:41 +00:00
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
fillKerberosRequiredData(
|
|
|
|
name: string,
|
|
|
|
realm: string,
|
|
|
|
principal: string,
|
|
|
|
keytab: string
|
|
|
|
) {
|
|
|
|
if (name) {
|
|
|
|
cy.get(`[${this.kerberosNameInput}]`).type(name);
|
|
|
|
}
|
|
|
|
if (realm) {
|
|
|
|
cy.get(`[${this.kerberosRealmInput}]`).type(realm);
|
|
|
|
}
|
|
|
|
if (principal) {
|
|
|
|
cy.get(`[${this.kerberosPrincipalInput}]`).type(principal);
|
|
|
|
}
|
|
|
|
if (keytab) {
|
|
|
|
cy.get(`[${this.kerberosKeytabInput}]`).type(keytab);
|
|
|
|
}
|
2021-03-02 15:23:21 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-01 21:56:26 +00:00
|
|
|
fillLdapRequiredGeneralData(name: string, vendor: string) {
|
2021-02-23 20:49:57 +00:00
|
|
|
if (name) {
|
2021-05-07 07:45:42 +00:00
|
|
|
cy.get(`[${this.ldapNameInput}]`).clear().type(name);
|
2021-02-23 20:49:57 +00:00
|
|
|
}
|
|
|
|
if (vendor) {
|
|
|
|
cy.get(this.ldapVendorInput).click();
|
|
|
|
cy.get(this.ldapVendorList).contains(vendor).click();
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
fillLdapRequiredConnectionData(
|
|
|
|
connectionUrl: string,
|
|
|
|
bindType: string,
|
2021-05-14 19:44:45 +00:00
|
|
|
bindDn?: string,
|
|
|
|
bindCreds?: string
|
2021-02-23 20:49:57 +00:00
|
|
|
) {
|
|
|
|
if (connectionUrl) {
|
|
|
|
cy.get(`[${this.ldapConnectionUrlInput}]`).type(connectionUrl);
|
|
|
|
}
|
|
|
|
if (bindType) {
|
|
|
|
cy.get(this.ldapBindTypeInput).click();
|
|
|
|
cy.get(this.ldapBindTypeList).contains(bindType).click();
|
|
|
|
}
|
|
|
|
if (bindDn) {
|
|
|
|
cy.get(`[${this.ldapBindDnInput}]`).type(bindDn);
|
|
|
|
}
|
|
|
|
if (bindCreds) {
|
|
|
|
cy.get(`[${this.ldapBindCredsInput}]`).type(bindCreds);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
fillLdapRequiredSearchingData(
|
|
|
|
usersDn: string,
|
|
|
|
userLdapAtt: string,
|
|
|
|
rdnLdapAtt: string,
|
|
|
|
uuidLdapAtt: string,
|
|
|
|
userObjClasses: string
|
|
|
|
) {
|
|
|
|
if (usersDn) {
|
|
|
|
cy.get(`[${this.ldapUsersDnInput}]`).type(usersDn);
|
|
|
|
}
|
|
|
|
if (userLdapAtt) {
|
|
|
|
cy.get(`[${this.ldapUserLdapAttInput}]`).type(userLdapAtt);
|
|
|
|
}
|
|
|
|
if (rdnLdapAtt) {
|
|
|
|
cy.get(`[${this.ldapRdnLdapAttInput}]`).type(rdnLdapAtt);
|
|
|
|
}
|
|
|
|
if (uuidLdapAtt) {
|
|
|
|
cy.get(`[${this.ldapUuidLdapAttInput}]`).type(uuidLdapAtt);
|
|
|
|
}
|
|
|
|
if (userObjClasses) {
|
|
|
|
cy.get(`[${this.ldapUserObjClassesInput}]`).type(userObjClasses);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectCacheType(cacheType: string) {
|
2021-03-05 20:55:01 +00:00
|
|
|
cy.get(this.cachePolicyInput).click();
|
|
|
|
cy.get(this.cachePolicyList).contains(cacheType).click();
|
2021-02-23 20:49:57 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-04-28 05:50:41 +00:00
|
|
|
goToMappers() {
|
|
|
|
cy.get(`[data-testid="ldap-mappers-tab"]`).click();
|
|
|
|
}
|
|
|
|
|
2021-06-04 16:33:38 +00:00
|
|
|
createRole(roleName: string) {
|
|
|
|
cy.get(this.rolesTab).click();
|
|
|
|
cy.wait(1000);
|
|
|
|
cy.get(`[${this.createRoleBtn}]`).click();
|
|
|
|
cy.wait(1000);
|
|
|
|
cy.get(this.roleNameField).type(roleName);
|
|
|
|
cy.wait(1000);
|
|
|
|
cy.get(`[${this.realmRolesSaveBtn}]`).click();
|
|
|
|
cy.wait(1000);
|
|
|
|
}
|
|
|
|
|
2021-04-28 05:50:41 +00:00
|
|
|
createNewMapper(mapperType: string) {
|
|
|
|
const userModelAttValue = "firstName";
|
|
|
|
const ldapAttValue = "cn";
|
2021-06-04 16:33:38 +00:00
|
|
|
const ldapDnValue = "ou=groups";
|
2021-04-28 05:50:41 +00:00
|
|
|
|
2021-06-16 11:35:03 +00:00
|
|
|
cy.contains("Add").click();
|
2021-04-28 05:50:41 +00:00
|
|
|
cy.wait(1000);
|
|
|
|
|
|
|
|
cy.get("#kc-providerId").click();
|
2021-06-16 14:16:46 +00:00
|
|
|
cy.get("button").contains(mapperType).click();
|
2021-04-28 05:50:41 +00:00
|
|
|
|
|
|
|
cy.get(`[data-testid="ldap-mapper-name"]`).type(`${mapperType}-test`);
|
|
|
|
|
|
|
|
switch (mapperType) {
|
|
|
|
case this.msadUserAcctMapper:
|
|
|
|
case this.msadLdsUserAcctMapper:
|
|
|
|
break;
|
|
|
|
case this.userAttLdapMapper:
|
|
|
|
case this.certLdapMapper:
|
|
|
|
cy.get(`[${this.userModelAttInput}]`).type(userModelAttValue);
|
|
|
|
cy.get(`[${this.ldapAttInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.hcAttMapper:
|
|
|
|
cy.get(`[${this.userModelAttNameInput}]`).type(userModelAttValue);
|
|
|
|
cy.get(`[${this.attValueInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.fullNameLdapMapper:
|
|
|
|
cy.get(`[${this.ldapFullNameAttInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.hcLdapAttMapper:
|
|
|
|
cy.get(`[${this.ldapAttNameInput}]`).type(userModelAttValue);
|
|
|
|
cy.get(`[${this.ldapAttValueInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.hcLdapGroupMapper:
|
|
|
|
cy.get(`[${this.groupInput}]`).type(this.groupName);
|
|
|
|
break;
|
2021-06-03 20:47:47 +00:00
|
|
|
case this.groupLdapMapper:
|
|
|
|
cy.get(`[${this.ldapDnInput}]`).type(ldapDnValue);
|
|
|
|
break;
|
2021-06-04 16:33:38 +00:00
|
|
|
|
|
|
|
case this.roleLdapMapper:
|
|
|
|
cy.get(`[${this.ldapDnInput}]`).type(ldapDnValue);
|
|
|
|
// cy select clientID dropdown and choose clientName (var)
|
|
|
|
cy.get(this.clientIdSelect).click();
|
|
|
|
cy.get("button").contains(this.clientName).click({ force: true });
|
|
|
|
break;
|
|
|
|
|
|
|
|
case this.hcLdapRoleMapper:
|
|
|
|
cy.get(`[data-testid="selectRole"]`).click();
|
|
|
|
cy.wait(2000);
|
|
|
|
cy.get(this.namesColumn)
|
|
|
|
.contains(this.clientName)
|
|
|
|
.parent()
|
|
|
|
.parent()
|
|
|
|
.within(() => {
|
|
|
|
cy.get('input[name="radioGroup"]').click();
|
|
|
|
});
|
|
|
|
cy.getId(this.assign).click();
|
|
|
|
break;
|
2021-04-28 05:50:41 +00:00
|
|
|
default:
|
|
|
|
console.log("Invalid mapper type.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateMapper(mapperType: string) {
|
|
|
|
const userModelAttValue = "lastName";
|
|
|
|
const ldapAttValue = "sn";
|
|
|
|
|
|
|
|
switch (mapperType) {
|
|
|
|
case this.msadUserAcctMapper:
|
|
|
|
case this.msadLdsUserAcctMapper:
|
|
|
|
break;
|
|
|
|
case this.userAttLdapMapper:
|
|
|
|
case this.certLdapMapper:
|
|
|
|
cy.get(`[${this.userModelAttInput}]`).clear();
|
|
|
|
cy.get(`[${this.userModelAttInput}]`).type(userModelAttValue);
|
|
|
|
cy.get(`[${this.ldapAttInput}]`).clear();
|
|
|
|
cy.get(`[${this.ldapAttInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.hcAttMapper:
|
|
|
|
cy.get(`[${this.userModelAttNameInput}]`).clear();
|
|
|
|
cy.get(`[${this.userModelAttNameInput}]`).type(userModelAttValue);
|
|
|
|
cy.get(`[${this.attValueInput}]`).clear();
|
|
|
|
cy.get(`[${this.attValueInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.fullNameLdapMapper:
|
|
|
|
cy.get(`[${this.ldapFullNameAttInput}]`).clear();
|
|
|
|
cy.get(`[${this.ldapFullNameAttInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
case this.hcLdapAttMapper:
|
|
|
|
cy.get(`[${this.ldapAttNameInput}]`).clear();
|
|
|
|
cy.get(`[${this.ldapAttNameInput}]`).type(userModelAttValue);
|
|
|
|
cy.get(`[${this.ldapAttValueInput}]`).clear;
|
|
|
|
cy.get(`[${this.ldapAttValueInput}]`).type(ldapAttValue);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log("Invalid mapper name.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 15:23:21 +00:00
|
|
|
clickExistingCard(cardName: string) {
|
2021-03-01 21:56:26 +00:00
|
|
|
cy.get('[data-testid="keycloak-card-title"]').contains(cardName).click();
|
|
|
|
cy.wait(1000);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-02 15:23:21 +00:00
|
|
|
clickMenuCommand(menu: string, command: string) {
|
|
|
|
cy.contains("button", menu).click();
|
|
|
|
cy.contains("li", command).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
clickNewCard(providerType: string) {
|
|
|
|
cy.get(`[data-testid=${providerType}-card]`).click();
|
|
|
|
cy.wait(1000);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
disableEnabledSwitch(providerType: string) {
|
|
|
|
cy.get(`#${providerType}-switch`).uncheck({ force: true });
|
2021-03-01 21:56:26 +00:00
|
|
|
return this;
|
2021-02-23 20:49:57 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
enableEnabledSwitch(providerType: string) {
|
|
|
|
cy.get(`#${providerType}-switch`).check({ force: true });
|
2021-03-01 21:56:26 +00:00
|
|
|
return this;
|
2021-02-23 20:49:57 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
save(providerType: string) {
|
|
|
|
cy.get(`[data-testid=${providerType}-save]`).click();
|
2021-02-23 20:49:57 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
cancel(providerType: string) {
|
|
|
|
cy.get(`[data-testid=${providerType}-cancel]`).click();
|
2021-02-23 20:49:57 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|