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 ProviderBaseGeneralSettingsPage from "../support/pages/admin-ui/manage/identity_providers/ProviderBaseGeneralSettingsPage";
|
2022-10-26 09:43:52 +00:00
|
|
|
import ProviderBaseAdvancedSettingsPage, {
|
2023-01-23 13:17:47 +00:00
|
|
|
ClientAssertionSigningAlg,
|
2022-10-26 09:43:52 +00:00
|
|
|
ClientAuthentication,
|
|
|
|
PromptSelect,
|
2022-12-07 15:28:28 +00:00
|
|
|
} from "../support/pages/admin-ui/manage/identity_providers/ProviderBaseAdvancedSettingsPage";
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
describe("OIDC identity provider test", () => {
|
|
|
|
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 createMapperSuccessMsg = "Mapper created 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
|
|
|
|
|
|
|
const keycloakServer = Cypress.env("KEYCLOAK_SERVER");
|
2022-03-06 15:25:37 +00:00
|
|
|
const discoveryUrl = `${keycloakServer}/realms/master/.well-known/openid-configuration`;
|
|
|
|
const authorizationUrl = `${keycloakServer}/realms/master/protocol/openid-connect/auth`;
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
describe("OIDC Identity provider creation", () => {
|
|
|
|
const oidcProviderName = "oidc";
|
|
|
|
const secret = "123";
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
});
|
|
|
|
|
2022-03-16 11:25:01 +00:00
|
|
|
it("should create an OIDC provider using discovery url", () => {
|
2021-12-06 10:50:29 +00:00
|
|
|
createProviderPage
|
2022-03-16 11:25:01 +00:00
|
|
|
.checkVisible(oidcProviderName)
|
|
|
|
.clickCard(oidcProviderName);
|
2021-12-06 10:50:29 +00:00
|
|
|
|
2022-03-16 11:25:01 +00:00
|
|
|
createProviderPage.checkAddButtonDisabled();
|
2021-12-06 10:50:29 +00:00
|
|
|
|
|
|
|
createProviderPage
|
|
|
|
.fillDiscoveryUrl(discoveryUrl)
|
|
|
|
.shouldBeSuccessful()
|
2022-12-20 11:42:59 +00:00
|
|
|
.fillDisplayName(oidcProviderName)
|
2021-12-06 10:50:29 +00:00
|
|
|
.fill(oidcProviderName, secret)
|
|
|
|
.clickAdd();
|
|
|
|
masthead.checkNotificationMessage(createSuccessMsg, true);
|
|
|
|
createProviderPage.shouldHaveAuthorizationUrl(authorizationUrl);
|
|
|
|
});
|
|
|
|
|
2022-10-26 09:43:52 +00:00
|
|
|
it("should test all settings", () => {
|
|
|
|
const providerBaseGeneralSettingsPage =
|
|
|
|
new ProviderBaseGeneralSettingsPage();
|
|
|
|
const providerBaseAdvancedSettingsPage =
|
|
|
|
new ProviderBaseAdvancedSettingsPage();
|
|
|
|
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(oidcProviderName);
|
|
|
|
//general settings
|
|
|
|
cy.findByTestId("displayName").click().type("OIDC");
|
|
|
|
cy.findByTestId("jump-link-general-settings").click();
|
|
|
|
providerBaseGeneralSettingsPage.typeDisplayOrder("1");
|
|
|
|
createProviderPage.clickSave();
|
|
|
|
masthead.checkNotificationMessage("Provider successfully updated", true);
|
|
|
|
|
|
|
|
//OIDC Settings and save/revert buttons
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCUrl("authorization");
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCUrl("token");
|
|
|
|
//OIDC Switches
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCSignatureSwitch();
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCPKCESwitch();
|
|
|
|
//Client Authentication
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCClientAuthentication(
|
|
|
|
ClientAuthentication.basicAuth
|
|
|
|
);
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCClientAuthentication(
|
|
|
|
ClientAuthentication.jwt
|
|
|
|
);
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCClientAuthentication(
|
|
|
|
ClientAuthentication.jwtPrivKey
|
|
|
|
);
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCClientAuthentication(
|
|
|
|
ClientAuthentication.post
|
|
|
|
);
|
2023-01-23 13:17:47 +00:00
|
|
|
//Client assertion signature algorithm
|
|
|
|
Object.entries(ClientAssertionSigningAlg).forEach(([, value]) => {
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCClientAuthSignAlg(value);
|
|
|
|
});
|
2022-10-26 09:43:52 +00:00
|
|
|
//OIDC Advanced Settings
|
|
|
|
providerBaseAdvancedSettingsPage.assertOIDCSettingsAdvancedSwitches();
|
|
|
|
providerBaseAdvancedSettingsPage.selectPromptOption(PromptSelect.none);
|
|
|
|
providerBaseAdvancedSettingsPage.selectPromptOption(PromptSelect.consent);
|
|
|
|
providerBaseAdvancedSettingsPage.selectPromptOption(PromptSelect.login);
|
|
|
|
providerBaseAdvancedSettingsPage.selectPromptOption(PromptSelect.select);
|
|
|
|
providerBaseAdvancedSettingsPage.selectPromptOption(
|
|
|
|
PromptSelect.unspecified
|
|
|
|
);
|
|
|
|
//Advanced Settings
|
|
|
|
providerBaseAdvancedSettingsPage.assertAdvancedSettings();
|
|
|
|
});
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
it("should add OIDC mapper of type Attribute Importer", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(oidcProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.emptyStateAddMapper();
|
|
|
|
addMapperPage.addOIDCAttrImporterMapper("OIDC Attribute Importer");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add OIDC mapper of type Claim To Role", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(oidcProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.addOIDCClaimToRoleMapper("OIDC Claim to Role");
|
|
|
|
masthead.checkNotificationMessage(createMapperSuccessMsg, true);
|
|
|
|
});
|
|
|
|
|
2022-12-15 14:57:51 +00:00
|
|
|
it("should cancel the addition of the OIDC mapper", () => {
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.goToItemDetails(oidcProviderName);
|
|
|
|
addMapperPage.goToMappersTab();
|
|
|
|
addMapperPage.addMapper();
|
|
|
|
addMapperPage.cancelNewMapper();
|
|
|
|
addMapperPage.shouldGoToMappersTab();
|
|
|
|
});
|
|
|
|
|
2021-12-06 10:50:29 +00:00
|
|
|
it("clean up providers", () => {
|
|
|
|
const modalUtils = new ModalUtils();
|
|
|
|
|
|
|
|
sidebarPage.goToIdentityProviders();
|
|
|
|
listingPage.itemExist(oidcProviderName).deleteItem(oidcProviderName);
|
|
|
|
modalUtils.checkModalTitle(deletePrompt).confirmModal();
|
|
|
|
masthead.checkNotificationMessage(deleteSuccessMsg, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|