Create profile (#1218)
* create-client-profile: creating client profile wip * create-profile: added deleting profile * create-profile: add executors - wip * create-profile: add executors - wip * create-profile: add executors - wip * create-profile: add executors - wip * create-profile: added testId for tests * create-profile: added cypress tests for client profiles * Update cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts marking fields as private Co-authored-by: Jon Koops <jonkoops@gmail.com> * Update src/realm-settings/NewClientProfileForm.tsx removing async (not needed) Co-authored-by: Jon Koops <jonkoops@gmail.com> * feedback fixes * Update src/realm-settings/NewClientProfileForm.tsx new router link implementation Co-authored-by: Jon Koops <jonkoops@gmail.com> * simplify ClientProfile type * align form type with model * do not delete Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com> Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
b7ebd3260b
commit
bd423c4bbe
6 changed files with 595 additions and 361 deletions
|
@ -13,71 +13,72 @@ const masthead = new Masthead();
|
||||||
const modalUtils = new ModalUtils();
|
const modalUtils = new ModalUtils();
|
||||||
const realmSettingsPage = new RealmSettingsPage();
|
const realmSettingsPage = new RealmSettingsPage();
|
||||||
|
|
||||||
describe("Realm settings", () => {
|
describe("Realm settings tests", () => {
|
||||||
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
|
describe("Realm settings tabs tests", () => {
|
||||||
|
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
keycloakBefore();
|
keycloakBefore();
|
||||||
loginPage.logIn();
|
loginPage.logIn();
|
||||||
sidebarPage.goToRealm(realmName);
|
sidebarPage.goToRealm(realmName);
|
||||||
});
|
});
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await new AdminClient().createRealm(realmName);
|
await new AdminClient().createRealm(realmName);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await new AdminClient().deleteRealm(realmName);
|
await new AdminClient().deleteRealm(realmName);
|
||||||
});
|
});
|
||||||
|
|
||||||
const goToKeys = () => {
|
const goToKeys = () => {
|
||||||
const keysUrl = `/auth/admin/realms/${realmName}/keys`;
|
const keysUrl = `/auth/admin/realms/${realmName}/keys`;
|
||||||
cy.intercept(keysUrl).as("keysFetch");
|
cy.intercept(keysUrl).as("keysFetch");
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
cy.findByTestId("rs-keys-list-tab").click();
|
cy.findByTestId("rs-keys-list-tab").click();
|
||||||
cy.wait(["@keysFetch"]);
|
cy.wait(["@keysFetch"]);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
const goToDetails = () => {
|
const goToDetails = () => {
|
||||||
const keysUrl = `/auth/admin/realms/${realmName}/keys`;
|
const keysUrl = `/auth/admin/realms/${realmName}/keys`;
|
||||||
cy.intercept(keysUrl).as("keysFetch");
|
cy.intercept(keysUrl).as("keysFetch");
|
||||||
|
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
cy.findByTestId("rs-providers-tab").click();
|
cy.findByTestId("rs-providers-tab").click();
|
||||||
cy.findAllByTestId("provider-name-link")
|
cy.findAllByTestId("provider-name-link")
|
||||||
.contains("test_aes-generated")
|
.contains("test_aes-generated")
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
sidebarPage.goToRealmSettings();
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
cy.findByTestId("rs-providers-tab").click();
|
cy.findByTestId("rs-providers-tab").click();
|
||||||
cy.findAllByTestId("provider-name-link")
|
cy.findAllByTestId("provider-name-link")
|
||||||
.contains("test_hmac-generated")
|
.contains("test_hmac-generated")
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
sidebarPage.goToRealmSettings();
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
cy.findByTestId("rs-providers-tab").click();
|
cy.findByTestId("rs-providers-tab").click();
|
||||||
cy.findAllByTestId("provider-name-link").contains("test_rsa").click();
|
cy.findAllByTestId("provider-name-link").contains("test_rsa").click();
|
||||||
|
|
||||||
sidebarPage.goToRealmSettings();
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
cy.findByTestId("rs-providers-tab").click();
|
cy.findByTestId("rs-providers-tab").click();
|
||||||
cy.findAllByTestId("provider-name-link")
|
cy.findAllByTestId("provider-name-link")
|
||||||
.contains("test_rsa-generated")
|
.contains("test_rsa-generated")
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.wait(["@keysFetch"]);
|
cy.wait(["@keysFetch"]);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*const deleteProvider = (providerName: string) => {
|
/*const deleteProvider = (providerName: string) => {
|
||||||
const url = `/auth/admin/realms/${realmName}/users/*`;
|
const url = `/auth/admin/realms/${realmName}/users/*`;
|
||||||
cy.intercept(url).as("reload");
|
cy.intercept(url).as("reload");
|
||||||
cy.findByTestId("provider-name")
|
cy.findByTestId("provider-name")
|
||||||
|
@ -93,160 +94,162 @@ describe("Realm settings", () => {
|
||||||
return this;
|
return this;
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
const addBundle = () => {
|
const addBundle = () => {
|
||||||
const localizationUrl = `/auth/admin/realms/${realmName}/localization/en`;
|
const localizationUrl = `/auth/admin/realms/${realmName}/localization/en`;
|
||||||
cy.intercept(localizationUrl).as("localizationFetch");
|
cy.intercept(localizationUrl).as("localizationFetch");
|
||||||
|
|
||||||
realmSettingsPage.addKeyValuePair(
|
realmSettingsPage.addKeyValuePair(
|
||||||
"key_" + (Math.random() + 1).toString(36).substring(7),
|
"key_" + (Math.random() + 1).toString(36).substring(7),
|
||||||
"value_" + (Math.random() + 1).toString(36).substring(7)
|
"value_" + (Math.random() + 1).toString(36).substring(7)
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.wait(["@localizationFetch"]);
|
cy.wait(["@localizationFetch"]);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
it("Go to general tab", function () {
|
it("Go to general tab", function () {
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
|
||||||
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
|
||||||
masthead.checkNotificationMessage("Realm successfully updated");
|
|
||||||
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
|
||||||
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
|
||||||
masthead.checkNotificationMessage("Realm successfully updated");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Go to login tab", () => {
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
cy.findByTestId("rs-login-tab").click();
|
|
||||||
realmSettingsPage.toggleSwitch(realmSettingsPage.userRegSwitch);
|
|
||||||
realmSettingsPage.toggleSwitch(realmSettingsPage.forgotPwdSwitch);
|
|
||||||
realmSettingsPage.toggleSwitch(realmSettingsPage.rememberMeSwitch);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Go to email tab", () => {
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
cy.findByTestId("rs-email-tab").click();
|
|
||||||
|
|
||||||
realmSettingsPage.addSenderEmail("example@example.com");
|
|
||||||
|
|
||||||
realmSettingsPage.toggleCheck(realmSettingsPage.enableSslCheck);
|
|
||||||
realmSettingsPage.toggleCheck(realmSettingsPage.enableStartTlsCheck);
|
|
||||||
|
|
||||||
realmSettingsPage.save(realmSettingsPage.emailSaveBtn);
|
|
||||||
|
|
||||||
realmSettingsPage.fillHostField("localhost");
|
|
||||||
cy.findByTestId(realmSettingsPage.testConnectionButton).click();
|
|
||||||
|
|
||||||
realmSettingsPage.fillEmailField(
|
|
||||||
"example" + (Math.random() + 1).toString(36).substring(7) + "@example.com"
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.modalTestConnectionButton).click();
|
|
||||||
|
|
||||||
masthead.checkNotificationMessage("Error! Failed to send email.");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Go to themes tab", () => {
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
cy.intercept(`/auth/admin/realms/${realmName}/keys`).as("load");
|
|
||||||
|
|
||||||
cy.findByTestId("rs-themes-tab").click();
|
|
||||||
cy.wait(["@load"]);
|
|
||||||
|
|
||||||
realmSettingsPage.selectLoginThemeType("keycloak");
|
|
||||||
realmSettingsPage.selectAccountThemeType("keycloak");
|
|
||||||
realmSettingsPage.selectAdminThemeType("base");
|
|
||||||
realmSettingsPage.selectEmailThemeType("base");
|
|
||||||
|
|
||||||
realmSettingsPage.saveThemes();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Events tab", () => {
|
|
||||||
const listingPage = new ListingPage();
|
|
||||||
|
|
||||||
it("Enable user events", () => {
|
|
||||||
cy.intercept("GET", `/auth/admin/realms/${realmName}/keys`).as("load");
|
|
||||||
sidebarPage.goToRealmSettings();
|
sidebarPage.goToRealmSettings();
|
||||||
cy.findByTestId("rs-realm-events-tab").click();
|
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
||||||
|
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
||||||
|
masthead.checkNotificationMessage("Realm successfully updated");
|
||||||
|
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
||||||
|
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
||||||
|
masthead.checkNotificationMessage("Realm successfully updated");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Go to login tab", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-login-tab").click();
|
||||||
|
realmSettingsPage.toggleSwitch(realmSettingsPage.userRegSwitch);
|
||||||
|
realmSettingsPage.toggleSwitch(realmSettingsPage.forgotPwdSwitch);
|
||||||
|
realmSettingsPage.toggleSwitch(realmSettingsPage.rememberMeSwitch);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Go to email tab", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-email-tab").click();
|
||||||
|
|
||||||
|
realmSettingsPage.addSenderEmail("example@example.com");
|
||||||
|
|
||||||
|
realmSettingsPage.toggleCheck(realmSettingsPage.enableSslCheck);
|
||||||
|
realmSettingsPage.toggleCheck(realmSettingsPage.enableStartTlsCheck);
|
||||||
|
|
||||||
|
realmSettingsPage.save(realmSettingsPage.emailSaveBtn);
|
||||||
|
|
||||||
|
realmSettingsPage.fillHostField("localhost");
|
||||||
|
cy.findByTestId(realmSettingsPage.testConnectionButton).click();
|
||||||
|
|
||||||
|
realmSettingsPage.fillEmailField(
|
||||||
|
"example" +
|
||||||
|
(Math.random() + 1).toString(36).substring(7) +
|
||||||
|
"@example.com"
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.modalTestConnectionButton).click();
|
||||||
|
|
||||||
|
masthead.checkNotificationMessage("Error! Failed to send email.");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Go to themes tab", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.intercept(`/auth/admin/realms/${realmName}/keys`).as("load");
|
||||||
|
|
||||||
|
cy.findByTestId("rs-themes-tab").click();
|
||||||
cy.wait(["@load"]);
|
cy.wait(["@load"]);
|
||||||
|
|
||||||
realmSettingsPage
|
realmSettingsPage.selectLoginThemeType("keycloak");
|
||||||
.toggleSwitch(realmSettingsPage.enableEvents)
|
realmSettingsPage.selectAccountThemeType("keycloak");
|
||||||
.save(realmSettingsPage.eventsUserSave);
|
realmSettingsPage.selectAdminThemeType("base");
|
||||||
masthead.checkNotificationMessage("Successfully saved configuration");
|
realmSettingsPage.selectEmailThemeType("base");
|
||||||
|
|
||||||
realmSettingsPage.clearEvents("user");
|
realmSettingsPage.saveThemes();
|
||||||
|
|
||||||
modalUtils
|
|
||||||
.checkModalMessage(
|
|
||||||
"If you clear all events of this realm, all records will be permanently cleared in the database"
|
|
||||||
)
|
|
||||||
.confirmModal();
|
|
||||||
|
|
||||||
masthead.checkNotificationMessage("The user events have been cleared");
|
|
||||||
|
|
||||||
const events = ["Client info", "Client info error"];
|
|
||||||
|
|
||||||
cy.intercept("GET", `/auth/admin/realms/${realmName}/events/config`).as(
|
|
||||||
"fetchConfig"
|
|
||||||
);
|
|
||||||
realmSettingsPage.addUserEvents(events).clickAdd();
|
|
||||||
masthead.checkNotificationMessage("Successfully saved configuration");
|
|
||||||
cy.wait(["@fetchConfig"]);
|
|
||||||
sidebarPage.waitForPageLoad();
|
|
||||||
|
|
||||||
for (const event of events) {
|
|
||||||
listingPage.searchItem(event, false).itemExist(event);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it("Go to keys tab", () => {
|
describe("Events tab", () => {
|
||||||
sidebarPage.goToRealmSettings();
|
const listingPage = new ListingPage();
|
||||||
|
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
it("Enable user events", () => {
|
||||||
});
|
cy.intercept("GET", `/auth/admin/realms/${realmName}/keys`).as("load");
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-realm-events-tab").click();
|
||||||
|
cy.wait(["@load"]);
|
||||||
|
|
||||||
it("add Providers", () => {
|
realmSettingsPage
|
||||||
sidebarPage.goToRealmSettings();
|
.toggleSwitch(realmSettingsPage.enableEvents)
|
||||||
|
.save(realmSettingsPage.eventsUserSave);
|
||||||
|
masthead.checkNotificationMessage("Successfully saved configuration");
|
||||||
|
|
||||||
cy.findByTestId("rs-keys-tab").click();
|
realmSettingsPage.clearEvents("user");
|
||||||
|
|
||||||
cy.findByTestId("rs-providers-tab").click();
|
modalUtils
|
||||||
|
.checkModalMessage(
|
||||||
|
"If you clear all events of this realm, all records will be permanently cleared in the database"
|
||||||
|
)
|
||||||
|
.confirmModal();
|
||||||
|
|
||||||
realmSettingsPage.toggleAddProviderDropdown();
|
masthead.checkNotificationMessage("The user events have been cleared");
|
||||||
|
|
||||||
cy.findByTestId("option-aes-generated").click();
|
const events = ["Client info", "Client info error"];
|
||||||
realmSettingsPage.enterConsoleDisplayName("test_aes-generated");
|
|
||||||
realmSettingsPage.addProvider();
|
|
||||||
|
|
||||||
realmSettingsPage.toggleAddProviderDropdown();
|
cy.intercept("GET", `/auth/admin/realms/${realmName}/events/config`).as(
|
||||||
|
"fetchConfig"
|
||||||
|
);
|
||||||
|
realmSettingsPage.addUserEvents(events).clickAdd();
|
||||||
|
masthead.checkNotificationMessage("Successfully saved configuration");
|
||||||
|
cy.wait(["@fetchConfig"]);
|
||||||
|
sidebarPage.waitForPageLoad();
|
||||||
|
|
||||||
cy.findByTestId("option-ecdsa-generated").click();
|
for (const event of events) {
|
||||||
realmSettingsPage.enterConsoleDisplayName("test_ecdsa-generated");
|
listingPage.searchItem(event, false).itemExist(event);
|
||||||
realmSettingsPage.addProvider();
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
realmSettingsPage.toggleAddProviderDropdown();
|
it("Go to keys tab", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
cy.findByTestId("option-hmac-generated").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
realmSettingsPage.enterConsoleDisplayName("test_hmac-generated");
|
});
|
||||||
realmSettingsPage.addProvider();
|
|
||||||
|
|
||||||
realmSettingsPage.toggleAddProviderDropdown();
|
it("add Providers", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
cy.findByTestId("option-rsa-generated").click();
|
cy.findByTestId("rs-keys-tab").click();
|
||||||
realmSettingsPage.enterConsoleDisplayName("test_rsa-generated");
|
|
||||||
realmSettingsPage.addProvider();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("go to details", () => {
|
cy.findByTestId("rs-providers-tab").click();
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
goToDetails();
|
|
||||||
});
|
|
||||||
|
|
||||||
/*it("delete providers", () => {
|
realmSettingsPage.toggleAddProviderDropdown();
|
||||||
|
|
||||||
|
cy.findByTestId("option-aes-generated").click();
|
||||||
|
realmSettingsPage.enterConsoleDisplayName("test_aes-generated");
|
||||||
|
realmSettingsPage.addProvider();
|
||||||
|
|
||||||
|
realmSettingsPage.toggleAddProviderDropdown();
|
||||||
|
|
||||||
|
cy.findByTestId("option-ecdsa-generated").click();
|
||||||
|
realmSettingsPage.enterConsoleDisplayName("test_ecdsa-generated");
|
||||||
|
realmSettingsPage.addProvider();
|
||||||
|
|
||||||
|
realmSettingsPage.toggleAddProviderDropdown();
|
||||||
|
|
||||||
|
cy.findByTestId("option-hmac-generated").click();
|
||||||
|
realmSettingsPage.enterConsoleDisplayName("test_hmac-generated");
|
||||||
|
realmSettingsPage.addProvider();
|
||||||
|
|
||||||
|
realmSettingsPage.toggleAddProviderDropdown();
|
||||||
|
|
||||||
|
cy.findByTestId("option-rsa-generated").click();
|
||||||
|
realmSettingsPage.enterConsoleDisplayName("test_rsa-generated");
|
||||||
|
realmSettingsPage.addProvider();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("go to details", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
goToDetails();
|
||||||
|
});
|
||||||
|
|
||||||
|
/*it("delete providers", () => {
|
||||||
sidebarPage.goToRealmSettings();
|
sidebarPage.goToRealmSettings();
|
||||||
const url = `/auth/admin/realms/${realmName}/keys`;
|
const url = `/auth/admin/realms/${realmName}/keys`;
|
||||||
cy.intercept(url).as("load");
|
cy.intercept(url).as("load");
|
||||||
|
@ -261,168 +264,201 @@ describe("Realm settings", () => {
|
||||||
deleteProvider("test_hmac-generated");
|
deleteProvider("test_hmac-generated");
|
||||||
deleteProvider("test_rsa-generated");
|
deleteProvider("test_rsa-generated");
|
||||||
});*/
|
});*/
|
||||||
it("Test keys", () => {
|
it("Test keys", () => {
|
||||||
sidebarPage.goToRealmSettings();
|
sidebarPage.goToRealmSettings();
|
||||||
goToKeys();
|
goToKeys();
|
||||||
|
|
||||||
realmSettingsPage.testSelectFilter();
|
realmSettingsPage.testSelectFilter();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("add locale", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
|
cy.findByTestId("rs-localization-tab").click();
|
||||||
|
|
||||||
|
addBundle();
|
||||||
|
|
||||||
|
masthead.checkNotificationMessage(
|
||||||
|
"Success! The localization text has been created."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Realm header settings", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.get("#pf-tab-securityDefences-securityDefences").click();
|
||||||
|
cy.findByTestId("headers-form-tab-save").should("be.disabled");
|
||||||
|
cy.get("#xFrameOptions").clear().type("DENY");
|
||||||
|
cy.findByTestId("headers-form-tab-save").should("be.enabled").click();
|
||||||
|
|
||||||
|
masthead.checkNotificationMessage("Realm successfully updated");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Brute force detection", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.get("#pf-tab-securityDefences-securityDefences").click();
|
||||||
|
cy.get("#pf-tab-20-bruteForce").click();
|
||||||
|
|
||||||
|
cy.findByTestId("brute-force-tab-save").should("be.disabled");
|
||||||
|
|
||||||
|
cy.get("#bruteForceProtected").click({ force: true });
|
||||||
|
cy.findByTestId("waitIncrementSeconds").type("1");
|
||||||
|
cy.findByTestId("maxFailureWaitSeconds").type("1");
|
||||||
|
cy.findByTestId("maxDeltaTimeSeconds").type("1");
|
||||||
|
cy.findByTestId("minimumQuickLoginWaitSeconds").type("1");
|
||||||
|
|
||||||
|
cy.findByTestId("brute-force-tab-save").should("be.enabled").click();
|
||||||
|
masthead.checkNotificationMessage("Realm successfully updated");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("add session data", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
|
cy.findByTestId("rs-sessions-tab").click();
|
||||||
|
|
||||||
|
realmSettingsPage.populateSessionsPage();
|
||||||
|
realmSettingsPage.save("sessions-tab-save");
|
||||||
|
|
||||||
|
masthead.checkNotificationMessage("Realm successfully updated");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("check that sessions data was saved", () => {
|
||||||
|
sidebarPage.goToAuthentication();
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
|
cy.findByTestId("rs-sessions-tab").click();
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.ssoSessionIdleInput).should(
|
||||||
|
"have.value",
|
||||||
|
1
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.ssoSessionMaxInput).should(
|
||||||
|
"have.value",
|
||||||
|
2
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.ssoSessionIdleRememberMeInput).should(
|
||||||
|
"have.value",
|
||||||
|
3
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.ssoSessionMaxRememberMeInput).should(
|
||||||
|
"have.value",
|
||||||
|
4
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.clientSessionIdleInput).should(
|
||||||
|
"have.value",
|
||||||
|
5
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.clientSessionMaxInput).should(
|
||||||
|
"have.value",
|
||||||
|
6
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.offlineSessionIdleInput).should(
|
||||||
|
"have.value",
|
||||||
|
7
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.offlineSessionMaxSwitch).should(
|
||||||
|
"have.value",
|
||||||
|
"on"
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.loginTimeoutInput).should(
|
||||||
|
"have.value",
|
||||||
|
9
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.loginActionTimeoutInput).should(
|
||||||
|
"have.value",
|
||||||
|
10
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("add token data", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
|
cy.findByTestId("rs-tokens-tab").click();
|
||||||
|
|
||||||
|
realmSettingsPage.populateTokensPage();
|
||||||
|
realmSettingsPage.save("tokens-tab-save");
|
||||||
|
|
||||||
|
masthead.checkNotificationMessage("Realm successfully updated");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("check that token data was saved", () => {
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
|
||||||
|
cy.findByTestId("rs-tokens-tab").click();
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.accessTokenLifespanInput).should(
|
||||||
|
"have.value",
|
||||||
|
1
|
||||||
|
);
|
||||||
|
cy.findByTestId(
|
||||||
|
realmSettingsPage.accessTokenLifespanImplicitInput
|
||||||
|
).should("have.value", 2);
|
||||||
|
cy.findByTestId(realmSettingsPage.clientLoginTimeoutInput).should(
|
||||||
|
"have.value",
|
||||||
|
3
|
||||||
|
);
|
||||||
|
cy.findByTestId(
|
||||||
|
realmSettingsPage.userInitiatedActionLifespanInput
|
||||||
|
).should("have.value", 4);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.defaultAdminInitatedInput).should(
|
||||||
|
"have.value",
|
||||||
|
5
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.emailVerificationInput).should(
|
||||||
|
"have.value",
|
||||||
|
6
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.idpEmailVerificationInput).should(
|
||||||
|
"have.value",
|
||||||
|
7
|
||||||
|
);
|
||||||
|
cy.findByTestId(realmSettingsPage.forgotPasswordInput).should(
|
||||||
|
"have.value",
|
||||||
|
8
|
||||||
|
);
|
||||||
|
|
||||||
|
cy.findByTestId(realmSettingsPage.executeActionsInput).should(
|
||||||
|
"have.value",
|
||||||
|
9
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("add locale", () => {
|
describe("Realm settings client profiles tab tests", () => {
|
||||||
sidebarPage.goToRealmSettings();
|
beforeEach(() => {
|
||||||
|
keycloakBefore();
|
||||||
|
loginPage.logIn();
|
||||||
|
sidebarPage.goToRealmSettings();
|
||||||
|
cy.findByTestId("rs-clientPolicies-tab").click();
|
||||||
|
cy.findByTestId("rs-profiles-clientPolicies-tab").click();
|
||||||
|
});
|
||||||
|
|
||||||
cy.findByTestId("rs-localization-tab").click();
|
it("Go to client policies profiles tab", function () {
|
||||||
|
realmSettingsPage.shouldDisplayProfilesTab();
|
||||||
|
});
|
||||||
|
|
||||||
addBundle();
|
it("Check new client form is displaying", function () {
|
||||||
|
realmSettingsPage.shouldDisplayNewClientProfileForm();
|
||||||
|
});
|
||||||
|
|
||||||
masthead.checkNotificationMessage(
|
it("Complete new client form and cancel", function () {
|
||||||
"Success! The localization text has been created."
|
realmSettingsPage.shouldCompleteAndCancelCreateNewClientProfile();
|
||||||
);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it("Realm header settings", () => {
|
it("Complete new client form and submit", function () {
|
||||||
sidebarPage.goToRealmSettings();
|
realmSettingsPage.shouldCompleteAndCreateNewClientProfile();
|
||||||
cy.get("#pf-tab-securityDefences-securityDefences").click();
|
});
|
||||||
cy.findByTestId("headers-form-tab-save").should("be.disabled");
|
|
||||||
cy.get("#xFrameOptions").clear().type("DENY");
|
|
||||||
cy.findByTestId("headers-form-tab-save").should("be.enabled").click();
|
|
||||||
|
|
||||||
masthead.checkNotificationMessage("Realm successfully updated");
|
it("Check cancelling the client profile deletion", function () {
|
||||||
});
|
realmSettingsPage.shouldDisplayDeleteClientProfileDialog();
|
||||||
|
});
|
||||||
|
|
||||||
it("Brute force detection", () => {
|
it("Check deleting the client profile", function () {
|
||||||
sidebarPage.goToRealmSettings();
|
realmSettingsPage.shouldDeleteClientProfileDialog();
|
||||||
cy.get("#pf-tab-securityDefences-securityDefences").click();
|
});
|
||||||
cy.get("#pf-tab-20-bruteForce").click();
|
|
||||||
|
|
||||||
cy.findByTestId("brute-force-tab-save").should("be.disabled");
|
|
||||||
|
|
||||||
cy.get("#bruteForceProtected").click({ force: true });
|
|
||||||
cy.findByTestId("waitIncrementSeconds").type("1");
|
|
||||||
cy.findByTestId("maxFailureWaitSeconds").type("1");
|
|
||||||
cy.findByTestId("maxDeltaTimeSeconds").type("1");
|
|
||||||
cy.findByTestId("minimumQuickLoginWaitSeconds").type("1");
|
|
||||||
|
|
||||||
cy.findByTestId("brute-force-tab-save").should("be.enabled").click();
|
|
||||||
masthead.checkNotificationMessage("Realm successfully updated");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("add session data", () => {
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
|
|
||||||
cy.findByTestId("rs-sessions-tab").click();
|
|
||||||
|
|
||||||
realmSettingsPage.populateSessionsPage();
|
|
||||||
realmSettingsPage.save("sessions-tab-save");
|
|
||||||
|
|
||||||
masthead.checkNotificationMessage("Realm successfully updated");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("check that sessions data was saved", () => {
|
|
||||||
sidebarPage.goToAuthentication();
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
|
|
||||||
cy.findByTestId("rs-sessions-tab").click();
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.ssoSessionIdleInput).should(
|
|
||||||
"have.value",
|
|
||||||
1
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.ssoSessionMaxInput).should(
|
|
||||||
"have.value",
|
|
||||||
2
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.ssoSessionIdleRememberMeInput).should(
|
|
||||||
"have.value",
|
|
||||||
3
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.ssoSessionMaxRememberMeInput).should(
|
|
||||||
"have.value",
|
|
||||||
4
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.clientSessionIdleInput).should(
|
|
||||||
"have.value",
|
|
||||||
5
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.clientSessionMaxInput).should(
|
|
||||||
"have.value",
|
|
||||||
6
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.offlineSessionIdleInput).should(
|
|
||||||
"have.value",
|
|
||||||
7
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.offlineSessionMaxSwitch).should(
|
|
||||||
"have.value",
|
|
||||||
"on"
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.loginTimeoutInput).should(
|
|
||||||
"have.value",
|
|
||||||
9
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.loginActionTimeoutInput).should(
|
|
||||||
"have.value",
|
|
||||||
10
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("add token data", () => {
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
|
|
||||||
cy.findByTestId("rs-tokens-tab").click();
|
|
||||||
|
|
||||||
realmSettingsPage.populateTokensPage();
|
|
||||||
realmSettingsPage.save("tokens-tab-save");
|
|
||||||
|
|
||||||
masthead.checkNotificationMessage("Realm successfully updated");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("check that token data was saved", () => {
|
|
||||||
sidebarPage.goToRealmSettings();
|
|
||||||
|
|
||||||
cy.findByTestId("rs-tokens-tab").click();
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.accessTokenLifespanInput).should(
|
|
||||||
"have.value",
|
|
||||||
1
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.accessTokenLifespanImplicitInput).should(
|
|
||||||
"have.value",
|
|
||||||
2
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.clientLoginTimeoutInput).should(
|
|
||||||
"have.value",
|
|
||||||
3
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.userInitiatedActionLifespanInput).should(
|
|
||||||
"have.value",
|
|
||||||
4
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.defaultAdminInitatedInput).should(
|
|
||||||
"have.value",
|
|
||||||
5
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.emailVerificationInput).should(
|
|
||||||
"have.value",
|
|
||||||
6
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.idpEmailVerificationInput).should(
|
|
||||||
"have.value",
|
|
||||||
7
|
|
||||||
);
|
|
||||||
cy.findByTestId(realmSettingsPage.forgotPasswordInput).should(
|
|
||||||
"have.value",
|
|
||||||
8
|
|
||||||
);
|
|
||||||
|
|
||||||
cy.findByTestId(realmSettingsPage.executeActionsInput).should(
|
|
||||||
"have.value",
|
|
||||||
9
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -143,6 +143,20 @@ export default class RealmSettingsPage {
|
||||||
executeActionsSelectMenu = "#kc-execute-actions-select-menu";
|
executeActionsSelectMenu = "#kc-execute-actions-select-menu";
|
||||||
executeActionsSelectMenuList = "#kc-execute-actions-select-menu > div > ul";
|
executeActionsSelectMenuList = "#kc-execute-actions-select-menu > div > ul";
|
||||||
|
|
||||||
|
private createProfileBtn = "createProfile";
|
||||||
|
private formViewSelect = "formView-radioBtn";
|
||||||
|
private jsonEditorSelect = "formView-radioBtn";
|
||||||
|
private newClientProfileNameInput = "client-profile-name";
|
||||||
|
private newClientProfileDescriptionInput = "client-profile-description";
|
||||||
|
private saveNewClientProfileBtn = "saveCreateProfile";
|
||||||
|
private cancelNewClientProfile = "cancelCreateProfile";
|
||||||
|
private alertMessage = ".pf-c-alert__title";
|
||||||
|
private moreDrpDwn = ".pf-c-dropdown__toggle.pf-m-plain";
|
||||||
|
private moreDrpDwnItems = ".pf-c-dropdown__menu-item";
|
||||||
|
private deleteDialogTitle = ".pf-c-modal-box__title-text";
|
||||||
|
private deleteDialogBodyText = ".pf-c-modal-box__body";
|
||||||
|
private deleteDialogCancelBtn = ".pf-c-button.pf-m-link";
|
||||||
|
|
||||||
selectLoginThemeType(themeType: string) {
|
selectLoginThemeType(themeType: string) {
|
||||||
cy.get(this.selectLoginTheme).click();
|
cy.get(this.selectLoginTheme).click();
|
||||||
cy.get(this.loginThemeList).contains(themeType).click();
|
cy.get(this.loginThemeList).contains(themeType).click();
|
||||||
|
@ -450,4 +464,62 @@ export default class RealmSettingsPage {
|
||||||
cy.findByTestId("addEventTypeConfirm").click();
|
cy.findByTestId("addEventTypeConfirm").click();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldDisplayProfilesTab() {
|
||||||
|
cy.findByTestId(this.createProfileBtn).should("exist");
|
||||||
|
cy.findByTestId(this.formViewSelect).should("exist");
|
||||||
|
cy.findByTestId(this.jsonEditorSelect).should("exist");
|
||||||
|
cy.get("table").should("be.visible").contains("td", "Global");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDisplayNewClientProfileForm() {
|
||||||
|
cy.findByTestId(this.createProfileBtn).click();
|
||||||
|
cy.findByTestId(this.newClientProfileNameInput).should("exist");
|
||||||
|
cy.findByTestId(this.newClientProfileDescriptionInput).should("exist");
|
||||||
|
cy.findByTestId(this.saveNewClientProfileBtn).should("exist");
|
||||||
|
cy.findByTestId(this.cancelNewClientProfile).should("exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldCompleteAndCancelCreateNewClientProfile() {
|
||||||
|
cy.findByTestId(this.createProfileBtn).click();
|
||||||
|
cy.findByTestId(this.newClientProfileNameInput).type("Test");
|
||||||
|
cy.findByTestId(this.newClientProfileDescriptionInput).type(
|
||||||
|
"Test Description"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.cancelNewClientProfile).click();
|
||||||
|
cy.get("table").should("not.have.text", "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldCompleteAndCreateNewClientProfile() {
|
||||||
|
cy.findByTestId(this.createProfileBtn).click();
|
||||||
|
cy.findByTestId(this.newClientProfileNameInput).type("Test");
|
||||||
|
cy.findByTestId(this.newClientProfileDescriptionInput).type(
|
||||||
|
"Test Description"
|
||||||
|
);
|
||||||
|
cy.findByTestId(this.saveNewClientProfileBtn).click();
|
||||||
|
cy.get(this.alertMessage).should(
|
||||||
|
"be.visible",
|
||||||
|
"New client profile created"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDisplayDeleteClientProfileDialog() {
|
||||||
|
cy.get(this.moreDrpDwn).last().click();
|
||||||
|
cy.get(this.moreDrpDwnItems).click();
|
||||||
|
cy.get(this.deleteDialogTitle).contains("Delete profile?");
|
||||||
|
cy.get(this.deleteDialogBodyText).contains(
|
||||||
|
"This action will permanently delete the profile custom-profile. This cannot be undone."
|
||||||
|
);
|
||||||
|
cy.findByTestId("modalConfirm").contains("Delete");
|
||||||
|
cy.get(this.deleteDialogCancelBtn).contains("Cancel").click();
|
||||||
|
cy.get("table").should("not.have.text", "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldDeleteClientProfileDialog() {
|
||||||
|
cy.get(this.moreDrpDwn).last().click();
|
||||||
|
cy.get(this.moreDrpDwnItems).click();
|
||||||
|
cy.findByTestId("modalConfirm").contains("Delete").click();
|
||||||
|
cy.get("table").should("not.have.text", "Test");
|
||||||
|
cy.get(this.alertMessage).should("be.visible", "Client profile deleted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
ActionGroup,
|
ActionGroup,
|
||||||
|
AlertVariant,
|
||||||
Button,
|
Button,
|
||||||
|
Divider,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
PageSection,
|
PageSection,
|
||||||
|
Text,
|
||||||
TextArea,
|
TextArea,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
TextVariants,
|
||||||
ValidatedOptions,
|
ValidatedOptions,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -14,15 +18,69 @@ import { FormAccess } from "../components/form-access/FormAccess";
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
|
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
||||||
|
import type ClientProfileRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientProfileRepresentation";
|
||||||
|
import { HelpItem } from "../components/help-enabler/HelpItem";
|
||||||
|
import { PlusCircleIcon } from "@patternfly/react-icons";
|
||||||
|
import "./RealmSettingsSection.css";
|
||||||
|
|
||||||
|
type NewClientProfileForm = Required<ClientProfileRepresentation>;
|
||||||
|
|
||||||
|
const defaultValues: NewClientProfileForm = {
|
||||||
|
name: "",
|
||||||
|
executors: [],
|
||||||
|
description: "",
|
||||||
|
};
|
||||||
|
|
||||||
export const NewClientProfileForm = () => {
|
export const NewClientProfileForm = () => {
|
||||||
const { t } = useTranslation("realm-settings");
|
const { t } = useTranslation("realm-settings");
|
||||||
const { register, errors } = useForm();
|
const { getValues, register, errors } = useForm<NewClientProfileForm>({
|
||||||
|
defaultValues,
|
||||||
|
});
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
const { addAlert, addError } = useAlerts();
|
||||||
|
const adminClient = useAdminClient();
|
||||||
|
const [globalProfiles, setGlobalProfiles] = useState<
|
||||||
|
ClientProfileRepresentation[]
|
||||||
|
>([]);
|
||||||
|
const [profiles, setProfiles] = useState<ClientProfileRepresentation[]>([]);
|
||||||
|
const [showAddExecutorsForm, setShowAddExecutorsForm] = useState(false);
|
||||||
|
|
||||||
function save() {
|
useFetch(
|
||||||
//TODO
|
() =>
|
||||||
}
|
adminClient.clientPolicies.listProfiles({ includeGlobalProfiles: true }),
|
||||||
|
(profiles) => {
|
||||||
|
setGlobalProfiles(profiles.globalProfiles ?? []);
|
||||||
|
setProfiles(profiles.profiles ?? []);
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
const form = getValues();
|
||||||
|
|
||||||
|
const createdProfile = {
|
||||||
|
...form,
|
||||||
|
executors: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const allProfiles = profiles.concat(createdProfile);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await adminClient.clientPolicies.createProfiles({
|
||||||
|
profiles: allProfiles,
|
||||||
|
globalProfiles: globalProfiles,
|
||||||
|
});
|
||||||
|
addAlert(
|
||||||
|
t("realm-settings:createClientProfileSuccess"),
|
||||||
|
AlertVariant.success
|
||||||
|
);
|
||||||
|
setShowAddExecutorsForm(true);
|
||||||
|
} catch (error) {
|
||||||
|
addError("realm-settings:createClientProfileError", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -32,39 +90,36 @@ export const NewClientProfileForm = () => {
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={t("newClientProfileName")}
|
label={t("newClientProfileName")}
|
||||||
fieldId="kc-name"
|
fieldId="kc-name"
|
||||||
|
helperText={t("createClientProfileNameHelperText")}
|
||||||
isRequired
|
isRequired
|
||||||
helperTextInvalid={t("common:required")}
|
helperTextInvalid={t("common:required")}
|
||||||
|
validated={
|
||||||
|
errors.name ? ValidatedOptions.error : ValidatedOptions.default
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
ref={register({ required: true })}
|
ref={register({ required: true })}
|
||||||
type="text"
|
type="text"
|
||||||
id="kc-client-profile-name"
|
id="kc-client-profile-name"
|
||||||
name="name"
|
name="name"
|
||||||
|
data-testid="client-profile-name"
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormGroup
|
<FormGroup label={t("common:description")} fieldId="kc-description">
|
||||||
label={t("common:description")}
|
|
||||||
fieldId="kc-description"
|
|
||||||
validated={
|
|
||||||
errors.description
|
|
||||||
? ValidatedOptions.error
|
|
||||||
: ValidatedOptions.default
|
|
||||||
}
|
|
||||||
helperTextInvalid={errors.description?.message}
|
|
||||||
>
|
|
||||||
<TextArea
|
<TextArea
|
||||||
name="description"
|
name="description"
|
||||||
aria-label={t("description")}
|
aria-label={t("description")}
|
||||||
ref={register()}
|
ref={register()}
|
||||||
type="text"
|
type="text"
|
||||||
id="kc-client-profile-description"
|
id="kc-client-profile-description"
|
||||||
|
data-testid="client-profile-description"
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<ActionGroup>
|
<ActionGroup>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
onClick={save}
|
onClick={save}
|
||||||
data-testid="realm-settings-client-profile-save-button"
|
data-testid="saveCreateProfile"
|
||||||
>
|
>
|
||||||
{t("common:save")}
|
{t("common:save")}
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -78,6 +133,42 @@ export const NewClientProfileForm = () => {
|
||||||
{t("common:cancel")}
|
{t("common:cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
</ActionGroup>
|
</ActionGroup>
|
||||||
|
{showAddExecutorsForm && (
|
||||||
|
<>
|
||||||
|
<FormGroup
|
||||||
|
label={t("executors")}
|
||||||
|
fieldId="kc-executors"
|
||||||
|
labelIcon={
|
||||||
|
<HelpItem
|
||||||
|
helpText={t("realm-settings:executorsHelpText")}
|
||||||
|
forLabel={t("executorsHelpItem")}
|
||||||
|
forID={t("executors")}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
id="addExecutor"
|
||||||
|
component={(props) => (
|
||||||
|
<Link
|
||||||
|
{...props}
|
||||||
|
to={`/${realm}/realm-settings/clientPolicies`}
|
||||||
|
></Link>
|
||||||
|
)}
|
||||||
|
variant="link"
|
||||||
|
className="kc-addExecutor"
|
||||||
|
data-testid="cancelCreateProfile"
|
||||||
|
icon={<PlusCircleIcon />}
|
||||||
|
isDisabled
|
||||||
|
>
|
||||||
|
{t("realm-settings:addExecutor")}
|
||||||
|
</Button>
|
||||||
|
</FormGroup>
|
||||||
|
<Divider />
|
||||||
|
<Text component={TextVariants.h6}>
|
||||||
|
{t("realm-settings:emptyExecutors")}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</FormAccess>
|
</FormAccess>
|
||||||
</PageSection>
|
</PageSection>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { useMemo, useState } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
|
import { omit } from "lodash";
|
||||||
import {
|
import {
|
||||||
AlertVariant,
|
AlertVariant,
|
||||||
Button,
|
Button,
|
||||||
|
@ -18,13 +19,10 @@ import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
import { useAlerts } from "../components/alert/Alerts";
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import "./RealmSettingsSection.css";
|
import "./RealmSettingsSection.css";
|
||||||
import type ClientPolicyExecutorRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientPolicyExecutorRepresentation";
|
|
||||||
import { toNewClientProfile } from "./routes/NewClientProfile";
|
import { toNewClientProfile } from "./routes/NewClientProfile";
|
||||||
|
import type ClientProfileRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientProfileRepresentation";
|
||||||
|
|
||||||
type ClientProfile = {
|
type ClientProfile = ClientProfileRepresentation & {
|
||||||
description?: string;
|
|
||||||
executors?: ClientPolicyExecutorRepresentation[];
|
|
||||||
name?: string;
|
|
||||||
global: boolean;
|
global: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,8 +31,12 @@ export const ProfilesTab = () => {
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
const [profiles, setProfiles] = useState<ClientProfile[]>();
|
const [tableProfiles, setTableProfiles] = useState<ClientProfile[]>();
|
||||||
|
const [globalProfiles, setGlobalProfiles] =
|
||||||
|
useState<ClientProfileRepresentation[]>();
|
||||||
|
const [selectedProfile, setSelectedProfile] = useState<ClientProfile>();
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
|
const [key, setKey] = useState(0);
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
const allProfiles = await adminClient.clientPolicies.listProfiles({
|
const allProfiles = await adminClient.clientPolicies.listProfiles({
|
||||||
|
@ -42,6 +44,8 @@ export const ProfilesTab = () => {
|
||||||
includeGlobalProfiles: true,
|
includeGlobalProfiles: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setGlobalProfiles(allProfiles.globalProfiles);
|
||||||
|
|
||||||
const globalProfiles = allProfiles.globalProfiles?.map(
|
const globalProfiles = allProfiles.globalProfiles?.map(
|
||||||
(globalProfiles) => ({
|
(globalProfiles) => ({
|
||||||
...globalProfiles,
|
...globalProfiles,
|
||||||
|
@ -55,12 +59,15 @@ export const ProfilesTab = () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const allClientProfiles = globalProfiles?.concat(profiles ?? []);
|
const allClientProfiles = globalProfiles?.concat(profiles ?? []);
|
||||||
setProfiles(allClientProfiles);
|
setTableProfiles(allClientProfiles);
|
||||||
|
|
||||||
return allClientProfiles ?? [];
|
return allClientProfiles ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const code = useMemo(() => JSON.stringify(profiles, null, 2), [profiles]);
|
const code = useMemo(
|
||||||
|
() => JSON.stringify(tableProfiles, null, 2),
|
||||||
|
[tableProfiles]
|
||||||
|
);
|
||||||
|
|
||||||
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
||||||
titleKey: t("deleteClientProfileConfirmTitle"),
|
titleKey: t("deleteClientProfileConfirmTitle"),
|
||||||
|
@ -68,9 +75,19 @@ export const ProfilesTab = () => {
|
||||||
continueButtonLabel: t("delete"),
|
continueButtonLabel: t("delete"),
|
||||||
continueButtonVariant: ButtonVariant.danger,
|
continueButtonVariant: ButtonVariant.danger,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
|
const updatedProfiles = tableProfiles
|
||||||
|
?.filter(
|
||||||
|
(profile) => profile.name !== selectedProfile?.name && !profile.global
|
||||||
|
)
|
||||||
|
.map<ClientProfileRepresentation>((profile) => omit(profile, "global"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// delete client profile here
|
await adminClient.clientPolicies.createProfiles({
|
||||||
|
profiles: updatedProfiles,
|
||||||
|
globalProfiles,
|
||||||
|
});
|
||||||
addAlert(t("deleteClientSuccess"), AlertVariant.success);
|
addAlert(t("deleteClientSuccess"), AlertVariant.success);
|
||||||
|
setKey(key + 1);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addError(t("deleteClientError"), error);
|
addError(t("deleteClientError"), error);
|
||||||
}
|
}
|
||||||
|
@ -102,6 +119,7 @@ export const ProfilesTab = () => {
|
||||||
label={t("profilesConfigTypes.formView")}
|
label={t("profilesConfigTypes.formView")}
|
||||||
id="formView-radioBtn"
|
id="formView-radioBtn"
|
||||||
className="kc-form-radio-btn pf-u-mr-sm pf-u-ml-sm"
|
className="kc-form-radio-btn pf-u-mr-sm pf-u-ml-sm"
|
||||||
|
data-testid="formView-radioBtn"
|
||||||
/>
|
/>
|
||||||
</FlexItem>
|
</FlexItem>
|
||||||
<FlexItem>
|
<FlexItem>
|
||||||
|
@ -112,6 +130,7 @@ export const ProfilesTab = () => {
|
||||||
label={t("profilesConfigTypes.jsonEditor")}
|
label={t("profilesConfigTypes.jsonEditor")}
|
||||||
id="jsonEditor-radioBtn"
|
id="jsonEditor-radioBtn"
|
||||||
className="kc-editor-radio-btn"
|
className="kc-editor-radio-btn"
|
||||||
|
data-testid="jsonEditor-radioBtn"
|
||||||
/>
|
/>
|
||||||
</FlexItem>
|
</FlexItem>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -119,6 +138,7 @@ export const ProfilesTab = () => {
|
||||||
<Divider />
|
<Divider />
|
||||||
{!show ? (
|
{!show ? (
|
||||||
<KeycloakDataTable
|
<KeycloakDataTable
|
||||||
|
key={key}
|
||||||
ariaLabelKey="userEventsRegistered"
|
ariaLabelKey="userEventsRegistered"
|
||||||
searchPlaceholderKey="realm-settings:clientProfileSearch"
|
searchPlaceholderKey="realm-settings:clientProfileSearch"
|
||||||
isPaginated
|
isPaginated
|
||||||
|
@ -136,11 +156,12 @@ export const ProfilesTab = () => {
|
||||||
</Button>
|
</Button>
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
}
|
}
|
||||||
isRowDisabled={(value) => value.global === true}
|
isRowDisabled={(value) => value.global}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
title: t("common:delete"),
|
title: t("common:delete"),
|
||||||
onRowClick: () => {
|
onRowClick: (profile) => {
|
||||||
|
setSelectedProfile(profile);
|
||||||
toggleDeleteDialog();
|
toggleDeleteDialog();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -181,7 +202,7 @@ export const ProfilesTab = () => {
|
||||||
>
|
>
|
||||||
{t("save")}
|
{t("save")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={ButtonVariant.secondary}> {t("reload")}</Button>
|
<Button variant={ButtonVariant.link}> {t("reload")}</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -192,4 +192,8 @@ article.pf-c-card.pf-m-flat.kc-login-settings-template
|
||||||
|
|
||||||
.kc-editor-radio-btn > input {
|
.kc-editor-radio-btn > input {
|
||||||
transform: scale(1.6);
|
transform: scale(1.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.kc-addExecutor {
|
||||||
|
float: right;
|
||||||
}
|
}
|
|
@ -234,6 +234,10 @@ export default {
|
||||||
deleteClientSuccess: "Client profile deleted",
|
deleteClientSuccess: "Client profile deleted",
|
||||||
deleteClientError: "Could not delete profile: {{error}}",
|
deleteClientError: "Could not delete profile: {{error}}",
|
||||||
createClientProfile: "Create client profile",
|
createClientProfile: "Create client profile",
|
||||||
|
createClientProfileSuccess: "New client profile created",
|
||||||
|
createClientProfileError: "Could not create client profile: '{{error}}'",
|
||||||
|
createClientProfileNameHelperText:
|
||||||
|
"The name must be unique within the realm",
|
||||||
allClientPolicies: "Client policies",
|
allClientPolicies: "Client policies",
|
||||||
newClientProfile: "Create client profile",
|
newClientProfile: "Create client profile",
|
||||||
newClientProfileName: "Client profile name",
|
newClientProfileName: "Client profile name",
|
||||||
|
@ -242,6 +246,12 @@ export default {
|
||||||
reload: "Reload",
|
reload: "Reload",
|
||||||
global: "Global",
|
global: "Global",
|
||||||
description: "description",
|
description: "description",
|
||||||
|
executors: "Executors",
|
||||||
|
executorsHelpText:
|
||||||
|
"Executors, which will be applied for this client profile",
|
||||||
|
executorsHelpItem: "Executors help item",
|
||||||
|
addExecutor: "Add executor",
|
||||||
|
emptyExecutors: "No executors configured",
|
||||||
tokens: "Tokens",
|
tokens: "Tokens",
|
||||||
key: "Key",
|
key: "Key",
|
||||||
value: "Value",
|
value: "Value",
|
||||||
|
|
Loading…
Reference in a new issue