2022-12-07 15:28:28 +00:00
|
|
|
import Masthead from "../support/pages/admin-ui/Masthead";
|
|
|
|
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
2021-12-06 10:50:29 +00:00
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2022-01-07 07:27:58 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2022-12-07 15:28:28 +00:00
|
|
|
import ListingPage from "../support/pages/admin-ui/ListingPage";
|
|
|
|
import CreateProviderPage from "../support/pages/admin-ui/manage/identity_providers/CreateProviderPage";
|
2021-12-06 10:50:29 +00:00
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2022-12-07 15:28:28 +00:00
|
|
|
import AddMapperPage from "../support/pages/admin-ui/manage/identity_providers/AddMapperPage";
|
|
|
|
import ProviderSAMLSettings from "../support/pages/admin-ui/manage/identity_providers/social/ProviderSAMLSettings";
|
2021-12-06 10:50:29 +00:00
|
|
|
|
2022-03-16 11:25:01 +00:00
|
|
|
describe("SAML identity provider test", () => {
|
2021-12-06 10:50:29 +00:00
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
const createProviderPage = new CreateProviderPage();
|
|
|
|
const addMapperPage = new AddMapperPage();
|
|
|
|
|
|
|
|
const createSuccessMsg = "Identity provider successfully created";
|
2022-03-16 11:25:01 +00:00
|
|
|
const saveSuccessMsg = "Provider successfully updated";
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
const createMapperSuccessMsg = "Mapper created successfully.";
|
|
|
|
const saveMapperSuccessMsg = "Mapper saved successfully.";
|
|
|
|
|
|
|
|
const deletePrompt = "Delete provider?";
|
2022-04-21 12:57:30 +00:00
|
|
|
const deleteSuccessMsg = "Provider successfully deleted.";
|
2021-12-06 10:50:29 +00:00
|
|
|
|
2022-03-16 11:25:01 +00:00
|
|
|
const classRefName = "acClassRef-1";
|
|
|
|
const declRefName = "acDeclRef-1";
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
const keycloakServer = Cypress.env("KEYCLOAK_SERVER");
|
2022-03-06 15:25:37 +00:00
|
|
|
const samlDiscoveryUrl = `${keycloakServer}/realms/master/protocol/saml/descriptor`;
|
2022-12-20 11:42:59 +00:00
|
|
|
const samlDisplayName = "saml";
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
describe("SAML identity provider creation", () => {
|
|
|
|
const samlProviderName = "saml";
|
|
|
|
|
2022-12-14 07:45:13 +00:00
|
|
|
beforeEach(() => {
|
2023-02-10 10:10:35 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
keycloakBefore();
|
2021-12-06 10:50:29 +00:00
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
});
|
|
|
|
|
2022-03-16 11:25:01 +00:00
|
|
|
it("should create a SAML provider using entity descriptor", () => {
|
2021-12-06 10:50:29 +00:00
|
|
|
createProviderPage
|
2022-03-16 11:25:01 +00:00
|
|
|
.checkVisible(samlProviderName)
|
|
|
|
.clickCard(samlProviderName);
|
|
|
|
createProviderPage.checkAddButtonDisabled();
|
2021-12-06 10:50:29 +00:00
|
|
|
createProviderPage
|
2022-12-20 11:42:59 +00:00
|
|
|
.fillDisplayName(samlDisplayName)
|
2021-12-06 10:50:29 +00:00
|
|
|
.fillDiscoveryUrl(samlDiscoveryUrl)
|
|
|
|
.shouldBeSuccessful()
|
|
|
|
.clickAdd();
|
|
|
|
masthead.checkNotificationMessage(createSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
2022-03-16 11:25:01 +00:00
|
|
|
it("should add auth constraints to existing SAML provider", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
createProviderPage
|
|
|
|
.fillAuthnContextClassRefs(classRefName)
|
|
|
|
.clickClassRefsAdd()
|
|
|
|
.fillAuthnContextDeclRefs(declRefName)
|
|
|
|
.clickDeclRefsAdd()
|
|
|
|
.clickSave();
|
|
|
|
masthead.checkNotificationMessage(saveSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
it("should add SAML mapper of type Advanced Attribute to Role", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.emptyStateAddMapper();
|
|
|
|
addMapperPage.addAdvancedAttrToRoleMapper("SAML mapper");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add SAML mapper of type Username Template Importer", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addUsernameTemplateImporterMapper(
|
2023-07-11 14:03:21 +00:00
|
|
|
"SAML Username Template Importer Mapper",
|
2021-12-06 10:50:29 +00:00
|
|
|
);
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add SAML mapper of type Hardcoded User Session Attribute", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addHardcodedUserSessionAttrMapper(
|
2023-07-11 14:03:21 +00:00
|
|
|
"Hardcoded User Session Attribute",
|
2021-12-06 10:50:29 +00:00
|
|
|
);
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add SAML mapper of type Attribute Importer", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addSAMLAttrImporterMapper("Attribute Importer");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add SAML mapper of type Hardcoded Role", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addHardcodedRoleMapper("Hardcoded Role");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add SAML mapper of type Hardcoded Attribute", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addHardcodedAttrMapper("Hardcoded Attribute");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add SAML mapper of type SAML Attribute To Role", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addSAMLAttributeToRoleMapper("SAML Attribute To Role");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
2021-12-14 22:46:19 +00:00
|
|
|
it("should edit Username Template Importer mapper", () => {
|
2021-12-06 10:50:29 +00:00
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
listingPage.goToItemDetails("SAML Username Template Importer Mapper");
|
|
|
|
addMapperPage.editUsernameTemplateImporterMapper();
|
|
|
|
masthead.checkNotificationMessage(saveMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should edit SAML mapper", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
listingPage.goToItemDetails("SAML mapper");
|
|
|
|
addMapperPage.editSAMLorOIDCMapper();
|
|
|
|
masthead.checkNotificationMessage(saveMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
2022-11-05 19:01:28 +00:00
|
|
|
it("should edit SAML settings", () => {
|
|
|
|
const providerSAMLSettings = new ProviderSAMLSettings();
|
|
|
|
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
providerSAMLSettings.disableProviderSwitch();
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
cy.findByText("Disabled");
|
|
|
|
listingPage.goToItemDetails(samlProviderName);
|
|
|
|
providerSAMLSettings.enableProviderSwitch();
|
|
|
|
|
2024-04-05 14:37:05 +00:00
|
|
|
cy.get(".pf-v5-c-jump-links__list").contains("SAML settings").click();
|
2022-11-05 19:01:28 +00:00
|
|
|
providerSAMLSettings.assertIdAndURLFields();
|
|
|
|
providerSAMLSettings.assertNameIdPolicyFormat();
|
|
|
|
providerSAMLSettings.assertPrincipalType();
|
|
|
|
providerSAMLSettings.assertSAMLSwitches();
|
|
|
|
providerSAMLSettings.assertSignatureAlgorithm();
|
|
|
|
providerSAMLSettings.assertValidateSignatures();
|
|
|
|
providerSAMLSettings.assertTextFields();
|
|
|
|
|
2024-04-05 14:37:05 +00:00
|
|
|
cy.get(".pf-v5-c-jump-links__list")
|
2022-11-05 19:01:28 +00:00
|
|
|
.contains("Requested AuthnContext Constraints")
|
|
|
|
.click();
|
|
|
|
providerSAMLSettings.assertAuthnContext();
|
|
|
|
});
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
it("clean up providers", () => {
|
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.itemExist(samlProviderName).deleteItem(samlProviderName);
|
|
|
|
modalUtils.checkModalTitle(deletePrompt).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(deleteSuccessMsg, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|