keycloak-scim/js/apps/admin-ui/cypress/e2e/identity_providers_saml_test.spec.ts

190 lines
7.5 KiB
TypeScript
Raw Normal View History

import { SERVER_URL } from "../support/constants";
2021-12-06 10:50:29 +00:00
import LoginPage from "../support/pages/LoginPage";
import ListingPage from "../support/pages/admin-ui/ListingPage";
import Masthead from "../support/pages/admin-ui/Masthead";
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
import AddMapperPage from "../support/pages/admin-ui/manage/identity_providers/AddMapperPage";
import CreateProviderPage from "../support/pages/admin-ui/manage/identity_providers/CreateProviderPage";
import ProviderSAMLSettings from "../support/pages/admin-ui/manage/identity_providers/social/ProviderSAMLSettings";
import ModalUtils from "../support/util/ModalUtils";
import { keycloakBefore } from "../support/util/keycloak_hooks";
2021-12-06 10:50:29 +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";
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?";
const deleteSuccessMsg = "Provider successfully deleted.";
2021-12-06 10:50:29 +00:00
const classRefName = "acClassRef-1";
const declRefName = "acDeclRef-1";
const samlDiscoveryUrl = `${SERVER_URL}/realms/master/protocol/saml/descriptor`;
const samlDisplayName = "saml";
2021-12-06 10:50:29 +00:00
describe("SAML identity provider creation", () => {
const samlProviderName = "saml";
beforeEach(() => {
2023-02-10 10:10:35 +00:00
loginPage.logIn();
keycloakBefore();
2021-12-06 10:50:29 +00:00
sidebarPage.goToIdentityProviders();
});
it("should create a SAML provider using entity descriptor", () => {
2021-12-06 10:50:29 +00:00
createProviderPage
.checkVisible(samlProviderName)
.clickCard(samlProviderName);
// createProviderPage.checkAddButtonDisabled();
2021-12-06 10:50:29 +00:00
createProviderPage
.fillDisplayName(samlDisplayName)
2021-12-06 10:50:29 +00:00
.fillDiscoveryUrl(samlDiscoveryUrl)
.shouldBeSuccessful()
.clickAdd();
masthead.checkNotificationMessage(createSuccessMsg, true);
});
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(
"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(
"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);
});
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();
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();
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);
});
});
});