Adds LDAP connection and general tests (#2376)

This commit is contained in:
mfrances17 2022-04-05 15:33:51 -04:00 committed by GitHub
parent 2c53947331
commit ef9d0ca822
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 305 additions and 143 deletions

View file

@ -24,12 +24,16 @@ const allCapProvider = provider.toUpperCase();
const ldapName = "ldap-mappers-testing";
const ldapVendor = "Active Directory";
const connectionUrl = "ldap://";
const firstBindType = "simple";
const firstBindDn = "user-1";
const firstBindCreds = "password1";
// connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389";
const bindTypeSimple = "simple";
const truststoreSpiOnlyLdaps = "Only for ldaps";
const connectionTimeoutTwoSecs = "2000";
const bindDnCnDc = "cn=read-only-admin,dc=example,dc=com";
const bindCredsValid = "password";
const firstEditMode = "READ_ONLY";
// ldap searching and updating
const editModeReadOnly = "READ_ONLY";
const firstUsersDn = "user-dn-1";
const firstUserLdapAtt = "uid";
const firstRdnLdapAtt = "uid";
@ -83,15 +87,20 @@ describe("User Fed LDAP mapper tests", () => {
providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
}
});
providersPage.fillLdapRequiredGeneralData(ldapName, ldapVendor);
providersPage.fillLdapRequiredConnectionData(
connectionUrl,
firstBindType,
firstBindDn,
firstBindCreds
providersPage.fillLdapGeneralData(ldapName, ldapVendor);
providersPage.fillLdapConnectionData(
connectionUrlValid,
bindTypeSimple,
truststoreSpiOnlyLdaps,
connectionTimeoutTwoSecs,
bindDnCnDc,
bindCredsValid
);
providersPage.fillLdapRequiredSearchingData(
firstEditMode,
providersPage.toggleSwitch(providersPage.enableStartTls);
providersPage.toggleSwitch(providersPage.connectionPooling);
providersPage.fillLdapSearchingData(
editModeReadOnly,
firstUsersDn,
firstUserLdapAtt,
firstRdnLdapAtt,

View file

@ -20,12 +20,16 @@ const allCapProvider = provider.toUpperCase();
const ldapName = "ldap-mappers-testing";
const ldapVendor = "Active Directory";
const connectionUrl = "ldap://";
const firstBindType = "simple";
const firstBindDn = "user-1";
const firstBindCreds = "password1";
// connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389";
const bindTypeSimple = "simple";
const truststoreSpiOnlyLdaps = "Only for ldaps";
const connectionTimeoutTwoSecs = "2000";
const bindDnCnDc = "cn=read-only-admin,dc=example,dc=com";
const bindCredsValid = "password";
const firstEditMode = "READ_ONLY";
// ldap searching and updating
const editModeReadOnly = "READ_ONLY";
const firstUsersDn = "user-dn-1";
const firstUserLdapAtt = "uid";
const firstRdnLdapAtt = "uid";
@ -88,15 +92,20 @@ describe("User Fed LDAP mapper tests", () => {
providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
}
});
providersPage.fillLdapRequiredGeneralData(ldapName, ldapVendor);
providersPage.fillLdapRequiredConnectionData(
connectionUrl,
firstBindType,
firstBindDn,
firstBindCreds
providersPage.fillLdapGeneralData(ldapName, ldapVendor);
providersPage.fillLdapConnectionData(
connectionUrlValid,
bindTypeSimple,
truststoreSpiOnlyLdaps,
connectionTimeoutTwoSecs,
bindDnCnDc,
bindCredsValid
);
providersPage.fillLdapRequiredSearchingData(
firstEditMode,
providersPage.toggleSwitch(providersPage.enableStartTls);
providersPage.toggleSwitch(providersPage.connectionPooling);
providersPage.fillLdapSearchingData(
editModeReadOnly,
firstUsersDn,
firstUserLdapAtt,
firstRdnLdapAtt,

View file

@ -17,12 +17,22 @@ const allCapProvider = provider.toUpperCase();
const firstLdapName = "my-ldap";
const firstLdapVendor = "Active Directory";
const connectionUrl = "ldap://";
const firstBindType = "simple";
const firstBindDn = "user-1";
const firstBindCreds = "password1";
// connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389";
const bindTypeSimple = "simple";
const truststoreSpiOnlyLdaps = "Only for ldaps";
const connectionTimeoutTwoSecs = "2000";
const bindDnCnDc = "cn=read-only-admin,dc=example,dc=com";
const bindCredsValid = "password";
const firstEditMode = "READ_ONLY";
const connectionUrlInvalid = "ldap://nowhere.com";
const bindTypeNone = "none";
const truststoreSpiNever = "Never";
const bindDnCnOnly = "cn=read-only-admin";
const bindCredsInvalid = "not-my-password";
// ldap searching and updating
const editModeReadOnly = "READ_ONLY";
const firstUsersDn = "user-dn-1";
const firstUserLdapAtt = "uid";
const firstRdnLdapAtt = "uid";
@ -32,15 +42,16 @@ const firstUserObjClasses = "inetOrgPerson, organizationalPerson";
const secondLdapName = `${firstLdapName}-2`;
const secondLdapVendor = "Other";
const secondBindType = "none";
const editModeWritable = "WRITABLE";
const secondEditMode = "WRITABLE";
const secondUsersDn = "user-dn-2";
const secondUserLdapAtt = "cn";
const secondRdnLdapAtt = "cn";
const secondUuidLdapAtt = "objectGUID";
const secondUserObjClasses = "person, organizationalPerson, user";
const updatedLdapName = `${firstLdapName}-updated`;
const defaultPolicy = "DEFAULT";
const newPolicy = "EVICT_WEEKLY";
const defaultLdapDay = "Sunday";
@ -57,11 +68,16 @@ const deletedSuccessMessage = "The user federation provider has been deleted.";
const deleteModalTitle = "Delete user federation provider?";
const disableModalTitle = "Disable user federation provider?";
const ldapTestSuccessMsg = "Successfully connected to LDAP";
const ldapTestFailMsg =
"Error when trying to connect to LDAP. See server.log for details. LDAP test error";
describe("User Fed LDAP tests", () => {
beforeEach(() => {
keycloakBefore();
loginPage.logIn();
sidebarPage.goToUserFederation();
cy.intercept("GET", "/admin/realms/master").as("getProvider");
});
it("Create Ldap provider from empty state", () => {
@ -74,24 +90,24 @@ describe("User Fed LDAP tests", () => {
providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
}
});
providersPage.fillLdapRequiredGeneralData(firstLdapName, firstLdapVendor);
providersPage.fillLdapRequiredConnectionData(
connectionUrl,
firstBindType,
firstBindDn,
firstBindCreds
providersPage.fillLdapGeneralData(firstLdapName, firstLdapVendor);
providersPage.fillLdapConnectionData(
connectionUrlInvalid,
bindTypeSimple,
truststoreSpiNever,
connectionTimeoutTwoSecs,
bindDnCnOnly,
bindCredsInvalid
);
providersPage.fillLdapRequiredSearchingData(
firstEditMode,
providersPage.fillLdapSearchingData(
editModeReadOnly,
firstUsersDn,
firstUserLdapAtt,
firstRdnLdapAtt,
firstUuidLdapAtt,
firstUserObjClasses
);
providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage);
sidebarPage.goToUserFederation();
});
@ -114,8 +130,94 @@ describe("User Fed LDAP tests", () => {
expect(cy.contains(defaultPolicy).should("not.exist"));
});
it("Change existing LDAP provider and click button to cancel", () => {
it("Update connection and authentication settings and save", () => {
providersPage.clickExistingCard(firstLdapName);
providersPage.fillLdapConnectionData(
connectionUrlInvalid,
bindTypeNone,
truststoreSpiNever,
connectionTimeoutTwoSecs
);
providersPage.toggleSwitch(providersPage.enableStartTls);
providersPage.toggleSwitch(providersPage.connectionPooling);
providersPage.save(provider);
masthead.checkNotificationMessage(savedSuccessMessage);
// now verify
sidebarPage.goToUserFederation();
providersPage.clickExistingCard(firstLdapName);
providersPage.verifyTextField(
providersPage.connectionUrlInput,
connectionUrlInvalid
);
providersPage.verifyTextField(
providersPage.connectionTimeoutInput,
connectionTimeoutTwoSecs
);
providersPage.verifySelect(
providersPage.truststoreSpiInput,
truststoreSpiNever
);
providersPage.verifySelect(providersPage.bindTypeInput, bindTypeNone);
providersPage.verifyToggle(providersPage.enableStartTls, "on");
providersPage.verifyToggle(providersPage.connectionPooling, "on");
sidebarPage.goToUserFederation();
});
it("Should fail connection and authentication tests", () => {
providersPage.clickExistingCard(firstLdapName);
providersPage.testConnection();
masthead.checkNotificationMessage(ldapTestFailMsg);
providersPage.testAuthorization();
masthead.checkNotificationMessage(ldapTestFailMsg);
sidebarPage.goToUserFederation();
});
it("Should make changes and pass connection and authentication tests", () => {
providersPage.clickExistingCard(firstLdapName);
providersPage.fillLdapConnectionData(
connectionUrlValid,
bindTypeSimple,
truststoreSpiOnlyLdaps,
connectionTimeoutTwoSecs,
bindDnCnDc,
bindCredsValid
);
providersPage.toggleSwitch(providersPage.enableStartTls);
providersPage.toggleSwitch(providersPage.connectionPooling);
providersPage.save(provider);
providersPage.testConnection();
masthead.checkNotificationMessage(ldapTestSuccessMsg);
providersPage.testAuthorization();
masthead.checkNotificationMessage(ldapTestSuccessMsg);
sidebarPage.goToUserFederation();
});
it("Should update display name", () => {
providersPage.clickExistingCard(firstLdapName);
providersPage.fillLdapGeneralData(updatedLdapName);
providersPage.save(provider);
masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation();
providersPage.clickExistingCard(updatedLdapName);
sidebarPage.goToUserFederation();
});
it("Change existing LDAP provider and click button to cancel", () => {
providersPage.clickExistingCard(updatedLdapName);
providersPage.selectCacheType(newPolicy);
providersPage.changeCacheTime("day", defaultLdapDay);
@ -123,9 +225,8 @@ describe("User Fed LDAP tests", () => {
providersPage.changeCacheTime("minute", defaultLdapMinute);
providersPage.cancel(provider);
cy.wait(1000);
providersPage.clickExistingCard(firstLdapName);
providersPage.clickExistingCard(updatedLdapName);
providersPage.selectCacheType(newPolicy);
providersPage.verifyChangedHourInput(newLdapHour, defaultLdapHour);
@ -133,36 +234,38 @@ describe("User Fed LDAP tests", () => {
sidebarPage.goToUserFederation();
});
it("Disable an existing LDAP provider", () => {
it("Should disable an existing LDAP provider", () => {
providersPage.clickExistingCard(firstLdapName);
cy.wait("@getProvider");
providersPage.disableEnabledSwitch(allCapProvider);
modalUtils.checkModalTitle(disableModalTitle).confirmModal();
masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation();
masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation();
expect(cy.contains("Disabled").should("exist"));
});
it("Enable an existing previously-disabled LDAP provider", () => {
it("Should enable a previously-disabled LDAP provider", () => {
providersPage.clickExistingCard(firstLdapName);
cy.wait("@getProvider");
providersPage.enableEnabledSwitch(allCapProvider);
masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation();
expect(cy.contains("Enabled").should("exist"));
});
it("Create new LDAP provider using the New Provider dropdown", () => {
providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
providersPage.fillLdapRequiredGeneralData(secondLdapName, secondLdapVendor);
providersPage.fillLdapRequiredConnectionData(connectionUrl, secondBindType);
providersPage.fillLdapRequiredSearchingData(
secondEditMode,
providersPage.fillLdapGeneralData(secondLdapName, secondLdapVendor);
providersPage.fillLdapConnectionData(
connectionUrlValid,
bindTypeSimple,
truststoreSpiNever,
connectionTimeoutTwoSecs,
bindDnCnOnly,
bindCredsInvalid
);
providersPage.fillLdapSearchingData(
editModeWritable,
secondUsersDn,
secondUserLdapAtt,
secondRdnLdapAtt,
@ -181,7 +284,7 @@ describe("User Fed LDAP tests", () => {
});
it("Delete an LDAP provider using the Settings view's Action menu", () => {
providersPage.deleteCardFromMenu(firstLdapName);
providersPage.deleteCardFromMenu(updatedLdapName);
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
masthead.checkNotificationMessage(deletedSuccessMessage);
});

View file

@ -1,30 +1,35 @@
export default class ProviderPage {
// 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";
// KerberosSettingsRequired input values
private kerberosNameInput = "kerberos-name";
private kerberosRealmInput = "kerberos-realm";
private kerberosPrincipalInput = "kerberos-principal";
private kerberosKeytabInput = "kerberos-keytab";
// LdapSettingsGeneral required input values
private ldapNameInput = "data-testid=ldap-name";
// LdapSettingsGeneral input values
private ldapNameInput = "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";
// LdapSettingsConnection input values
connectionUrlInput = "ldap-connection-url";
truststoreSpiInput = "#kc-use-truststore-spi";
truststoreSpiList = "#kc-use-truststore-spi + ul";
connectionTimeoutInput = "connection-timeout";
bindTypeInput = "#kc-bind-type";
private bindTypeList = "#kc-bind-type + ul";
bindDnInput = "ldap-bind-dn";
bindCredsInput = "ldap-bind-credentials";
private testConnectionBtn = "test-connection-button";
private testAuthBtn = "test-auth-button";
// LdapSettingsSearching required input values
// LdapSettingsSearching input values
private ldapEditModeInput = "#kc-edit-mode";
private ldapEditModeList = "#kc-edit-mode + ul";
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";
private ldapUsersDnInput = "ldap-users-dn";
private ldapUserLdapAttInput = "ldap-username-attribute";
private ldapRdnLdapAttInput = "ldap-rdn-attribute";
private ldapUuidLdapAttInput = "ldap-uuid-attribute";
private ldapUserObjClassesInput = "ldap-user-object-classes";
// SettingsCache input values
private cacheDayInput = "#kc-eviction-day";
@ -36,7 +41,7 @@ export default class ProviderPage {
private cachePolicyInput = "#kc-cache-policy";
private cachePolicyList = "#kc-cache-policy + ul";
// Mapper required input values
// Mapper input values
private userModelAttInput = "user.model.attribute";
private ldapAttInput = "ldap.attribute";
private userModelAttNameInput = "user.model.attribute";
@ -61,9 +66,13 @@ export default class ProviderPage {
private roleLdapMapper = "role-ldap-mapper";
private hcLdapRoleMapper = "hardcoded-ldap-role-mapper";
private actionDropdown = "action-dropdown";
private deleteCmd = "delete-cmd";
private mappersTab = "ldap-mappers-tab";
private rolesTab = "rolesTab";
private createRoleBtn = "data-testid=no-roles-for-this-client-empty-action";
private realmRolesSaveBtn = "data-testid=realm-roles-save-button";
private createRoleBtn = "no-roles-for-this-client-empty-action";
private realmRolesSaveBtn = "realm-roles-save-button";
private roleNameField = "#kc-name";
private clientIdSelect = "#client\\.id-select-typeahead";
@ -77,6 +86,10 @@ export default class ProviderPage {
firstLoginSwitch = "update-first-login";
passwordAuthSwitch = "allow-password-authentication";
// LDAP switch input values
enableStartTls = "enable-start-tls";
connectionPooling = "connection-pooling";
changeCacheTime(unit: string, time: string) {
switch (unit) {
case "day":
@ -107,15 +120,15 @@ export default class ProviderPage {
}
deleteCardFromCard(card: string) {
cy.get(`[data-testid=${card}-dropdown]`).click();
cy.get('[data-testid="card-delete"]').click();
cy.findByTestId(`${card}-dropdown`).click();
cy.findByTestId("card-delete").click();
return this;
}
deleteCardFromMenu(card: string) {
this.clickExistingCard(card);
cy.get('[data-testid="action-dropdown"]').click();
cy.get(`[data-testid="delete-cmd"]`).click();
cy.findByTestId(this.actionDropdown).click();
cy.findByTestId(this.deleteCmd).click();
return this;
}
@ -126,16 +139,16 @@ export default class ProviderPage {
keytab: string
) {
if (name) {
cy.get(`[${this.kerberosNameInput}]`).type(name);
cy.findByTestId(this.kerberosNameInput).clear().type(name);
}
if (realm) {
cy.get(`[${this.kerberosRealmInput}]`).type(realm);
cy.findByTestId(this.kerberosRealmInput).clear().type(realm);
}
if (principal) {
cy.get(`[${this.kerberosPrincipalInput}]`).type(principal);
cy.findByTestId(this.kerberosPrincipalInput).clear().type(principal);
}
if (keytab) {
cy.get(`[${this.kerberosKeytabInput}]`).type(keytab);
cy.findByTestId(this.kerberosKeytabInput).clear().type(keytab);
}
return this;
}
@ -157,10 +170,16 @@ export default class ProviderPage {
return this;
}
fillLdapRequiredGeneralData(name: string, vendor: string) {
if (name) {
cy.get(`[${this.ldapNameInput}]`).clear().type(name);
verifyTextField(fieldName: string, value: string) {
cy.findByTestId(fieldName).should("have.value", value);
}
verifySelect(selectInput: string, value: string) {
cy.get(selectInput).should("contain", value);
}
fillLdapGeneralData(name: string, vendor?: string) {
cy.findByTestId(this.ldapNameInput).clear().type(name);
if (vendor) {
cy.get(this.ldapVendorInput).click();
cy.get(this.ldapVendorList).contains(vendor).click();
@ -168,55 +187,62 @@ export default class ProviderPage {
return this;
}
fillLdapRequiredConnectionData(
fillLdapConnectionData(
connectionUrl: string,
bindType: string,
truststoreSpi?: string,
connectionTimeout?: string,
bindDn?: string,
bindCreds?: string
) {
if (connectionUrl) {
cy.get(`[${this.ldapConnectionUrlInput}]`).type(connectionUrl);
cy.findByTestId(this.connectionUrlInput).clear().type(connectionUrl);
cy.get(this.bindTypeInput).click();
cy.get(this.bindTypeList).contains(bindType).click();
if (truststoreSpi) {
cy.get(this.truststoreSpiInput).click();
cy.get(this.truststoreSpiList).contains(truststoreSpi).click();
}
if (bindType) {
cy.get(this.ldapBindTypeInput).click();
cy.get(this.ldapBindTypeList).contains(bindType).click();
if (connectionTimeout) {
cy.findByTestId(this.connectionTimeoutInput)
.clear()
.type(connectionTimeout);
}
if (bindDn) {
cy.get(`[${this.ldapBindDnInput}]`).type(bindDn);
cy.findByTestId(this.bindDnInput).clear().type(bindDn);
}
if (bindCreds) {
cy.get(`[${this.ldapBindCredsInput}]`).type(bindCreds);
cy.findByTestId(this.bindCredsInput).clear().type(bindCreds);
}
return this;
}
fillLdapRequiredSearchingData(
fillLdapSearchingData(
editMode: string,
usersDn: string,
userLdapAtt: string,
rdnLdapAtt: string,
uuidLdapAtt: string,
userObjClasses: string
userLdapAtt?: string,
rdnLdapAtt?: string,
uuidLdapAtt?: string,
userObjClasses?: string
) {
if (editMode) {
cy.get(this.ldapEditModeInput).click();
cy.get(this.ldapEditModeList).contains(editMode).click();
}
if (usersDn) {
cy.get(`[${this.ldapUsersDnInput}]`).type(usersDn);
}
cy.findByTestId(this.ldapUsersDnInput).clear().type(usersDn);
if (userLdapAtt) {
cy.get(`[${this.ldapUserLdapAttInput}]`).type(userLdapAtt);
cy.findByTestId(this.ldapUserLdapAttInput).clear().type(userLdapAtt);
}
if (rdnLdapAtt) {
cy.get(`[${this.ldapRdnLdapAttInput}]`).type(rdnLdapAtt);
cy.findByTestId(this.ldapRdnLdapAttInput).clear().type(rdnLdapAtt);
}
if (uuidLdapAtt) {
cy.get(`[${this.ldapUuidLdapAttInput}]`).type(uuidLdapAtt);
cy.findByTestId(this.ldapUuidLdapAttInput).clear().type(uuidLdapAtt);
}
if (userObjClasses) {
cy.get(`[${this.ldapUserObjClassesInput}]`).type(userObjClasses);
cy.findByTestId(this.ldapUserObjClassesInput)
.clear()
.type(userObjClasses);
}
return this;
}
@ -228,17 +254,17 @@ export default class ProviderPage {
}
goToMappers() {
cy.get(`[data-testid="ldap-mappers-tab"]`).click();
cy.findByTestId(this.mappersTab).click();
}
createRole(roleName: string) {
cy.findByTestId(this.rolesTab).click();
cy.wait(1000);
cy.get(`[${this.createRoleBtn}]`).click();
cy.findByTestId(this.createRoleBtn).click();
cy.wait(1000);
cy.get(this.roleNameField).type(roleName);
cy.get(this.roleNameField).clear().type(roleName);
cy.wait(1000);
cy.get(`[${this.realmRolesSaveBtn}]`).click();
cy.findByTestId(this.realmRolesSaveBtn).click();
cy.wait(1000);
}
@ -253,7 +279,7 @@ export default class ProviderPage {
cy.get("#kc-providerId").click();
cy.get("button").contains(mapperType).click();
cy.get(`[data-testid="ldap-mapper-name"]`).type(`${mapperType}-test`);
cy.findByTestId("ldap-mapper-name").clear().type(`${mapperType}-test`);
switch (mapperType) {
case this.msadUserAcctMapper:
@ -261,30 +287,31 @@ export default class ProviderPage {
break;
case this.userAttLdapMapper:
case this.certLdapMapper:
cy.findByTestId(this.userModelAttInput).type(userModelAttValue);
cy.findByTestId(this.ldapAttInput).type(ldapAttValue);
cy.findByTestId(this.userModelAttInput).clear().type(userModelAttValue);
cy.findByTestId(this.ldapAttInput).clear().type(ldapAttValue);
break;
case this.hcAttMapper:
cy.findByTestId(this.userModelAttNameInput).type(userModelAttValue);
cy.findByTestId(this.attValueInput).type(ldapAttValue);
cy.findByTestId(this.userModelAttNameInput)
.clear()
.type(userModelAttValue);
cy.findByTestId(this.attValueInput).clear().type(ldapAttValue);
break;
case this.fullNameLdapMapper:
cy.findByTestId(this.ldapFullNameAttInput).type(ldapAttValue);
cy.findByTestId(this.ldapFullNameAttInput).clear().type(ldapAttValue);
break;
case this.hcLdapAttMapper:
cy.findByTestId(this.ldapAttNameInput).type(userModelAttValue);
cy.findByTestId(this.ldapAttValueInput).type(ldapAttValue);
cy.findByTestId(this.ldapAttNameInput).clear().type(userModelAttValue);
cy.findByTestId(this.ldapAttValueInput).clear().type(ldapAttValue);
break;
case this.hcLdapGroupMapper:
cy.findByTestId(this.groupInput).type(this.groupName);
cy.findByTestId(this.groupInput).clear().type(this.groupName);
break;
case this.groupLdapMapper:
cy.findByTestId(this.ldapGroupsDnInput).type(ldapDnValue);
cy.findByTestId(this.ldapGroupsDnInput).clear().type(ldapDnValue);
break;
case this.roleLdapMapper:
cy.findByTestId(this.ldapRolesDnInput).type(ldapDnValue);
// cy select clientID dropdown and choose clientName (var)
cy.findByTestId(this.ldapRolesDnInput).clear().type(ldapDnValue);
cy.get(this.clientIdSelect).click();
cy.get("button").contains(this.clientName).click({ force: true });
break;
@ -300,7 +327,6 @@ export default class ProviderPage {
.get(".pf-c-select__menu-item")
.first()
.click();
break;
default:
console.log("Invalid mapper type.");
@ -341,7 +367,7 @@ export default class ProviderPage {
}
clickExistingCard(cardName: string) {
cy.get('[data-testid="keycloak-card-title"]').contains(cardName).click();
cy.findByTestId("keycloak-card-title").contains(cardName).click();
cy.wait(1000);
return this;
}
@ -353,7 +379,7 @@ export default class ProviderPage {
}
clickNewCard(providerType: string) {
cy.get(`[data-testid=${providerType}-card]`).click();
cy.findByTestId(`${providerType}-card`).click();
cy.wait(1000);
return this;
}
@ -369,12 +395,22 @@ export default class ProviderPage {
}
save(providerType: string) {
cy.get(`[data-testid=${providerType}-save]`).click();
cy.findByTestId(`${providerType}-save`).click();
return this;
}
cancel(providerType: string) {
cy.get(`[data-testid=${providerType}-cancel]`).click();
cy.findByTestId(`${providerType}-cancel`).click();
return this;
}
testConnection() {
cy.findByTestId(this.testConnectionBtn).click();
return this;
}
testAuthorization() {
cy.findByTestId(this.testAuthBtn).click();
return this;
}
}

View file

@ -154,6 +154,7 @@ export const LdapSettingsConnection = ({
render={({ onChange, value }) => (
<Switch
id={"kc-enable-start-tls"}
data-testid="enable-start-tls"
isDisabled={false}
onChange={(value) => onChange([`${value}`])}
isChecked={value[0] === "true"}
@ -216,6 +217,7 @@ export const LdapSettingsConnection = ({
render={({ onChange, value }) => (
<Switch
id={"kc-connection-pooling"}
data-testid="connection-pooling"
isDisabled={false}
onChange={(value) => onChange([`${value}`])}
isChecked={value[0] === "true"}
@ -239,14 +241,16 @@ export const LdapSettingsConnection = ({
type="number"
min={0}
id="kc-console-connection-timeout"
data-testid="connection-timeout"
name="config.connectionTimeout[0]"
ref={form.register}
/>
</FormGroup>
<FormGroup fieldId="kc-test-button">
<FormGroup fieldId="kc-test-connection-button">
<Button
variant="secondary"
id="kc-connection-test-button"
id="kc-test-connection-button"
data-testid="test-connection-button"
onClick={() => testLdap("testConnection")}
>
{t("common:testConnection")}
@ -357,10 +361,11 @@ export const LdapSettingsConnection = ({
</FormGroup>
</>
)}
<FormGroup fieldId="kc-test-button">
<FormGroup fieldId="kc-test-auth-button">
<Button
variant="secondary"
id="kc-test-button"
id="kc-test-auth-button"
data-testid="test-auth-button"
onClick={() => testLdap("testAuthentication")}
>
{t("testAuthentication")}