Merge pull request #419 from mfrances17/issue-376

User fed cypress tests should not fail if there are existing providers on the system
This commit is contained in:
mfrances17 2021-03-08 09:04:31 -05:00 committed by GitHub
commit 39b629eff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 162 additions and 262 deletions

View file

@ -1,15 +1,18 @@
import LoginPage from "../support/pages/LoginPage"; import LoginPage from "../support/pages/LoginPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage"; import SidebarPage from "../support/pages/admin_console/SidebarPage";
import CreateKerberosProviderPage from "../support/pages/admin_console/manage/providers/CreateKerberosProviderPage"; import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
import Masthead from "../support/pages/admin_console/Masthead"; import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils"; import ModalUtils from "../support/util/ModalUtils";
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const masthead = new Masthead(); const masthead = new Masthead();
const sidebarPage = new SidebarPage(); const sidebarPage = new SidebarPage();
const providersPage = new CreateKerberosProviderPage(); const providersPage = new ProviderPage();
const modalUtils = new ModalUtils(); const modalUtils = new ModalUtils();
const provider = "kerberos";
const initCapProvider = provider.charAt(0).toUpperCase() + provider.slice(1);
const firstKerberosName = "my-kerberos"; const firstKerberosName = "my-kerberos";
const firstKerberosRealm = "my-realm"; const firstKerberosRealm = "my-realm";
const firstKerberosPrincipal = "my-principal"; const firstKerberosPrincipal = "my-principal";
@ -29,6 +32,7 @@ const newKerberosDay = "Wednesday";
const newKerberosHour = "15"; const newKerberosHour = "15";
const newKerberosMinute = "55"; const newKerberosMinute = "55";
const addProviderMenu = "Add new provider";
const createdSuccessMessage = "User federation provider successfully created"; const createdSuccessMessage = "User federation provider successfully created";
const savedSuccessMessage = "User federation provider successfully saved"; const savedSuccessMessage = "User federation provider successfully saved";
const deletedSuccessMessage = "The user federation provider has been deleted."; const deletedSuccessMessage = "The user federation provider has been deleted.";
@ -36,189 +40,129 @@ const deleteModalTitle = "Delete user federation provider?";
const disableModalTitle = "Disable user federation provider?"; const disableModalTitle = "Disable user federation provider?";
describe("User Fed Kerberos tests", () => { describe("User Fed Kerberos tests", () => {
it("Create Kerberos provider from empty state", () => { beforeEach(() => {
/*
Prevent unpredictable 401 errors from failing individual tests.
These are most often occurring during the login process:
GET /admin/serverinfo/
GET /admin/master/console/whoami
*/
cy.on("uncaught:exception", (err, runnable) => {
return false;
});
cy.visit(""); cy.visit("");
loginPage.logIn(); loginPage.logIn();
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.get("[data-testid=kerberos-card]").click(); });
it("Create Kerberos 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=kerberos-card]`).length > 0) {
providersPage.clickNewCard(provider);
} else {
providersPage.clickMenuCommand(addProviderMenu, initCapProvider);
}
});
providersPage.fillKerberosRequiredData( providersPage.fillKerberosRequiredData(
firstKerberosName, firstKerberosName,
firstKerberosRealm, firstKerberosRealm,
firstKerberosPrincipal, firstKerberosPrincipal,
firstKerberosKeytab firstKerberosKeytab
); );
providersPage.save(); providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage); masthead.checkNotificationMessage(createdSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
}); });
it("Update an existing Kerberos provider and save", () => { it("Update an existing Kerberos provider and save", () => {
cy.visit(""); providersPage.clickExistingCard(firstKerberosName);
loginPage.logIn();
sidebarPage.goToUserFederation();
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
providersPage.changeCacheTime("day", newKerberosDay);
providersPage.changeCacheTime("hour", newKerberosHour);
providersPage.changeCacheTime("minute", newKerberosMinute);
providersPage.save(provider);
cy.contains(defaultKerberosDay).click();
cy.contains(newKerberosDay).click();
cy.contains(defaultKerberosHour).click();
cy.contains(newKerberosHour).click();
cy.contains(defaultKerberosMinute).click();
cy.contains(newKerberosMinute).click();
providersPage.save();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000); providersPage.clickExistingCard(firstKerberosName);
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000);
expect(cy.contains(newPolicy).should("exist")); expect(cy.contains(newPolicy).should("exist"));
expect(cy.contains(defaultPolicy).should("not.exist")); expect(cy.contains(defaultPolicy).should("not.exist"));
}); });
it("Change existing Kerberos provider and click button to cancel", () => { it("Change existing Kerberos provider and click button to cancel", () => {
cy.visit(""); providersPage.clickExistingCard(firstKerberosName);
loginPage.logIn();
sidebarPage.goToUserFederation();
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
providersPage.changeCacheTime("day", defaultKerberosDay);
cy.contains(newKerberosDay).click(); providersPage.changeCacheTime("hour", defaultKerberosHour);
cy.contains(defaultKerberosDay).click(); providersPage.changeCacheTime("minute", defaultKerberosMinute);
providersPage.cancel(provider);
cy.contains(newKerberosHour).click();
cy.contains(defaultKerberosHour).click();
cy.contains(newKerberosMinute).click();
cy.contains(defaultKerberosMinute).click();
providersPage.cancel();
cy.wait(1000);
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000); cy.wait(1000);
providersPage.clickExistingCard(firstKerberosName);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
expect(cy.contains(newKerberosDay).should("exist")); expect(cy.contains(newKerberosDay).should("exist"));
expect(cy.contains(newKerberosHour).should("exist")); expect(cy.contains(newKerberosHour).should("exist"));
expect(cy.contains(newKerberosMinute).should("exist")); expect(cy.contains(newKerberosMinute).should("exist"));
expect(cy.contains(defaultKerberosMinute).should("not.exist")); expect(cy.contains(defaultKerberosMinute).should("not.exist"));
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
}); });
it("Disable an existing Kerberos provider", () => { it("Disable an existing Kerberos provider", () => {
cy.visit(""); providersPage.clickExistingCard(firstKerberosName);
loginPage.logIn(); providersPage.disableEnabledSwitch(initCapProvider);
sidebarPage.goToUserFederation();
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000);
providersPage.disableEnabledSwitch();
modalUtils.checkModalTitle(disableModalTitle).confirmModal(); modalUtils.checkModalTitle(disableModalTitle).confirmModal();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000);
expect(cy.contains("Disabled").should("exist")); expect(cy.contains("Disabled").should("exist"));
}); });
it("Enable an existing previously-disabled Kerberos provider", () => { it("Enable an existing previously-disabled Kerberos provider", () => {
cy.visit(""); providersPage.clickExistingCard(firstKerberosName);
loginPage.logIn(); providersPage.enableEnabledSwitch(initCapProvider);
sidebarPage.goToUserFederation();
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000);
providersPage.enableEnabledSwitch();
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000);
expect(cy.contains("Enabled").should("exist")); expect(cy.contains("Enabled").should("exist"));
}); });
it("Create new Kerberos provider using the New Provider dropdown", () => { it("Create new Kerberos provider using the New Provider dropdown", () => {
cy.visit(""); providersPage.clickMenuCommand(addProviderMenu, initCapProvider);
loginPage.logIn();
sidebarPage.goToUserFederation();
cy.contains("Add new provider").click();
cy.contains("Kerberos").click();
providersPage.fillKerberosRequiredData( providersPage.fillKerberosRequiredData(
secondKerberosName, secondKerberosName,
secondKerberosRealm, secondKerberosRealm,
secondKerberosPrincipal, secondKerberosPrincipal,
secondKerberosKeytab secondKerberosKeytab
); );
providersPage.save(); providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage);
masthead.checkNotificationMessage(createdSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
}); });
it("Delete a Kerberos provider from card view using the card's menu", () => { it("Delete a Kerberos provider from card view using the card's menu", () => {
cy.visit(""); providersPage.deleteCardFromCard(secondKerberosName);
loginPage.logIn();
sidebarPage.goToUserFederation();
cy.get('[data-testid="my-kerberos-2-dropdown"]').click();
cy.get('[data-testid="card-delete"]').click();
modalUtils.checkModalTitle(deleteModalTitle).confirmModal(); modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
masthead.checkNotificationMessage(deletedSuccessMessage); masthead.checkNotificationMessage(deletedSuccessMessage);
}); });
it("Delete a Kerberos provider using the Settings view's Action menu", () => { it("Delete a Kerberos provider using the Settings view's Action menu", () => {
cy.visit(""); providersPage.deleteCardFromMenu(provider, firstKerberosName);
loginPage.logIn();
sidebarPage.goToUserFederation();
cy.get('[data-testid="keycloak-card-title"]')
.contains(firstKerberosName)
.click();
cy.wait(1000);
cy.get('[data-testid="action-dropdown"]').click();
cy.get('[data-testid="delete-kerberos-cmd"]').click();
modalUtils.checkModalTitle(deleteModalTitle).confirmModal(); modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
masthead.checkNotificationMessage(deletedSuccessMessage); masthead.checkNotificationMessage(deletedSuccessMessage);
}); });
}); });

