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 GroupModal from "../support/pages/admin_console/manage/groups/GroupModal";
|
|
|
|
import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
|
2021-06-03 20:47:47 +00:00
|
|
|
import CreateClientPage from "../support/pages/admin_console/manage/clients/CreateClientPage";
|
2021-04-28 05:50:41 +00:00
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
const groupModal = new GroupModal();
|
2021-06-03 20:47:47 +00:00
|
|
|
const createClientPage = new CreateClientPage();
|
2021-04-28 05:50:41 +00:00
|
|
|
|
|
|
|
const providersPage = new ProviderPage();
|
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
|
|
|
|
const provider = "ldap";
|
|
|
|
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";
|
|
|
|
|
2021-09-23 14:11:41 +00:00
|
|
|
const firstEditMode = "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?";
|
2021-06-10 15:24:05 +00:00
|
|
|
const groupDeleteTitle = "Delete group?";
|
2021-06-03 20:47:47 +00:00
|
|
|
const groupCreatedSuccess = "Group created";
|
|
|
|
const groupDeletedSuccess = "Group deleted";
|
|
|
|
const clientCreatedSuccess = "Client created successfully";
|
|
|
|
const clientDeletedSuccess = "The client has been deleted";
|
2021-06-04 16:33:38 +00:00
|
|
|
const roleCreatedSuccess = "Role created";
|
2021-06-03 20:47:47 +00:00
|
|
|
const groupName = "aa-uf-mappers-group";
|
|
|
|
const clientName = "aa-uf-mappers-client";
|
2021-06-04 16:33:38 +00:00
|
|
|
const roleName = "aa-uf-mappers-role";
|
2021-04-28 05:50:41 +00:00
|
|
|
|
|
|
|
// mapperType variables
|
|
|
|
const msadUserAcctMapper = "msad-user-account-control-mapper";
|
|
|
|
const msadLdsUserAcctMapper = "msad-lds-user-account-control-mapper";
|
|
|
|
const userAttLdapMapper = "user-attribute-ldap-mapper";
|
|
|
|
const hcAttMapper = "hardcoded-attribute-mapper";
|
|
|
|
const certLdapMapper = "certificate-ldap-mapper";
|
|
|
|
const fullNameLdapMapper = "full-name-ldap-mapper";
|
|
|
|
const hcLdapGroupMapper = "hardcoded-ldap-group-mapper";
|
|
|
|
const hcLdapAttMapper = "hardcoded-ldap-attribute-mapper";
|
2021-06-03 20:47:47 +00:00
|
|
|
|
|
|
|
const groupLdapMapper = "group-ldap-mapper";
|
2021-06-04 16:33:38 +00:00
|
|
|
const roleLdapMapper = "role-ldap-mapper";
|
2021-06-03 20:47:47 +00:00
|
|
|
const hcLdapRoleMapper = "hardcoded-ldap-role-mapper";
|
2021-04-28 05:50:41 +00:00
|
|
|
|
2021-09-01 13:45:46 +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";
|
2021-09-01 13:45:46 +00:00
|
|
|
*/
|
2021-04-28 05:50:41 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
providersPage.fillLdapRequiredGeneralData(ldapName, ldapVendor);
|
|
|
|
providersPage.fillLdapRequiredConnectionData(
|
|
|
|
connectionUrl,
|
|
|
|
firstBindType,
|
|
|
|
firstBindDn,
|
|
|
|
firstBindCreds
|
|
|
|
);
|
|
|
|
providersPage.fillLdapRequiredSearchingData(
|
2021-09-23 14:11:41 +00:00
|
|
|
firstEditMode,
|
2021-04-28 05:50:41 +00:00
|
|
|
firstUsersDn,
|
|
|
|
firstUserLdapAtt,
|
|
|
|
firstRdnLdapAtt,
|
|
|
|
firstUuidLdapAtt,
|
|
|
|
firstUserObjClasses
|
|
|
|
);
|
|
|
|
providersPage.save(provider);
|
|
|
|
masthead.checkNotificationMessage(providerCreatedSuccess);
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
// create a new group
|
|
|
|
it("Create group", () => {
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
groupModal
|
2021-06-16 11:35:03 +00:00
|
|
|
.open("no-groups-in-this-realm-empty-action")
|
2021-04-28 05:50:41 +00:00
|
|
|
.fillGroupForm(groupName)
|
|
|
|
.clickCreate();
|
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
masthead.checkNotificationMessage(groupCreatedSuccess);
|
|
|
|
});
|
|
|
|
|
2021-06-04 16:33:38 +00:00
|
|
|
// create a new client and then new role for that client
|
|
|
|
it("Create client and role", () => {
|
2021-06-03 20:47:47 +00:00
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.goToCreateItem();
|
|
|
|
createClientPage
|
|
|
|
.selectClientType("openid-connect")
|
|
|
|
.fillClientData(clientName)
|
|
|
|
.continue()
|
|
|
|
.continue();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage(clientCreatedSuccess);
|
2021-06-04 16:33:38 +00:00
|
|
|
|
|
|
|
providersPage.createRole(roleName);
|
|
|
|
masthead.checkNotificationMessage(roleCreatedSuccess);
|
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.searchItem(clientName).itemExist(clientName);
|
2021-04-28 05:50:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// delete default mappers
|
2021-09-01 13:45:46 +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();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
listingPage.itemExist(creationDateMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(emailMapper).deleteItem(emailMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
listingPage.itemExist(emailMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(lastNameMapper).deleteItem(lastNameMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
listingPage.itemExist(lastNameMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(modifyDateMapper).deleteItem(modifyDateMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
listingPage.itemExist(modifyDateMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(usernameMapper).deleteItem(usernameMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
listingPage.itemExist(usernameMapper, false);
|
|
|
|
|
|
|
|
listingPage.itemExist(firstNameMapper).deleteItem(firstNameMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
|
|
|
listingPage.itemExist(firstNameMapper, false);
|
|
|
|
|
|
|
|
listingPage
|
|
|
|
.itemExist(MsadAccountControlsMapper)
|
|
|
|
.deleteItem(MsadAccountControlsMapper);
|
|
|
|
modalUtils.checkModalTitle(mapperDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(mapperDeletedSuccess);
|
2021-09-01 13:45:46 +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);
|
|
|
|
});
|
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
// create one of each mapper type
|
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 certificate ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(certLdapMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(certLdapMapper, 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 hardcoded attribute mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(hcAttMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(hcAttMapper, 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);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create hardcoded ldap group mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(hcLdapGroupMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(hcLdapGroupMapper, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create hardcoded ldap attribute mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(hcLdapAttMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(hcLdapAttMapper, 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-06-04 16:33:38 +00:00
|
|
|
|
|
|
|
it("Create hardcoded ldap role mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(hcLdapRoleMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(hcLdapRoleMapper, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Create role ldap mapper", () => {
|
|
|
|
providersPage.clickExistingCard(ldapName);
|
|
|
|
providersPage.goToMappers();
|
|
|
|
providersPage.createNewMapper(roleLdapMapper);
|
|
|
|
providersPage.save("ldap-mapper");
|
|
|
|
masthead.checkNotificationMessage(mapperCreatedSuccess);
|
|
|
|
listingPage.itemExist(roleLdapMapper, true);
|
|
|
|
});
|
2021-04-28 05:50:41 +00:00
|
|
|
});
|
|
|
|
|
2021-06-03 20:47:47 +00:00
|
|
|
// *** test cleanup ***
|
2021-04-28 05:50:41 +00:00
|
|
|
it("Cleanup - delete LDAP provider", () => {
|
|
|
|
providersPage.deleteCardFromMenu(provider, ldapName);
|
|
|
|
modalUtils.checkModalTitle(providerDeleteTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(providerDeleteSuccess);
|
|
|
|
});
|
2021-06-03 20:47:47 +00:00
|
|
|
|
|
|
|
it("Cleanup - delete group", () => {
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
listingPage.deleteItem(groupName);
|
2021-06-10 15:24:05 +00:00
|
|
|
modalUtils.checkModalTitle(groupDeleteTitle).confirmModal();
|
2021-06-03 20:47:47 +00:00
|
|
|
masthead.checkNotificationMessage(groupDeletedSuccess);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Cleanup - delete client", () => {
|
|
|
|
sidebarPage.goToClients();
|
|
|
|
listingPage.deleteItem(clientName);
|
|
|
|
modalUtils.checkModalTitle(`Delete ${clientName} ?`).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(clientDeletedSuccess);
|
|
|
|
});
|
2021-04-28 05:50:41 +00:00
|
|
|
});
|