From 4bf8930cd4ca4a40dc604cee9b27b703be67b0c3 Mon Sep 17 00:00:00 2001 From: mfrances Date: Fri, 4 Jun 2021 12:33:38 -0400 Subject: [PATCH] all user fed mappers tests passing --- .../user_fed_ldap_mapper_test.spec.ts | 54 +++++++-------- .../manage/providers/ProviderPage.ts | 66 ++++++++++++++----- 2 files changed, 78 insertions(+), 42 deletions(-) diff --git a/cypress/integration/user_fed_ldap_mapper_test.spec.ts b/cypress/integration/user_fed_ldap_mapper_test.spec.ts index 9804977d58..a923640351 100644 --- a/cypress/integration/user_fed_ldap_mapper_test.spec.ts +++ b/cypress/integration/user_fed_ldap_mapper_test.spec.ts @@ -47,8 +47,10 @@ const groupCreatedSuccess = "Group created"; const groupDeletedSuccess = "Group deleted"; const clientCreatedSuccess = "Client created successfully"; const clientDeletedSuccess = "The client has been deleted"; +const roleCreatedSuccess = "Role created"; const groupName = "aa-uf-mappers-group"; const clientName = "aa-uf-mappers-client"; +const roleName = "aa-uf-mappers-role"; // mapperType variables const msadUserAcctMapper = "msad-user-account-control-mapper"; @@ -61,10 +63,8 @@ const hcLdapGroupMapper = "hardcoded-ldap-group-mapper"; const hcLdapAttMapper = "hardcoded-ldap-attribute-mapper"; const groupLdapMapper = "group-ldap-mapper"; -/* -const roleMapper = "role-ldap-mapper"; +const roleLdapMapper = "role-ldap-mapper"; const hcLdapRoleMapper = "hardcoded-ldap-role-mapper"; -*/ const creationDateMapper = "creation date"; const emailMapper = "email"; @@ -105,9 +105,7 @@ describe("User Fed LDAP mapper tests", () => { firstUuidLdapAtt, firstUserObjClasses ); - providersPage.save(provider); - masthead.checkNotificationMessage(providerCreatedSuccess); sidebarPage.goToUserFederation(); }); @@ -123,8 +121,8 @@ describe("User Fed LDAP mapper tests", () => { masthead.checkNotificationMessage(groupCreatedSuccess); }); - // create a new client - it("Create client", () => { + // create a new client and then new role for that client + it("Create client and role", () => { sidebarPage.goToClients(); listingPage.goToCreateItem(); createClientPage @@ -134,6 +132,10 @@ describe("User Fed LDAP mapper tests", () => { .continue(); masthead.checkNotificationMessage(clientCreatedSuccess); + + providersPage.createRole(roleName); + masthead.checkNotificationMessage(roleCreatedSuccess); + sidebarPage.goToClients(); listingPage.searchItem(clientName).itemExist(clientName); }); @@ -286,26 +288,6 @@ describe("User Fed LDAP mapper tests", () => { listingPage.itemExist(hcLdapAttMapper, true); }); -/* COMING SOON - 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(roleMapper); - providersPage.save("ldap-mapper"); - masthead.checkNotificationMessage(mapperCreatedSuccess); - listingPage.itemExist(roleMapper, true); - }); -*/ - it("Create group ldap mapper", () => { providersPage.clickExistingCard(ldapName); providersPage.goToMappers(); @@ -313,6 +295,24 @@ describe("User Fed LDAP mapper tests", () => { providersPage.save("ldap-mapper"); masthead.checkNotificationMessage(mapperCreatedSuccess); listingPage.itemExist(groupLdapMapper, true); + + 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); + }); }); // *** test cleanup *** diff --git a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts index 630cb6421b..62465aef5f 100644 --- a/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts +++ b/cypress/support/pages/admin_console/manage/providers/ProviderPage.ts @@ -56,10 +56,27 @@ export default class ProviderPage { private hcLdapAttMapper = "hardcoded-ldap-attribute-mapper"; private hcLdapGroupMapper = "hardcoded-ldap-group-mapper"; private groupLdapMapper = "group-ldap-mapper"; - // this.roleMapper = "role-ldap-mapper"; - // this.hcLdapRoleMapper = "hardcoded-ldap-role-mapper"; + private roleLdapMapper = "role-ldap-mapper"; + private hcLdapRoleMapper = "hardcoded-ldap-role-mapper"; + + private tab = "#pf-tab-serviceAccount-serviceAccount"; + private scopeTab = "scopeTab"; + private assignRole = "assignRole"; + private unAssign = "unAssignRole"; + private assign = "assign"; + private hide = "#hideInheritedRoles"; + private assignedRolesTable = "assigned-roles"; + private namesColumn = 'td[data-label="Name"]:visible'; + + private rolesTab = "#pf-tab-roles-roles"; + private createRoleBtn = "data-testid=empty-primary-action"; + private realmRolesSaveBtn = "data-testid=realm-roles-save-button"; + private roleNameField = "#kc-name"; + private clientIdSelect = "#kc-client-id"; private groupName = "aa-uf-mappers-group"; + private clientName = "aa-uf-mappers-client"; + private roleName = "aa-uf-mappers-role"; changeCacheTime(unit: string, time: string) { switch (unit) { @@ -184,10 +201,21 @@ export default class ProviderPage { cy.get(`[data-testid="ldap-mappers-tab"]`).click(); } + createRole(roleName: string) { + cy.get(this.rolesTab).click(); + cy.wait(1000); + cy.get(`[${this.createRoleBtn}]`).click(); + cy.wait(1000); + cy.get(this.roleNameField).type(roleName); + cy.wait(1000); + cy.get(`[${this.realmRolesSaveBtn}]`).click(); + cy.wait(1000); + } + createNewMapper(mapperType: string) { const userModelAttValue = "firstName"; const ldapAttValue = "cn"; - const ldapDnValue = "ou=groups" + const ldapDnValue = "ou=groups"; cy.get(`[data-testid="add-mapper-btn"]`).click(); cy.wait(1000); @@ -223,10 +251,26 @@ export default class ProviderPage { case this.groupLdapMapper: cy.get(`[${this.ldapDnInput}]`).type(ldapDnValue); break; - // case this.roleMapper: - // break; - // case this.hcLdapRoleMapper: - // break; + + case this.roleLdapMapper: + cy.get(`[${this.ldapDnInput}]`).type(ldapDnValue); + // cy select clientID dropdown and choose clientName (var) + cy.get(this.clientIdSelect).click(); + cy.get("button").contains(this.clientName).click({ force: true }); + break; + + case this.hcLdapRoleMapper: + cy.get(`[data-testid="selectRole"]`).click(); + cy.wait(2000); + cy.get(this.namesColumn) + .contains(this.clientName) + .parent() + .parent() + .within(() => { + cy.get('input[name="radioGroup"]').click(); + }); + cy.getId(this.assign).click(); + break; default: console.log("Invalid mapper type."); break; @@ -264,14 +308,6 @@ export default class ProviderPage { cy.get(`[${this.ldapAttValueInput}]`).clear; cy.get(`[${this.ldapAttValueInput}]`).type(ldapAttValue); break; - // case this.hcLdapGroupMapper: - // break; - // case this.groupLdapMapper: - // break; - // case this.roleMapper: - // break; - // case this.hcLdapRoleMapper: - // break; default: console.log("Invalid mapper name."); break;