View file

@ -1,15 +1,18 @@
import LoginPage from "../support/pages/LoginPage"; import LoginPage from "../support/pages/LoginPage";
import SidebarPage from "../support/pages/admin_console/SidebarPage"; import SidebarPage from "../support/pages/admin_console/SidebarPage";
import CreateLdapProviderPage from "../support/pages/admin_console/manage/providers/CreateLdapProviderPage"; import ProviderPage from "../support/pages/admin_console/manage/providers/ProviderPage";
import Masthead from "../support/pages/admin_console/Masthead"; import Masthead from "../support/pages/admin_console/Masthead";
import ModalUtils from "../support/util/ModalUtils"; import ModalUtils from "../support/util/ModalUtils";
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const masthead = new Masthead(); const masthead = new Masthead();
const sidebarPage = new SidebarPage(); const sidebarPage = new SidebarPage();
const providersPage = new CreateLdapProviderPage(); const providersPage = new ProviderPage();
const modalUtils = new ModalUtils(); const modalUtils = new ModalUtils();
const provider = "ldap";
const allCapProvider = provider.toUpperCase();
const firstLdapName = "my-ldap"; const firstLdapName = "my-ldap";
const firstLdapVendor = "Active Directory"; const firstLdapVendor = "Active Directory";
@ -46,6 +49,7 @@ const newLdapDay = "Wednesday";
const newLdapHour = "15"; const newLdapHour = "15";
const newLdapMinute = "55"; const newLdapMinute = "55";
const addProviderMenu = "Add new provider";
const createdSuccessMessage = "User federation provider successfully created"; const createdSuccessMessage = "User federation provider successfully created";
const savedSuccessMessage = "User federation provider successfully saved"; const savedSuccessMessage = "User federation provider successfully saved";
const deletedSuccessMessage = "The user federation provider has been deleted."; const deletedSuccessMessage = "The user federation provider has been deleted.";
@ -69,7 +73,15 @@ describe("User Fed LDAP tests", () => {
}); });
it("Create Ldap provider from empty state", () => { it("Create Ldap provider from empty state", () => {
providersPage.clickNewCard("ldap"); // 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(firstLdapName, firstLdapVendor); providersPage.fillLdapRequiredGeneralData(firstLdapName, firstLdapVendor);
providersPage.fillLdapRequiredConnectionData( providersPage.fillLdapRequiredConnectionData(
connectionUrl, connectionUrl,
@ -85,7 +97,7 @@ describe("User Fed LDAP tests", () => {
firstUserObjClasses firstUserObjClasses
); );
providersPage.save(); providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage); masthead.checkNotificationMessage(createdSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
@ -95,16 +107,14 @@ describe("User Fed LDAP tests", () => {
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
providersPage.changeTime(defaultLdapDay, newLdapDay); providersPage.changeCacheTime("day", newLdapDay);
providersPage.changeTime(defaultLdapHour, newLdapHour); providersPage.changeCacheTime("hour", newLdapHour);
providersPage.changeTime(defaultLdapMinute, newLdapMinute); providersPage.changeCacheTime("minute", newLdapMinute);
providersPage.save(); providersPage.save(provider);
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000);
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
expect(cy.contains(newPolicy).should("exist")); expect(cy.contains(newPolicy).should("exist"));
@ -115,11 +125,11 @@ describe("User Fed LDAP tests", () => {
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.selectCacheType(newPolicy); providersPage.selectCacheType(newPolicy);
providersPage.changeTime(newLdapDay, defaultLdapDay); providersPage.changeCacheTime("day", defaultLdapDay);
providersPage.changeTime(newLdapHour, defaultLdapHour); providersPage.changeCacheTime("hour", defaultLdapHour);
providersPage.changeTime(newLdapMinute, defaultLdapMinute); providersPage.changeCacheTime("minute", defaultLdapMinute);
providersPage.cancel(); providersPage.cancel(provider);
cy.wait(1000); cy.wait(1000);
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
@ -135,7 +145,7 @@ describe("User Fed LDAP tests", () => {
it("Disable an existing LDAP provider", () => { it("Disable an existing LDAP provider", () => {
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.disableEnabledSwitch(); providersPage.disableEnabledSwitch(allCapProvider);
modalUtils.checkModalTitle(disableModalTitle).confirmModal(); modalUtils.checkModalTitle(disableModalTitle).confirmModal();
@ -144,23 +154,21 @@ describe("User Fed LDAP tests", () => {
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000);
expect(cy.contains("Disabled").should("exist")); expect(cy.contains("Disabled").should("exist"));
}); });
it("Enable an existing previously-disabled LDAP provider", () => { it("Enable an existing previously-disabled LDAP provider", () => {
providersPage.clickExistingCard(firstLdapName); providersPage.clickExistingCard(firstLdapName);
providersPage.enableEnabledSwitch(); providersPage.enableEnabledSwitch(allCapProvider);
masthead.checkNotificationMessage(savedSuccessMessage); masthead.checkNotificationMessage(savedSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
cy.wait(1000);
expect(cy.contains("Enabled").should("exist")); expect(cy.contains("Enabled").should("exist"));
}); });
it("Create new LDAP provider using the New Provider dropdown", () => { it("Create new LDAP provider using the New Provider dropdown", () => {
providersPage.clickMenuCommand("Add new provider", "LDAP"); providersPage.clickMenuCommand(addProviderMenu, allCapProvider);
providersPage.fillLdapRequiredGeneralData(secondLdapName, secondLdapVendor); providersPage.fillLdapRequiredGeneralData(secondLdapName, secondLdapVendor);
providersPage.fillLdapRequiredConnectionData( providersPage.fillLdapRequiredConnectionData(
connectionUrl, connectionUrl,
@ -175,7 +183,7 @@ describe("User Fed LDAP tests", () => {
secondUuidLdapAtt, secondUuidLdapAtt,
secondUserObjClasses secondUserObjClasses
); );
providersPage.save(); providersPage.save(provider);
masthead.checkNotificationMessage(createdSuccessMessage); masthead.checkNotificationMessage(createdSuccessMessage);
sidebarPage.goToUserFederation(); sidebarPage.goToUserFederation();
}); });
@ -187,7 +195,7 @@ describe("User Fed LDAP tests", () => {
}); });
it("Delete an LDAP provider using the Settings view's Action menu", () => { it("Delete an LDAP provider using the Settings view's Action menu", () => {
providersPage.deleteCardFromMenu(firstLdapName); providersPage.deleteCardFromMenu(provider, firstLdapName);
modalUtils.checkModalTitle(deleteModalTitle).confirmModal(); modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
masthead.checkNotificationMessage(deletedSuccessMessage); masthead.checkNotificationMessage(deletedSuccessMessage);
}); });

View file

@ -113,6 +113,7 @@ export default class SidebarPage {
goToUserFederation() { goToUserFederation() {
cy.get(this.userFederationBtn).click(); cy.get(this.userFederationBtn).click();
cy.wait(1000);
return this; return this;
} }

View file

@ -1,87 +0,0 @@
export default class CreateKerberosProviderPage {
kerberosNameInput: string;
kerberosRealmInput: string;
kerberosPrincipalInput: string;
kerberosKeytabInput: string;
kerberosEnabledInput: string;
kerberosCacheDayInput: string;
kerberosCacheDayList: string;
kerberosCacheHourInput: string;
kerberosCacheHourList: string;
kerberosCacheMinuteInput: string;
kerberosCacheMinuteList: string;
kerberosCachePolicyInput: string;
kerberosCachePolicyList: string;
saveBtn: string;
cancelBtn: string;
constructor() {
this.kerberosNameInput = "data-testid=kerberos-name";
this.kerberosRealmInput = "data-testid=kerberos-realm";
this.kerberosPrincipalInput = "data-testid=kerberos-principal";
this.kerberosKeytabInput = "data-testid=kerberos-keytab";
this.kerberosEnabledInput = "#Kerberos-switch";
this.kerberosCacheDayInput = "#kc-eviction-day";
this.kerberosCacheDayList = "#kc-eviction-day + ul";
this.kerberosCacheHourInput = "#kc-eviction-hour";
this.kerberosCacheHourList = "#kc-eviction-hour + ul";
this.kerberosCacheMinuteInput = "#kc-eviction-minute";
this.kerberosCacheMinuteList = "#kc-eviction-minute + ul";
this.kerberosCachePolicyInput = "#kc-cache-policy";
this.kerberosCachePolicyList = "#kc-cache-policy + ul";
this.saveBtn = "data-testid=kerberos-save";
this.cancelBtn = "data-testid=kerberos-cancel";
}
//#region Required Settings
fillKerberosRequiredData(
name: string,
realm: string,
principal: string,
keytab: string
) {
if (name) {
cy.get(`[${this.kerberosNameInput}]`).type(name);
}
if (realm) {
cy.get(`[${this.kerberosRealmInput}]`).type(realm);
}
if (principal) {
cy.get(`[${this.kerberosPrincipalInput}]`).type(principal);
}
if (keytab) {
cy.get(`[${this.kerberosKeytabInput}]`).type(keytab);
}
return this;
}
selectCacheType(cacheType: string) {
cy.get(this.kerberosCachePolicyInput).click();
cy.get(this.kerberosCachePolicyList).contains(cacheType).click();
return this;
}
disableEnabledSwitch() {
cy.get(this.kerberosEnabledInput).uncheck({ force: true });
}
enableEnabledSwitch() {
cy.get(this.kerberosEnabledInput).check({ force: true });
}
save() {
cy.get(`[${this.saveBtn}]`).click();
return this;
}
cancel() {
cy.get(`[${this.cancelBtn}]`).click();
return this;
}
}

View file

@ -1,4 +1,9 @@
export default class CreateLdapProviderPage { export default class ProviderPage {
kerberosNameInput: string;
kerberosRealmInput: string;
kerberosPrincipalInput: string;
kerberosKeytabInput: string;
ldapNameInput: string; ldapNameInput: string;
ldapVendorInput: string; ldapVendorInput: string;
ldapVendorList: string; ldapVendorList: string;
@ -15,21 +20,22 @@ export default class CreateLdapProviderPage {
ldapUuidLdapAttInput: string; ldapUuidLdapAttInput: string;
ldapUserObjClassesInput: string; ldapUserObjClassesInput: string;
ldapEnabledInput: string; cacheDayInput: string;
cacheDayList: string;
ldapCacheDayInput: string; cacheHourInput: string;
ldapCacheDayList: string; cacheHourList: string;
ldapCacheHourInput: string; cacheMinuteInput: string;
ldapCacheHourList: string; cacheMinuteList: string;
ldapCacheMinuteInput: string; cachePolicyInput: string;
ldapCacheMinuteList: string; cachePolicyList: string;
ldapCachePolicyInput: string;
ldapCachePolicyList: string;
saveBtn: string;
cancelBtn: string;
constructor() { constructor() {
// KerberosSettingsRequired required input values
this.kerberosNameInput = "data-testid=kerberos-name";
this.kerberosRealmInput = "data-testid=kerberos-realm";
this.kerberosPrincipalInput = "data-testid=kerberos-principal";
this.kerberosKeytabInput = "data-testid=kerberos-keytab";
// LdapSettingsGeneral required input values // LdapSettingsGeneral required input values
this.ldapNameInput = "data-testid=ldap-name"; this.ldapNameInput = "data-testid=ldap-name";
this.ldapVendorInput = "#kc-vendor"; this.ldapVendorInput = "#kc-vendor";
@ -50,26 +56,34 @@ export default class CreateLdapProviderPage {
this.ldapUserObjClassesInput = "data-testid=ldap-user-object-classes"; this.ldapUserObjClassesInput = "data-testid=ldap-user-object-classes";
// SettingsCache input values // SettingsCache input values
this.ldapCacheDayInput = "#kc-eviction-day"; this.cacheDayInput = "#kc-eviction-day";
this.ldapCacheDayList = "#kc-eviction-day + ul"; this.cacheDayList = "#kc-eviction-day + ul";
this.ldapCacheHourInput = "#kc-eviction-hour"; this.cacheHourInput = "#kc-eviction-hour";
this.ldapCacheHourList = "#kc-eviction-hour + ul"; this.cacheHourList = "#kc-eviction-hour + ul";
this.ldapCacheMinuteInput = "#kc-eviction-minute"; this.cacheMinuteInput = "#kc-eviction-minute";
this.ldapCacheMinuteList = "#kc-eviction-minute + ul"; this.cacheMinuteList = "#kc-eviction-minute + ul";
this.ldapCachePolicyInput = "#kc-cache-policy"; this.cachePolicyInput = "#kc-cache-policy";
this.ldapCachePolicyList = "#kc-cache-policy + ul"; this.cachePolicyList = "#kc-cache-policy + ul";
// LDAP settings enabled switch
this.ldapEnabledInput = "#LDAP-switch";
// LDAP action buttons
this.saveBtn = "data-testid=ldap-save";
this.cancelBtn = "data-testid=ldap-cancel";
} }
changeTime(oldTime: string, newTime: string) { changeCacheTime(unit: string, time: string) {
cy.contains(oldTime).click(); switch (unit) {
cy.contains(newTime).click(); case "day":
cy.get(this.cacheDayInput).click();
cy.get(this.cacheDayList).contains(time).click();
break;
case "hour":
cy.get(this.cacheHourInput).click();
cy.get(this.cacheHourList).contains(time).click();
break;
case "minute":
cy.get(this.cacheMinuteInput).click();
cy.get(this.cacheMinuteList).contains(time).click();
break;
default:
console.log("Invalid cache time, must be 'day', 'hour', or 'minute'.");
break;
}
return this; return this;
} }
@ -79,14 +93,34 @@ export default class CreateLdapProviderPage {
return this; return this;
} }
deleteCardFromMenu(card: string) { deleteCardFromMenu(providerType: string, card: string) {
this.clickExistingCard(card); this.clickExistingCard(card);
cy.get('[data-testid="action-dropdown"]').click(); cy.get('[data-testid="action-dropdown"]').click();
cy.get('[data-testid="delete-ldap-cmd"]').click(); cy.get(`[data-testid="delete-${providerType}-cmd"]`).click();
return this;
}
fillKerberosRequiredData(
name: string,
realm: string,
principal: string,
keytab: string
) {
if (name) {
cy.get(`[${this.kerberosNameInput}]`).type(name);
}
if (realm) {
cy.get(`[${this.kerberosRealmInput}]`).type(realm);
}
if (principal) {
cy.get(`[${this.kerberosPrincipalInput}]`).type(principal);
}
if (keytab) {
cy.get(`[${this.kerberosKeytabInput}]`).type(keytab);
}
return this; return this;
} }
// Required fields - these always must be filled out when testing a save
fillLdapRequiredGeneralData(name: string, vendor: string) { fillLdapRequiredGeneralData(name: string, vendor: string) {
if (name) { if (name) {
cy.get(`[${this.ldapNameInput}]`).type(name); cy.get(`[${this.ldapNameInput}]`).type(name);
@ -146,8 +180,8 @@ export default class CreateLdapProviderPage {
} }
selectCacheType(cacheType: string) { selectCacheType(cacheType: string) {
cy.get(this.ldapCachePolicyInput).click(); cy.get(this.cachePolicyInput).click();
cy.get(this.ldapCachePolicyList).contains(cacheType).click(); cy.get(this.cachePolicyList).contains(cacheType).click();
return this; return this;
} }
@ -169,23 +203,23 @@ export default class CreateLdapProviderPage {
return this; return this;
} }
disableEnabledSwitch() { disableEnabledSwitch(providerType: string) {
cy.get(this.ldapEnabledInput).uncheck({ force: true }); cy.get(`#${providerType}-switch`).uncheck({ force: true });
return this; return this;
} }
enableEnabledSwitch() { enableEnabledSwitch(providerType: string) {
cy.get(this.ldapEnabledInput).check({ force: true }); cy.get(`#${providerType}-switch`).check({ force: true });
return this; return this;
} }
save() { save(providerType: string) {
cy.get(`[${this.saveBtn}]`).click(); cy.get(`[data-testid=${providerType}-save]`).click();
return this; return this;
} }
cancel() { cancel(providerType: string) {
cy.get(`[${this.cancelBtn}]`).click(); cy.get(`[data-testid=${providerType}-cancel]`).click();
return this; return this;
} }
} }