2021-02-15 19:35:25 +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-16 19:42:30 +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-15 19:35:25 +00:00
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
2021-02-16 19:42:30 +00:00
|
|
|
const masthead = new Masthead();
|
2021-02-15 19:35:25 +00:00
|
|
|
const sidebarPage = new SidebarPage();
|
2021-03-05 20:55:01 +00:00
|
|
|
const providersPage = new ProviderPage();
|
2021-02-16 19:42:30 +00:00
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
const provider = "kerberos";
|
|
|
|
const initCapProvider = provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
const firstKerberosName = "my-kerberos";
|
|
|
|
const firstKerberosRealm = "my-realm";
|
|
|
|
const firstKerberosPrincipal = "my-principal";
|
|
|
|
const firstKerberosKeytab = "my-keytab";
|
|
|
|
|
|
|
|
const secondKerberosName = `${firstKerberosName}-2`;
|
|
|
|
const secondKerberosRealm = `${firstKerberosRealm}-2`;
|
|
|
|
const secondKerberosPrincipal = `${firstKerberosPrincipal}-2`;
|
|
|
|
const secondKerberosKeytab = `${firstKerberosKeytab}-2`;
|
|
|
|
|
|
|
|
const defaultPolicy = "DEFAULT";
|
|
|
|
const newPolicy = "EVICT_WEEKLY";
|
|
|
|
const defaultKerberosDay = "Sunday";
|
|
|
|
const defaultKerberosHour = "00";
|
|
|
|
const defaultKerberosMinute = "00";
|
|
|
|
const newKerberosDay = "Wednesday";
|
|
|
|
const newKerberosHour = "15";
|
|
|
|
const newKerberosMinute = "55";
|
|
|
|
|
2021-03-05 20:55:01 +00:00
|
|
|
const addProviderMenu = "Add new provider";
|
2021-02-16 19:42:30 +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 Kerberos tests", () => {
|
2021-03-05 16:36:49 +00:00
|
|
|
beforeEach(() => {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
2021-02-16 19:42:30 +00:00
|
|
|
|
2021-03-05 16:36:49 +00:00
|
|
|
it("Create Kerberos 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=kerberos-card]`).length > 0) {
|
|
|
|
providersPage.clickNewCard(provider);
|
|
|
|
} else {
|
|
|
|
providersPage.clickMenuCommand(addProviderMenu, initCapProvider);
|
|
|
|
}
|
|
|
|
});
|
2021-02-16 19:42:30 +00:00
|
|
|
providersPage.fillKerberosRequiredData(
|
|
|
|
firstKerberosName,
|
|
|
|
firstKerberosRealm,
|
|
|
|
firstKerberosPrincipal,
|
|
|
|
firstKerberosKeytab
|
|
|
|
);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.save(provider);
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
masthead.checkNotificationMessage(createdSuccessMessage);
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
it("Update an existing Kerberos provider and save", () => {
|
2021-03-05 16:36:49 +00:00
|
|
|
providersPage.clickExistingCard(firstKerberosName);
|
2021-02-16 19:42:30 +00:00
|
|
|
providersPage.selectCacheType(newPolicy);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.changeCacheTime("day", newKerberosDay);
|
|
|
|
providersPage.changeCacheTime("hour", newKerberosHour);
|
|
|
|
providersPage.changeCacheTime("minute", newKerberosMinute);
|
|
|
|
providersPage.save(provider);
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-03-05 16:36:49 +00:00
|
|
|
masthead.checkNotificationMessage(savedSuccessMessage);
|
2021-02-16 19:42:30 +00:00
|
|
|
sidebarPage.goToUserFederation();
|
2021-03-05 16:36:49 +00:00
|
|
|
providersPage.clickExistingCard(firstKerberosName);
|
2021-02-16 19:42:30 +00:00
|
|
|
|
|
|
|
expect(cy.contains(newPolicy).should("exist"));
|
|
|
|
expect(cy.contains(defaultPolicy).should("not.exist"));
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Change existing Kerberos provider and click button to cancel", () => {
|
2021-03-05 16:36:49 +00:00
|
|
|
providersPage.clickExistingCard(firstKerberosName);
|
2021-02-16 19:42:30 +00:00
|
|
|
providersPage.selectCacheType(newPolicy);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.changeCacheTime("day", defaultKerberosDay);
|
|
|
|
providersPage.changeCacheTime("hour", defaultKerberosHour);
|
|
|
|
providersPage.changeCacheTime("minute", defaultKerberosMinute);
|
|
|
|
providersPage.cancel(provider);
|
2021-02-16 19:42:30 +00:00
|
|
|
cy.wait(1000);
|
2021-03-05 16:36:49 +00:00
|
|
|
|
|
|
|
providersPage.clickExistingCard(firstKerberosName);
|
2021-02-16 19:42:30 +00:00
|
|
|
providersPage.selectCacheType(newPolicy);
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
expect(cy.contains(newKerberosDay).should("exist"));
|
|
|
|
expect(cy.contains(newKerberosHour).should("exist"));
|
|
|
|
expect(cy.contains(newKerberosMinute).should("exist"));
|
|
|
|
expect(cy.contains(defaultKerberosMinute).should("not.exist"));
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
it("Disable an existing Kerberos provider", () => {
|
2021-03-05 16:36:49 +00:00
|
|
|
providersPage.clickExistingCard(firstKerberosName);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.disableEnabledSwitch(initCapProvider);
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
modalUtils.checkModalTitle(disableModalTitle).confirmModal();
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
masthead.checkNotificationMessage(savedSuccessMessage);
|
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
masthead.checkNotificationMessage(savedSuccessMessage);
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
expect(cy.contains("Disabled").should("exist"));
|
|
|
|
});
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
it("Enable an existing previously-disabled Kerberos provider", () => {
|
2021-03-05 16:36:49 +00:00
|
|
|
providersPage.clickExistingCard(firstKerberosName);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.enableEnabledSwitch(initCapProvider);
|
2021-03-05 16:36:49 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
masthead.checkNotificationMessage(savedSuccessMessage);
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
expect(cy.contains("Enabled").should("exist"));
|
|
|
|
});
|
2021-02-15 19:35:25 +00:00
|
|
|
|
2021-02-16 19:42:30 +00:00
|
|
|
it("Create new Kerberos provider using the New Provider dropdown", () => {
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.clickMenuCommand(addProviderMenu, initCapProvider);
|
2021-02-16 19:42:30 +00:00
|
|
|
|
|
|
|
providersPage.fillKerberosRequiredData(
|
|
|
|
secondKerberosName,
|
|
|
|
secondKerberosRealm,
|
|
|
|
secondKerberosPrincipal,
|
|
|
|
secondKerberosKeytab
|
|
|
|
);
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.save(provider);
|
2021-02-16 19:42:30 +00:00
|
|
|
|
2021-03-05 16:36:49 +00:00
|
|
|
masthead.checkNotificationMessage(createdSuccessMessage);
|
2021-02-16 19:42:30 +00:00
|
|
|
sidebarPage.goToUserFederation();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Delete a Kerberos provider from card view using the card's menu", () => {
|
2021-03-05 16:36:49 +00:00
|
|
|
providersPage.deleteCardFromCard(secondKerberosName);
|
2021-02-16 19:42:30 +00:00
|
|
|
|
|
|
|
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(deletedSuccessMessage);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Delete a Kerberos provider using the Settings view's Action menu", () => {
|
2021-03-05 20:55:01 +00:00
|
|
|
providersPage.deleteCardFromMenu(provider, firstKerberosName);
|
2021-02-16 19:42:30 +00:00
|
|
|
|
|
|
|
modalUtils.checkModalTitle(deleteModalTitle).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(deletedSuccessMessage);
|
|
|
|
});
|
|
|
|
});
|