From 818b8cdbb9c38d9e4bc5acb6b4bd99aa93fbc5dd Mon Sep 17 00:00:00 2001
From: mfrances17 <39063664+mfrances17@users.noreply.github.com>
Date: Fri, 8 Apr 2022 05:47:14 -0400
Subject: [PATCH] Adds LDAP searching tests (#2385)
---
.../integration/user_fed_ldap_test.spec.ts | 103 ++++++++++++++++--
.../manage/providers/ProviderPage.ts | 38 +++++--
.../ldap/LdapSettingsSearching.tsx | 5 +-
3 files changed, 130 insertions(+), 16 deletions(-)
diff --git a/cypress/integration/user_fed_ldap_test.spec.ts b/cypress/integration/user_fed_ldap_test.spec.ts
index 1703e798fb..854f59db34 100644
--- a/cypress/integration/user_fed_ldap_test.spec.ts
+++ b/cypress/integration/user_fed_ldap_test.spec.ts
@@ -16,6 +16,9 @@ const allCapProvider = provider.toUpperCase();
const firstLdapName = "my-ldap";
const firstLdapVendor = "Active Directory";
+const secondLdapName = `${firstLdapName}-2`;
+const secondLdapVendor = "Other";
+const updatedLdapName = `${firstLdapName}-updated`;
// connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389";
@@ -43,24 +46,27 @@ const userSyncPeriod = "86400";
// ldap searching and updating
const editModeReadOnly = "READ_ONLY";
+const editModeWritable = "WRITABLE";
+const editModeUnsynced = "UNSYNCED";
+
const firstUsersDn = "user-dn-1";
const firstUserLdapAtt = "uid";
const firstRdnLdapAtt = "uid";
const firstUuidLdapAtt = "entryUUID";
const firstUserObjClasses = "inetOrgPerson, organizationalPerson";
+const firstUserLdapFilter = "(first-filter)";
+const firstReadTimeout = "5000";
-const secondLdapName = `${firstLdapName}-2`;
-const secondLdapVendor = "Other";
-
-const editModeWritable = "WRITABLE";
+const searchScopeOneLevel = "One Level";
+const searchScopeSubtree = "Subtree";
const secondUsersDn = "user-dn-2";
const secondUserLdapAtt = "cn";
const secondRdnLdapAtt = "cn";
const secondUuidLdapAtt = "objectGUID";
const secondUserObjClasses = "person, organizationalPerson, user";
-
-const updatedLdapName = `${firstLdapName}-updated`;
+const secondUserLdapFilter = "(second-filter)";
+const secondReadTimeout = "5000";
const defaultPolicy = "DEFAULT";
const newPolicy = "EVICT_WEEKLY";
@@ -115,7 +121,10 @@ describe("User Fed LDAP tests", () => {
firstUserLdapAtt,
firstRdnLdapAtt,
firstUuidLdapAtt,
- firstUserObjClasses
+ firstUserObjClasses,
+ firstUserLdapFilter,
+ searchScopeOneLevel,
+ firstReadTimeout
);
providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage);
@@ -290,6 +299,86 @@ describe("User Fed LDAP tests", () => {
sidebarPage.goToUserFederation();
});
+ it("Should update LDAP searching and updating settings and save", () => {
+ providersPage.clickExistingCard(firstLdapName);
+
+ providersPage.fillLdapSearchingData(
+ editModeWritable,
+ secondUsersDn,
+ secondUserLdapAtt,
+ secondRdnLdapAtt,
+ secondUuidLdapAtt,
+ secondUserObjClasses,
+ secondUserLdapFilter,
+ searchScopeSubtree,
+ secondReadTimeout
+ );
+ providersPage.toggleSwitch(providersPage.ldapPagination);
+
+ providersPage.save(provider);
+ masthead.checkNotificationMessage(savedSuccessMessage);
+
+ // now verify
+ sidebarPage.goToUserFederation();
+ providersPage.clickExistingCard(firstLdapName);
+
+ providersPage.verifySelect(
+ providersPage.ldapEditModeInput,
+ editModeWritable
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapUsersDnInput,
+ secondUsersDn
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapUserLdapAttInput,
+ secondUserLdapAtt
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapRdnLdapAttInput,
+ secondRdnLdapAtt
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapUuidLdapAttInput,
+ secondUuidLdapAtt
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapUserObjClassesInput,
+ secondUserObjClasses
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapUserLdapFilter,
+ secondUserLdapFilter
+ );
+ providersPage.verifySelect(
+ providersPage.ldapSearchScopeInput,
+ searchScopeSubtree
+ );
+ providersPage.verifyTextField(
+ providersPage.ldapReadTimeout,
+ secondReadTimeout
+ );
+ providersPage.verifyToggle(providersPage.ldapPagination, "on");
+
+ sidebarPage.goToUserFederation();
+ providersPage.clickExistingCard(firstLdapName);
+
+ providersPage.fillSelect(providersPage.ldapEditModeInput, editModeUnsynced);
+ providersPage.toggleSwitch(providersPage.importUsers);
+
+ providersPage.save(provider);
+ masthead.checkNotificationMessage(savedSuccessMessage);
+
+ // now verify
+ sidebarPage.goToUserFederation();
+ providersPage.clickExistingCard(firstLdapName);
+
+ providersPage.verifySelect(
+ providersPage.ldapEditModeInput,
+ editModeUnsynced
+ );
+ });
+
it("Should update display name", () => {
providersPage.clickExistingCard(firstLdapName);
providersPage.fillLdapGeneralData(updatedLdapName);
diff --git a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts
index 71dda030ec..3ddf1e3b57 100644
--- a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts
+++ b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts
@@ -23,13 +23,18 @@ export default class ProviderPage {
private testAuthBtn = "test-auth-button";
// LdapSettingsSearching input values
- private ldapEditModeInput = "#kc-edit-mode";
+ ldapEditModeInput = "#kc-edit-mode";
private ldapEditModeList = "#kc-edit-mode + ul";
- 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";
+ ldapSearchScopeInput = "#kc-search-scope";
+ private ldapSearchScopeInputList = "#kc-search-scope + ul";
+ ldapPagination = "console-pagination";
+ ldapUsersDnInput = "ldap-users-dn";
+ ldapUserLdapAttInput = "ldap-username-attribute";
+ ldapRdnLdapAttInput = "ldap-rdn-attribute";
+ ldapUuidLdapAttInput = "ldap-uuid-attribute";
+ ldapUserObjClassesInput = "ldap-user-object-classes";
+ ldapUserLdapFilter = "user-ldap-filter";
+ ldapReadTimeout = "ldap-read-timeout";
// LdapSettingsKerberosIntegration input values
ldapKerberosRealmInput = "kerberos-realm";
@@ -176,6 +181,11 @@ export default class ProviderPage {
return this;
}
+ fillSelect(selectField: string, value: string) {
+ cy.get(selectField).click();
+ cy.get(`${selectField} + ul`).contains(value).click();
+ }
+
fillTextField(textField: string, value: string) {
cy.findByTestId(textField).type("x");
cy.findByTestId(textField).clear().type(value).blur();
@@ -246,11 +256,13 @@ export default class ProviderPage {
userLdapAtt?: string,
rdnLdapAtt?: string,
uuidLdapAtt?: string,
- userObjClasses?: string
+ userObjClasses?: string,
+ userLdapFilter?: string,
+ searchScope?: string,
+ readTimeout?: string
) {
cy.get(this.ldapEditModeInput).click();
cy.get(this.ldapEditModeList).contains(editMode).click();
-
cy.findByTestId(this.ldapUsersDnInput).clear().type(usersDn);
if (userLdapAtt) {
cy.findByTestId(this.ldapUserLdapAttInput).clear().type(userLdapAtt);
@@ -266,6 +278,16 @@ export default class ProviderPage {
.clear()
.type(userObjClasses);
}
+ if (userLdapFilter) {
+ cy.findByTestId(this.ldapUserLdapFilter).clear().type(userLdapFilter);
+ }
+ if (searchScope) {
+ cy.get(this.ldapSearchScopeInput).click();
+ cy.get(this.ldapSearchScopeInputList).contains(searchScope).click();
+ }
+ if (readTimeout) {
+ cy.findByTestId(this.ldapReadTimeout).clear().type(readTimeout);
+ }
return this;
}
diff --git a/src/user-federation/ldap/LdapSettingsSearching.tsx b/src/user-federation/ldap/LdapSettingsSearching.tsx
index 9d44ff4998..263a08825d 100644
--- a/src/user-federation/ldap/LdapSettingsSearching.tsx
+++ b/src/user-federation/ldap/LdapSettingsSearching.tsx
@@ -274,6 +274,7 @@ export const LdapSettingsSearching = ({
@@ -363,7 +365,8 @@ export const LdapSettingsSearching = ({
control={form.control}
render={({ onChange, value }) => (