Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions js/apps/admin-ui/cypress/e2e/realm_settings_events_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ describe("Realm settings events tab tests", () => {
return this;
};

const addBundle = () => {
realmSettingsPage.addKeyValuePair("key_" + uuid(), "value_" + uuid());

return this;
};

it("Enable user events", () => {
cy.intercept("GET", `/admin/realms/${realmName}/events/config`).as("load");
sidebarPage.goToRealmSettings();
Expand Down Expand Up @@ -240,33 +234,31 @@ describe("Realm settings events tab tests", () => {
realmSettingsPage.checkKeyPublic();
});

it("add locale", () => {
it("Realm header settings", () => {
sidebarPage.goToRealmSettings();
cy.findByTestId("rs-security-defenses-tab").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();

cy.findByTestId("rs-localization-tab").click();
cy.findByTestId("internationalization-disabled").click({ force: true });

cy.get(realmSettingsPage.supportedLocalesTypeahead)
.click()
.get(".pf-c-select__menu-item")
.contains("Danish")
.click();
cy.get("#kc-l-supported-locales").click();
masthead.checkNotificationMessage("Realm successfully updated");
});

cy.intercept("GET", `/admin/realms/${realmName}/localization/en*`).as(
"load",
);
it("Brute force detection", () => {
sidebarPage.goToRealmSettings();
cy.findAllByTestId("rs-security-defenses-tab").click();
cy.get("#pf-tab-20-bruteForce").click();

cy.findByTestId("localization-tab-save").click();
cy.wait("@load");
cy.findByTestId("brute-force-tab-save").should("be.disabled");

addBundle();
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");

masthead.checkNotificationMessage(
"Success! The message bundle has been added.",
);
realmSettingsPage.setDefaultLocale("Danish");
cy.findByTestId("localization-tab-save").click();
cy.findByTestId("brute-force-tab-save").should("be.enabled").click();
masthead.checkNotificationMessage("Realm successfully updated");
});

it("add session data", () => {
Expand Down
127 changes: 125 additions & 2 deletions js/apps/admin-ui/cypress/e2e/realm_settings_tabs_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ describe("Realm settings tabs tests", () => {
await adminClient.deleteRealm(realmName);
});

const addBundle = () => {
realmSettingsPage.addKeyValuePair("123", "abc");

return this;
};

it("shows the 'user profile' tab if enabled", () => {
sidebarPage.goToRealmSettings();
cy.findByTestId(realmSettingsPage.userProfileTab).should("not.exist");
Expand Down Expand Up @@ -167,6 +173,109 @@ describe("Realm settings tabs tests", () => {
});
});

describe("Go to localization tab", () => {
it("Locales tab - Add locale", () => {
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationLocalesSubTab();

cy.findByTestId("internationalization-disabled").click({ force: true });

cy.get(realmSettingsPage.supportedLocalesTypeahead)
.click()
.get(".pf-c-select__menu-item")
.contains("Danish")
.click();
cy.get("#kc-l-supported-locales").click();

cy.intercept("GET", `/admin/realms/${realmName}/localization/en*`).as(
"load",
);

cy.findByTestId("localization-tab-save").click();
cy.wait("@load");

masthead.checkNotificationMessage("Realm successfully updated");
});

it("Realm Overrides - Add and delete bundle", () => {
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationRealmOverridesSubTab();

addBundle();

masthead.checkNotificationMessage(
"Success! The message bundle has been added.",
);

cy.findByTestId("editable-rows-table")
.contains("td", "123")
.should("be.visible");

cy.findByTestId("realmOverrides-deleteKebabToggle").click();
cy.findByTestId("confirm").click();
masthead.checkNotificationMessage(
"Successfully removed message(s) from the bundle.",
);
});

it("Realm Overrides - Search for and delete bundle", () => {
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationRealmOverridesSubTab();

addBundle();

cy.get('input[aria-label="Search"]').type("123");

cy.findByTestId("editable-rows-table")
.contains("td", "123")
.should("be.visible");

cy.findByTestId("selectAll").click();
cy.get('[data-testid="toolbar-deleteBtn"] button').click();
cy.findByTestId("delete-selected-bundleBtn").click();
cy.findByTestId("confirm").click();
masthead.checkNotificationMessage(
"Successfully removed message(s) from the bundle.",
);
});

it("Realm Overrides - Edit and cancel edit message bundle", () => {
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationRealmOverridesSubTab();

addBundle();

cy.findByTestId("editUserLabelBtn-0").click();
cy.findByTestId("editUserLabelCancelBtn-0").click();

cy.findByTestId("editUserLabelBtn-0").click();
cy.findByTestId("editUserLabelInput-0").click().clear().type("def");
cy.findByTestId("editUserLabelAcceptBtn-0").click();

cy.findByTestId("editable-rows-table")
.contains("td", "def")
.should("be.visible");

cy.findByTestId("realmOverrides-deleteKebabToggle").click();
cy.findByTestId("confirm").click();

masthead.checkNotificationMessage(
"Successfully removed message(s) from the bundle.",
);
});

it("Effective Message Bundles - Check before search message", () => {
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationEffectiveMessageBundlesSubTab();
cy.contains("h1", "Search for effective messages");
});
});

describe("Accessibility tests for realm settings", () => {
beforeEach(() => {
loginPage.logIn();
Expand Down Expand Up @@ -226,18 +335,32 @@ describe("Realm settings tabs tests", () => {
cy.checkA11y();
});

it("Check a11y violations on localization tab", () => {
it("Check a11y violations on localization locales sub tab", () => {
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationLocalesSubTab();
cy.checkA11y();
});

it("Check a11y violations on localization realm overrides sub tab", () => {
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationRealmOverridesSubTab();
cy.checkA11y();
});

it("Check a11y violations on localization tab/ adding message bundle", () => {
it("Check a11y violations on localization realm overrides sub tab/ adding message bundle", () => {
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationRealmOverridesSubTab();
cy.findByTestId("add-bundle-button").click();
cy.checkA11y();
modalUtils.cancelModal();
});

it("Check a11y violations on localization effective message bundles sub tab", () => {
realmSettingsPage.goToLocalizationTab();
realmSettingsPage.goToLocalizationEffectiveMessageBundlesSubTab();
cy.checkA11y();
});

it("Check a11y violations on security defenses tab", () => {
realmSettingsPage.goToSecurityDefensesTab();
cy.checkA11y();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ export default class RealmSettingsPage extends CommonPage {
#port = "#kc-port";

#publicKeyBtn = ".kc-keys-list > tbody > tr > td > .button-wrapper > button";
#localizationLocalesSubTab = "rs-localization-locales-tab";
#localizationRealmOverridesSubTab = "rs-localization-realm-overrides-tab";
#localizationEffectiveMessageBundlesSubTab =
"rs-localization-effective-message-bundles-tab";
#realmSettingsEventsTab = new RealmSettingsEventsTab();
#realmId = 'input[aria-label="Copyable input"]';
#securityDefensesHeadersSaveBtn = "headers-form-tab-save";
Expand Down Expand Up @@ -456,7 +460,7 @@ export default class RealmSettingsPage extends CommonPage {
cy.findByTestId(this.keyInput).type(key);
cy.findByTestId(this.valueInput).type(value);

cy.findByTestId(this.confirmAddBundle).click();
cy.findByTestId(this.confirmAddBundle).click({ force: true });

return this;
}
Expand Down Expand Up @@ -1260,6 +1264,21 @@ export default class RealmSettingsPage extends CommonPage {
return this;
}

goToLocalizationLocalesSubTab() {
cy.findByTestId(this.#localizationLocalesSubTab).click();
return this;
}

goToLocalizationRealmOverridesSubTab() {
cy.findByTestId(this.#localizationRealmOverridesSubTab).click();
return this;
}

goToLocalizationEffectiveMessageBundlesSubTab() {
cy.findByTestId(this.#localizationEffectiveMessageBundlesSubTab).click();
return this;
}

goToSecurityDefensesTab() {
cy.findByTestId(this.securityDefensesTab).click();
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,7 @@ id=ID
join=Join
clientUpdaterSourceGroupsHelp=The condition checks the group of the entity who tries to create/update the client to determine whether the policy is applied.
idTokenEncryptionContentEncryptionAlgorithmHelp=JWA Algorithm used for content encryption in encrypting ID tokens. This option is needed just if you want encrypted ID tokens. If left empty, ID Tokens are just signed, but not encrypted.
messageBundleDescription=You can edit the supported locales. If you haven't selected supported locales yet, you can only edit the English locale.
messageBundleDescription=You can only edit the supported locales. If you haven't selected supported locales yet, you can only edit the English locale.
saveEventListenersError=Error saving event listener\: {{error}}
scopesHelp=The scopes to be sent when asking for authorization. It can be a space-separated list of scopes. Defaults to 'openid'.
multivalued.tooltip=Indicates if attribute supports multiple values. If true, the list of all values of this attribute will be set as claim. If false, just first value will be set as claim
Expand Down Expand Up @@ -2941,6 +2941,28 @@ invalidEmailMessage='{{0}}': Invalid email address.
missingLastNameMessage='{{0}}': Please specify last name.
missingEmailMessage='{{0}}': Please specify email.
missingPasswordMessage='{{0}}': Please specify password.
locales=Locales
realmOverrides=Realm overrides
realmOverridesHelp=You can only edit the supported locales. If you haven't selected supported locale yet, you only can edit English locale.
effectiveMessageBundles=Effective message bundles
effectiveMessageBundlesHelp=You can search for effective message bundles based on themes, features, language, and free text.
deleteMessageBundle=Delete message bundle {{key}}
deleteAllMessagesBundleSuccess=Successfully removed message(s) from the bundle.
deleteAllMessagesBundleError=Error removing message(s) from the bundle, {{error}}
noRealmOverridesSearchResultsInstructions=Click on the search bar above to search for realm overrides
emptyEffectiveMessageBundles=Search for effective messages
emptyEffectiveMessageBundlesInstructions=You can search for the effective messages you want by theme, feature and language in the search box above.
searchForEffectiveMessageBundles=Search for message bundle
selectAll=Select all
theme=Theme
themeType=Theme Type
language=Language
hasWords=Has words
deleteConfirmMessageBundle=Delete message bundle?
messageBundleDeleteConfirmDialog=Are you sure you want to permanently delete {{count}} selected message bundles
selectTheme=Select theme
selectThemeType=Select theme type
selectLanguage=Select language
referral=Referral
referralHelp=Specifies if LDAP referrals should be followed or ignored. Please note that enabling referrals can slow down authentication as it allows the LDAP server to decide which other LDAP servers to use. This could potentially include untrusted servers.
authenticatorRefConfig.value.help=Add a custom reference name for the authenticator. When this authenticator is successfully completed during an authentication flow, the Authentication Method Reference (AMR) protocol mapper will use this value to populate the amr claim of the generated tokens. Note, the AMR protocol must be configured for the given client to populate the AMR claim
Expand Down
12 changes: 1 addition & 11 deletions js/apps/admin-ui/src/realm-settings/LocalizationTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { useRealm } from "../context/realm-context/RealmContext";
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
import { useWhoAmI } from "../context/whoami/WhoAmI";
import { DEFAULT_LOCALE } from "../i18n/i18n";
import { convertToFormValues } from "../util";
import { convertToFormValues, localeToDisplayName } from "../util";
import { useFetch } from "../utils/useFetch";
import useLocaleSort, { mapByKey } from "../utils/useLocaleSort";
import { AddMessageBundleModal } from "./AddMessageBundleModal";
Expand Down Expand Up @@ -74,16 +74,6 @@ export type BundleForm = {
messageBundle: KeyValueType;
};

const localeToDisplayName = (locale: string, displayLocale: string) => {
try {
return new Intl.DisplayNames([displayLocale], { type: "language" }).of(
locale,
);
} catch (error) {
return locale;
}
};

export const LocalizationTab = ({ save, realm }: LocalizationTabProps) => {
const { t } = useTranslation();
const [addMessageBundleModalOpen, setAddMessageBundleModalOpen] =
Expand Down
9 changes: 2 additions & 7 deletions js/apps/admin-ui/src/realm-settings/RealmSettingsTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { convertFormValuesToObject, convertToFormValues } from "../util";
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
import { RealmSettingsEmailTab } from "./EmailTab";
import { RealmSettingsGeneralTab } from "./GeneralTab";
import { LocalizationTab } from "./LocalizationTab";
import { LocalizationTab } from "./localization/LocalizationTab";
import { RealmSettingsLoginTab } from "./LoginTab";
import { PartialExportDialog } from "./PartialExport";
import { PartialImportDialog } from "./PartialImport";
Expand Down Expand Up @@ -340,12 +340,7 @@ export const RealmSettingsTabs = ({
data-testid="rs-localization-tab"
{...localizationTab}
>
<LocalizationTab
key={key}
refresh={refresh}
save={save}
realm={realm}
/>
<LocalizationTab key={key} save={save} realm={realm} />
</Tab>
<Tab
title={<TabTitleText>{t("securityDefences")}</TabTitleText>}
Expand Down
Loading