2021-04-28 05:50:41 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
|
|
|
import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2022-01-07 07:27:58 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2021-04-28 05:50:41 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
|
|
|
|
const providersPage = new ProviderPage();
|
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
|
|
|
|
const provider = "ldap";
|
|
|
|
const allCapProvider = provider.toUpperCase();
|
|
|
|
|
|
|
|
const ldapName = "ldap-mappers-testing";
|
|
|
|
const ldapVendor = "Active Directory";
|
|
|
|
|
2022-04-05 19:33:51 +00:00
|
|
|
// 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";
|
2021-04-28 05:50:41 +00:00
|
|
|
|
2022-04-05 19:33:51 +00:00
|
|
|
// ldap searching and updating
|
|
|
|
const editModeReadOnly = "READ_ONLY";
|
2021-04-28 05:50:41 +00:00
|
|
|
const firstUsersDn = "user-dn-1";
|
|
|
|
const firstUserLdapAtt = "uid";
|
|
|
|
const firstRdnLdapAtt = "uid";
|
|
|
|
const firstUuidLdapAtt = "entryUUID";
|
|
|
|
const firstUserObjClasses = "inetOrgPerson, organizationalPerson";
|
|
|
|
|
|
|
|
const addProviderMenu = "Add new provider";
|
|
|
|
const providerCreatedSuccess = "User federation provider successfully created";
|
|
|
|
const mapperCreatedSuccess = "Mapping successfully created";
|
|
|
|
const mapperUpdatedSuccess = "Mapping successfully updated";
|
|
|
|
const providerDeleteSuccess = "The user federation provider has been deleted.";
|
|
|
|
const providerDeleteTitle = "Delete user federation provider?";
|
|
|
|
const mapperDeletedSuccess = "Mapping successfully deleted";
|
|
|
|
const mapperDeleteTitle = "Delete mapping?";
|
|
|
|
|
|
|
|
// mapperType variables
|
|
|
|
const msadUserAcctMapper = "msad-user-account-control-mapper";
|
|
|
|
const msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper";
|
|
|
|
const userAttLdapMapper = "user-attribute-ldap-mapper";
|
|
|
|
const fullNameLdapMapper = "full-name-ldap-mapper";
|
2021-06-03 20:47:47 +00:00
|
|
|
const groupLdapMapper = "group-ldap-mapper";
|
2022-03-21 06:45:34 +00:00
|
|
|
const certLdapMapper = "certificate-ldap-mapper";
|
|
|
|
|
|
|
|
const mapperNames = [
|
|
|
|
`${msadUserAcctMapper}-test`,
|
|
|
|
`${msadLdsUserAcctMapper}-test`,
|
|
|
|
`${userAttLdapMapper}-test`,
|
|
|
|
`${fullNameLdapMapper}-test`,
|
|
|
|
`${groupLdapMapper}-test`,
|
|
|
|
];
|
|
|
|
const multiMapperNames = mapperNames.slice(2);
|
|
|
|
const singleMapperName = mapperNames.slice(4);
|
|
|
|
const uniqueSearchTerm = "group";
|
|
|
|
const multipleSearchTerm = "ldap";
|
|
|
|
const nonexistingSearchTerm = "redhat";
|
2021-04-28 05:50:41 +00:00
|
|
|
|
2021-10-26 12:41:08 +00:00
|
|
|
// Used by "Delete default mappers" test
|
2021-04-28 05:50:41 +00:00
|
|
|
const creationDateMapper = "creation date";
|
|
|
|
const emailMapper = "email";
|
|
|
|
const lastNameMapper = "last name";
|
|
|
|
const modifyDateMapper = "modify date";
|
|
|
|
const usernameMapper = "username";
|
|
|
|
const firstNameMapper = "first name";
|
|
|
|
const MsadAccountControlsMapper = "MSAD account controls";
|
|
|
|
|
|
|
|
describe("User Fed LDAP mapper tests", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create LDAP provider from empty state", () => {
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
});
|
2022-04-05 19:33:51 +00:00
|
|
|
providersPage.fillLdapGeneralData(ldapName, ldapVendor);
|
|
|
|
providersPage.fillLdapConnectionData(
|
|
|
|
connectionUrlValid,
|
|
|
|
bindTypeSimple,
|
|
|
|
truststoreSpiOnlyLdaps,
|
|
|
|
connectionTimeoutTwoSecs,
|
|
|
|
bindDnCnDc,
|
|
|
|
bindCredsValid
|
2021-04-28 05:50:41 +00:00
|
|
|
);
|
2022-04-05 19:33:51 +00:00
|
|
|
providersPage.toggleSwitch(providersPage.enableStartTls);
|
|
|
|
providersPage.toggleSwitch(providersPage.connectionPooling);
|
|
|
|
|
|
|
|
providersPage.fillLdapSearchingData(
|
|
|
|
editModeReadOnly,
|
2021-04-28 05:50:41 +00:00
|
|
|
firstUsersDn,
|
|
|
|
firstUserLdapAtt,
|
|
|
|
firstRdnLdapAtt,
|
|
|
|
firstUuidLdapAtt,
|
|
|
|
firstUserObjClasses
|
|
|
|
);
|
|
|
|
providersPage.save(provider);
|
|
|
|
masthead.checkNotificationMessage(providerCreatedSuccess);
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
// delete default mappers
|
2021-10-26 12:41:08 +00:00
|
|
|
it("Delete default mappers", () => {
|
2021-04-28 05:50:41 +00:00
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
|
|
|
|
listingPage.itemExist(creationDateMapper).deleteItem(creationDateMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-11-02 21:00:42 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
listingPage.itemExist(creationDateMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(emailMapper).deleteItem(emailMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-11-02 21:00:42 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
listingPage.itemExist(emailMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(lastNameMapper).deleteItem(lastNameMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-11-02 21:00:42 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
listingPage.itemExist(lastNameMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(modifyDateMapper).deleteItem(modifyDateMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-11-02 21:00:42 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
listingPage.itemExist(modifyDateMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(usernameMapper).deleteItem(usernameMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-11-02 21:00:42 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
listingPage.itemExist(usernameMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(firstNameMapper).deleteItem(firstNameMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-11-02 21:00:42 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
listingPage.itemExist(firstNameMapper, false);
|
|
|
|
|
|
|
|
listingPage
|
|
|
|
.itemExist(MsadAccountControlsMapper)
|
|
|
|
.deleteItem(MsadAccountControlsMapper);
|
2022-02-16 16:34:54 +00:00
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
2021-12-06 10:50:29 +00:00
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess, true);
|
2021-10-26 12:41:08 +00:00
|
|
|
});
|
2021-04-28 05:50:41 +00:00
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
// mapper CRUD tests
|
2021-04-28 05:50:41 +00:00
|
|
|
// create mapper
|
|
|
|
it("Create certificate ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(certLdapMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(certLdapMapper, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// update mapper
|
|
|
|
it("Update certificate ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
|
|
|
|
listingPage.goToItemDetails(`${certLdapMapper}-test`);
|
|
|
|
providersPage.updateMapper(certLdapMapper);
|
|
|
|
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperUpdatedSuccess);
|
|
|
|
});
|
|
|
|
|
|
|
|
// delete mapper
|
|
|
|
it("Delete certificate ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
|
|
|
|
listingPage.deleteItem(`${certLdapMapper}-test`);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
});
|
|
|
|
|
2022-03-21 06:45:34 +00:00
|
|
|
// create one of each non-hardcoded mapper type except
|
|
|
|
// certificate ldap mapper which was already tested in CRUD section
|
2021-04-28 05:50:41 +00:00
|
|
|
it("Create user account control mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(msadUserAcctMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(msadUserAcctMapper, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create msad lds user account control mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(msadLdsUserAcctMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(msadLdsUserAcctMapper, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create user attribute ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(userAttLdapMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(userAttLdapMapper, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create full name ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(fullNameLdapMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(fullNameLdapMapper, true);
|
|
|
|
});
|
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
it("Create group ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(groupLdapMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(groupLdapMapper, true);
|
2021-04-28 05:50:41 +00:00
|
|
|
});
|
|
|
|
|
2022-03-21 06:45:34 +00:00
|
|
|
it("Should return one search result for mapper with unique string", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
listingPage.searchItem(uniqueSearchTerm, false);
|
|
|
|
singleMapperName.map((mapperName) => listingPage.itemExist(mapperName));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should return multiple search results for mappers that share common string", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
listingPage.searchItem(multipleSearchTerm, false);
|
|
|
|
multiMapperNames.map((mapperName) => listingPage.itemExist(mapperName));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should return all mappers in search results when no string is specified", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
listingPage.searchItem("", false);
|
|
|
|
mapperNames.map((mapperName) => listingPage.itemExist(mapperName));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should return no search results for string that does not exist in any mappers", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
listingPage.searchItem(nonexistingSearchTerm, false);
|
|
|
|
cy.findByTestId(listingPage.emptyState).should("exist");
|
|
|
|
});
|
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
// *** test cleanup ***
|
2021-04-28 05:50:41 +00:00
|
|
|
it("Cleanup - delete LDAP provider", () => {
|
2022-01-05 17:06:53 +00:00
|
|
|
providersPage.deleteCardFromMenu(ldapName);
|
2021-04-28 05:50:41 +00:00
|
|
|
modalUtils.checkModalTitle(providerDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(providerDeleteSuccess);
|
|
|
|
});
|
|
|
|
});
|