2021-02-23 20:49:57 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
2021-03-05 20:55:01 +00:00
|
|
|
import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
|
2021-02-23 20:49:57 +00:00
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2021-03-18 12:48:14 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
2021-02-23 20:49:57 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2021-03-05 20:55:01 +00:00
|
|
|
const providersPage = new ProviderPage();
|
2021-02-23 20:49:57 +00:00
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
const provider = "ldap";
|
|
|
|
const allCapProvider = provider.toUpperCase();
|
|
|
|
|
2021-02-23 20:49:57 +00:00
|
|
|
const firstLdapName = "my-ldap";
|
|
|
|
const firstLdapVendor = "Active Directory";
|
|
|
|
|
|
|
|
const connectionUrl = "ldap://";
|
|
|
|
const firstBindType = "simple";
|
|
|
|
const firstBindDn = "user-1";
|
|
|
|
const firstBindCreds = "password1";
|
|
|
|
|
2021-09-23 14:11:41 +00:00
|
|
|
const firstEditMode = "READ_ONLY";
|
2021-02-23 20:49:57 +00:00
|
|
|
const firstUsersDn = "user-dn-1";
|
|
|
|
const firstUserLdapAtt = "uid";
|
|
|
|
const firstRdnLdapAtt = "uid";
|
|
|
|
const firstUuidLdapAtt = "entryUUID";
|
|
|
|
const firstUserObjClasses = "inetOrgPerson, organizationalPerson";
|
|
|
|
|
|
|
|
const secondLdapName = `${firstLdapName}-2`;
|
|
|
|
const secondLdapVendor = "Other";
|
|
|
|
|
|
|
|
const secondBindType = "none";
|
|
|
|
|
2021-09-23 14:11:41 +00:00
|
|
|
const secondEditMode = "WRITABLE";
|
2021-02-23 20:49:57 +00:00
|
|
|
const secondUsersDn = "user-dn-2";
|
|
|
|
const secondUserLdapAtt = "cn";
|
|
|
|
const secondRdnLdapAtt = "cn";
|
|
|
|
const secondUuidLdapAtt = "objectGUID";
|
|
|
|
const secondUserObjClasses = "person, organizationalPerson, user";
|
|
|
|
|
|
|
|
const defaultPolicy = "DEFAULT";
|
|
|
|
const newPolicy = "EVICT_WEEKLY";
|
|
|
|
const defaultLdapDay = "Sunday";
|
|
|
|
const defaultLdapHour = "00";
|
|
|
|
const defaultLdapMinute = "00";
|
|
|
|
const newLdapDay = "Wednesday";
|
|
|
|
const newLdapHour = "15";
|
|
|
|
const newLdapMinute = "55";
|
|
|
|
|
2021-03-05 22:04:41 +00:00
|
|
|
const addProviderMenu = "Add new provider";
|
2021-02-23 20:49:57 +00:00
|
|
|
const createdSuccessMessage = "User federation provider successfully created";
|
|
|
|
const savedSuccessMessage = "User federation provider successfully saved";
|
|
|
|
const deletedSuccessMessage = "The user federation provider has been deleted.";
|
|
|
|
const deleteModalTitle = "Delete user federation provider?";
|
|
|
|
const disableModalTitle = "Disable user federation provider?";
|
|
|
|
|
|
|
|
describe("User Fed LDAP tests", () => {
|
2021-03-01 21:56:26 +00:00
|
|
|
beforeEach(() => {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-02-23 20:49:57 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToUserFederation();
|
2021-03-01 21:56:26 +00:00
|
|
|
});
|
2021-02-23 20:49:57 +00:00
|
|
|
|
2021-03-01 21:56:26 +00:00
|
|
|
it("Create Ldap provider from empty state", () => {
|
2021-03-05 22:04:41 +00:00
|
|
|
// if tests don't start at empty state, e.g. user has providers configured locally,
|
|
|
|
// create a new card from the card view instead
|
|
|
|
cy.get("body").then(($body) => {
|
|
|
|
if ($body.find(`[data-testid=ldap-card]`).length > 0) {
|
|
|
|
providersPage.clickNewCard(provider);
|
|
|
|
} else {
|
|
|
|
providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
|
|
|
|
}
|
|
|
|
});
|
2021-03-01 21:56:26 +00:00
|
|
|
providersPage.fillLdapRequiredGeneralData(firstLdapName, firstLdapVendor);
|
2021-02-23 20:49:57 +00:00
|
|
|
providersPage.fillLdapRequiredConnectionData(
|
|
|
|
connectionUrl,
|
|
|
|
firstBindType,
|
|
|
|
firstBindDn,
|
2021-03-01 21:56:26 +00:00
|
|
|
firstBindCreds
|
2021-02-23 20:49:57 +00:00
|
|
|
);
|
|
|
|
providersPage.fillLdapRequiredSearchingData(
|
2021-09-23 14:11:41 +00:00
|
|
|
firstEditMode,
|
2021-02-23 20:49:57 +00:00
|
|
|
firstUsersDn,
|
|
|
|
firstUserLdapAtt,
|
|
|
|
firstRdnLdapAtt,
|
|
|
|
firstUuidLdapAtt,
|
|
|
|
firstUserObjClasses
|
|
|
|
);
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.save(provider);
|
2021-02-23 20:49:57 +00:00
|
|
|
|
|
|
|
masthead.checkNotificationMessage(createdSuccessMessage);
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Update an existing LDAP provider and save", () => {
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.clickExistingCard(firstLdapName);
|
2021-02-23 20:49:57 +00:00
|
|
|
providersPage.selectCacheType(newPolicy);
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.changeCacheTime("day", newLdapDay);
|
|
|
|
providersPage.changeCacheTime("hour", newLdapHour);
|
|
|
|
providersPage.changeCacheTime("minute", newLdapMinute);
|
2021-02-23 20:49:57 +00:00
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.save(provider);
|
2021-02-23 20:49:57 +00:00
|
|
|
masthead.checkNotificationMessage(savedSuccessMessage);
|
|
|
|
|
|
|
|
sidebarPage.goToUserFederation();
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.clickExistingCard(firstLdapName);
|
2021-02-23 20:49:57 +00:00
|
|
|
|
|
|
|
expect(cy.contains(newPolicy).should("exist"));
|
|
|
|
expect(cy.contains(defaultPolicy).should("not.exist"));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Change existing LDAP provider and click button to cancel", () => {
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.clickExistingCard(firstLdapName);
|
2021-02-23 20:49:57 +00:00
|
|
|
providersPage.selectCacheType(newPolicy);
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.changeCacheTime("day", defaultLdapDay);
|
|
|
|
providersPage.changeCacheTime("hour", defaultLdapHour);
|
|
|
|
providersPage.changeCacheTime("minute", defaultLdapMinute);
|
2021-02-23 20:49:57 +00:00
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.cancel(provider);
|
2021-02-23 20:49:57 +00:00
|
|
|
cy.wait(1000);
|
2021-03-01 21:56:26 +00:00
|
|
|
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.clickExistingCard(firstLdapName);
|
2021-02-23 20:49:57 +00:00
|
|
|
providersPage.selectCacheType(newPolicy);
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
providersPage.verifyChangedHourInput(newLdapHour, defaultLdapHour);
|
2021-02-23 20:49:57 +00:00
|
|
|
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Disable an existing LDAP provider", () => {
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.clickExistingCard(firstLdapName);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.disableEnabledSwitch(allCapProvider);
|
2021-02-23 20:49:57 +00:00
|
|
|
|
|
|
|
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", () => {
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.clickExistingCard(firstLdapName);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.enableEnabledSwitch(allCapProvider);
|
2021-03-01 21:56:26 +00:00
|
|
|
|
2021-02-23 20:49:57 +00:00
|
|
|
masthead.checkNotificationMessage(savedSuccessMessage);
|
|
|
|
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
expect(cy.contains("Enabled").should("exist"));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create new LDAP provider using the New Provider dropdown", () => {
|
2021-03-05 22:04:41 +00:00
|
|
|
providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
|
2021-03-01 21:56:26 +00:00
|
|
|
providersPage.fillLdapRequiredGeneralData(secondLdapName, secondLdapVendor);
|
2021-09-16 10:24:21 +00:00
|
|
|
providersPage.fillLdapRequiredConnectionData(connectionUrl, secondBindType);
|
2021-02-23 20:49:57 +00:00
|
|
|
providersPage.fillLdapRequiredSearchingData(
|
2021-09-23 14:11:41 +00:00
|
|
|
secondEditMode,
|
2021-02-23 20:49:57 +00:00
|
|
|
secondUsersDn,
|
|
|
|
secondUserLdapAtt,
|
|
|
|
secondRdnLdapAtt,
|
|
|
|
secondUuidLdapAtt,
|
|
|
|
secondUserObjClasses
|
|
|
|
);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.save(provider);
|
2021-02-23 20:49:57 +00:00
|
|
|
masthead.checkNotificationMessage(createdSuccessMessage);
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Delete an LDAP provider from card view using the card's menu", () => {
|
2021-03-02 15:23:21 +00:00
|
|
|
providersPage.deleteCardFromCard(secondLdapName);
|
2021-02-23 20:49:57 +00:00
|
|
|
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(deletedSuccessMessage);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Delete an LDAP provider using the Settings view's Action menu", () => {
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.deleteCardFromMenu(provider, firstLdapName);
|
2021-02-23 20:49:57 +00:00
|
|
|
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(deletedSuccessMessage);
|
|
|
|
});
|
|
|
|
});
|