Adds LDAP searching tests (#2385)

This commit is contained in:
mfrances17 2022-04-08 05:47:14 -04:00 committed by GitHub
parent e681dbae4a
commit 818b8cdbb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 130 additions and 16 deletions

View file

@ -16,6 +16,9 @@ const allCapProvider = provider.toUpperCase();
const firstLdapName = "my-ldap"; const firstLdapName = "my-ldap";
const firstLdapVendor = "Active Directory"; const firstLdapVendor = "Active Directory";
const secondLdapName = `${firstLdapName}-2`;
const secondLdapVendor = "Other";
const updatedLdapName = `${firstLdapName}-updated`;
// connection and authentication settings // connection and authentication settings
const connectionUrlValid = "ldap://ldap.forumsys.com:389"; const connectionUrlValid = "ldap://ldap.forumsys.com:389";
@ -43,24 +46,27 @@ const userSyncPeriod = "86400";
// ldap searching and updating // ldap searching and updating
const editModeReadOnly = "READ_ONLY"; const editModeReadOnly = "READ_ONLY";
const editModeWritable = "WRITABLE";
const editModeUnsynced = "UNSYNCED";
const firstUsersDn = "user-dn-1"; const firstUsersDn = "user-dn-1";
const firstUserLdapAtt = "uid"; const firstUserLdapAtt = "uid";
const firstRdnLdapAtt = "uid"; const firstRdnLdapAtt = "uid";
const firstUuidLdapAtt = "entryUUID"; const firstUuidLdapAtt = "entryUUID";
const firstUserObjClasses = "inetOrgPerson, organizationalPerson"; const firstUserObjClasses = "inetOrgPerson, organizationalPerson";
const firstUserLdapFilter = "(first-filter)";
const firstReadTimeout = "5000";
const secondLdapName = `${firstLdapName}-2`; const searchScopeOneLevel = "One Level";
const secondLdapVendor = "Other"; const searchScopeSubtree = "Subtree";
const editModeWritable = "WRITABLE";
const secondUsersDn = "user-dn-2"; const secondUsersDn = "user-dn-2";
const secondUserLdapAtt = "cn"; const secondUserLdapAtt = "cn";
const secondRdnLdapAtt = "cn"; const secondRdnLdapAtt = "cn";
const secondUuidLdapAtt = "objectGUID"; const secondUuidLdapAtt = "objectGUID";
const secondUserObjClasses = "person, organizationalPerson, user"; const secondUserObjClasses = "person, organizationalPerson, user";
const secondUserLdapFilter = "(second-filter)";
const updatedLdapName = `${firstLdapName}-updated`; const secondReadTimeout = "5000";
const defaultPolicy = "DEFAULT"; const defaultPolicy = "DEFAULT";
const newPolicy = "EVICT_WEEKLY"; const newPolicy = "EVICT_WEEKLY";
@ -115,7 +121,10 @@ describe("User Fed LDAP tests", () => {
firstUserLdapAtt, firstUserLdapAtt,
firstRdnLdapAtt, firstRdnLdapAtt,
firstUuidLdapAtt, firstUuidLdapAtt,
firstUserObjClasses firstUserObjClasses,
firstUserLdapFilter,
searchScopeOneLevel,
firstReadTimeout
); );
providersPage.save(provider); providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage); masthead.checkNotificationMessage(createdSuccessMessage);
@ -290,6 +299,86 @@ describe("User Fed LDAP tests", () => {
sidebarPage.goToUserFederation(); 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", () => { it("Should update display name", () => {
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.fillLdapGeneralData(updatedLdapName); providersPage.fillLdapGeneralData(updatedLdapName);

View file

@ -23,13 +23,18 @@ export default class ProviderPage {
private testAuthBtn = "test-auth-button"; private testAuthBtn = "test-auth-button";
// LdapSettingsSearching input values // LdapSettingsSearching input values
private ldapEditModeInput = "#kc-edit-mode"; ldapEditModeInput = "#kc-edit-mode";
private ldapEditModeList = "#kc-edit-mode + ul"; private ldapEditModeList = "#kc-edit-mode + ul";
private ldapUsersDnInput = "ldap-users-dn"; ldapSearchScopeInput = "#kc-search-scope";
private ldapUserLdapAttInput = "ldap-username-attribute"; private ldapSearchScopeInputList = "#kc-search-scope + ul";
private ldapRdnLdapAttInput = "ldap-rdn-attribute"; ldapPagination = "console-pagination";
private ldapUuidLdapAttInput = "ldap-uuid-attribute"; ldapUsersDnInput = "ldap-users-dn";
private ldapUserObjClassesInput = "ldap-user-object-classes"; 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 // LdapSettingsKerberosIntegration input values
ldapKerberosRealmInput = "kerberos-realm"; ldapKerberosRealmInput = "kerberos-realm";
@ -176,6 +181,11 @@ export default class ProviderPage {
return this; return this;
} }
fillSelect(selectField: string, value: string) {
cy.get(selectField).click();
cy.get(`${selectField} + ul`).contains(value).click();
}
fillTextField(textField: string, value: string) { fillTextField(textField: string, value: string) {
cy.findByTestId(textField).type("x"); cy.findByTestId(textField).type("x");
cy.findByTestId(textField).clear().type(value).blur(); cy.findByTestId(textField).clear().type(value).blur();
@ -246,11 +256,13 @@ export default class ProviderPage {
userLdapAtt?: string, userLdapAtt?: string,
rdnLdapAtt?: string, rdnLdapAtt?: string,
uuidLdapAtt?: string, uuidLdapAtt?: string,
userObjClasses?: string userObjClasses?: string,
userLdapFilter?: string,
searchScope?: string,
readTimeout?: string
) { ) {
cy.get(this.ldapEditModeInput).click(); cy.get(this.ldapEditModeInput).click();
cy.get(this.ldapEditModeList).contains(editMode).click(); cy.get(this.ldapEditModeList).contains(editMode).click();
cy.findByTestId(this.ldapUsersDnInput).clear().type(usersDn); cy.findByTestId(this.ldapUsersDnInput).clear().type(usersDn);
if (userLdapAtt) { if (userLdapAtt) {
cy.findByTestId(this.ldapUserLdapAttInput).clear().type(userLdapAtt); cy.findByTestId(this.ldapUserLdapAttInput).clear().type(userLdapAtt);
@ -266,6 +278,16 @@ export default class ProviderPage {
.clear() .clear()
.type(userObjClasses); .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; return this;
} }

View file

@ -274,6 +274,7 @@ export const LdapSettingsSearching = ({
<TextInput <TextInput
type="text" type="text"
id="kc-user-ldap-filter" id="kc-user-ldap-filter"
data-testid="user-ldap-filter"
name="config.customUserSearchFilter[0]" name="config.customUserSearchFilter[0]"
ref={form.register({ ref={form.register({
pattern: { pattern: {
@ -342,6 +343,7 @@ export const LdapSettingsSearching = ({
type="number" type="number"
min={0} min={0}
id="kc-read-timeout" id="kc-read-timeout"
data-testid="ldap-read-timeout"
name="config.readTimeout[0]" name="config.readTimeout[0]"
ref={form.register} ref={form.register}
/> />
@ -363,7 +365,8 @@ export const LdapSettingsSearching = ({
control={form.control} control={form.control}
render={({ onChange, value }) => ( render={({ onChange, value }) => (
<Switch <Switch
id={"kc-console-pagination"} id="kc-console-pagination"
data-testid="console-pagination"
isDisabled={false} isDisabled={false}
onChange={(value) => onChange([`${value}`])} onChange={(value) => onChange([`${value}`])}
isChecked={value[0] === "true"} isChecked={value[0] === "true"}