diff --git a/cypress/integration/realm_settings_test.spec.ts b/cypress/integration/realm_settings_test.spec.ts index 448ba6dc2f..715d7ac513 100644 --- a/cypress/integration/realm_settings_test.spec.ts +++ b/cypress/integration/realm_settings_test.spec.ts @@ -82,7 +82,6 @@ describe("Realm settings", () => { realmSettingsPage.toggleSwitch(realmSettingsPage.userRegSwitch); realmSettingsPage.toggleSwitch(realmSettingsPage.forgotPwdSwitch); realmSettingsPage.toggleSwitch(realmSettingsPage.rememberMeSwitch); - realmSettingsPage.toggleSwitch(realmSettingsPage.verifyEmailSwitch); }); it("Go to email tab", () => { @@ -233,6 +232,56 @@ describe("Realm settings", () => { cy.getId("headers-form-tab-save").should("be.disabled"); cy.get("#xFrameOptions").clear().type("DENY"); cy.getId("headers-form-tab-save").should("be.enabled").click(); + masthead.checkNotificationMessage("Realm successfully updated"); }); + + it("add session data", () => { + sidebarPage.goToRealmSettings(); + + cy.wait(500); + + cy.getId("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.wait(500); + + cy.getId("rs-sessions-tab").click(); + + cy.getId(realmSettingsPage.ssoSessionIdleInput).should("have.value", 1); + cy.getId(realmSettingsPage.ssoSessionMaxInput).should("have.value", 2); + cy.getId(realmSettingsPage.ssoSessionIdleRememberMeInput).should( + "have.value", + 3 + ); + cy.getId(realmSettingsPage.ssoSessionMaxRememberMeInput).should( + "have.value", + 4 + ); + + cy.getId(realmSettingsPage.clientSessionIdleInput).should("have.value", 5); + cy.getId(realmSettingsPage.clientSessionMaxInput).should("have.value", 6); + + cy.getId(realmSettingsPage.offlineSessionIdleInput).should("have.value", 7); + cy.getId(realmSettingsPage.offlineSessionMaxSwitch).should( + "have.value", + "on" + ); + + cy.getId(realmSettingsPage.loginTimeoutInput).should("have.value", 9); + cy.getId(realmSettingsPage.loginActionTimeoutInput).should( + "have.value", + 10 + ); + }); }); diff --git a/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts b/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts index 81350a652f..eabe6daee6 100644 --- a/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts +++ b/cypress/support/pages/admin_console/manage/realm_settings/RealmSettingsPage.ts @@ -12,8 +12,40 @@ export default class RealmSettingsPage { selectEmailTheme = "#kc-email-theme"; emailThemeList = "#kc-email-theme + ul"; hostInput = "#kc-host"; + ssoSessionIdleSelectMenu = "#kc-sso-session-idle-select-menu"; + ssoSessionIdleSelectMenuList = "#kc-sso-session-idle-select-menu > div > ul"; + ssoSessionMaxSelectMenu = "#kc-sso-session-max-select-menu"; + ssoSessionMaxSelectMenuList = "#kc-sso-session-max-select-menu > div > ul"; + + ssoSessionMaxRememberMeSelectMenu = + "#kc-sso-session-max-remember-me-select-menu"; + ssoSessionMaxRememberMeSelectMenuList = + "#kc-sso-session-max-remember-me-select-menu > div > ul"; + + ssoSessionIdleRememberMeSelectMenu = + "#kc-sso-session-idle-remember-me-select-menu"; + ssoSessionIdleRememberMeSelectMenuList = + "#kc-sso-session-idle-remember-me-select-menu > div > ul"; + + clientSessionIdleSelectMenu = "#kc-client-session-idle-select-menu"; + clientSessionIdleSelectMenuList = + "#kc-client-session-idle-select-menu > div > ul"; + + clientSessionMaxSelectMenu = "#kc-client-session-max-select-menu"; + clientSessionMaxSelectMenuList = + "#kc-client-session-max-select-menu > div > ul"; + + offlineSessionIdleSelectMenu = "#kc-offline-session-idle-select-menu"; + + loginTimeoutSelectMenu = "#kc-login-timeout-select-menu"; + loginTimeoutSelectMenuList = "#kc-login-timeout-select-menu > div > ul"; + + loginActionTimeoutSelectMenu = "#kc-login-action-timeout-select-menu"; + loginActionTimeoutSelectMenuList = + "#kc-login-action-timeout-select-menu > div > ul"; + selectDefaultLocale = "select-default-locale"; - defaultLocaleList = "select-default-locale + ul"; + defaultLocaleList = "select-default-locale > div > ul"; emailSaveBtn = "email-tab-save"; managedAccessSwitch = "user-managed-access-switch"; userRegSwitch = "user-reg-switch"; @@ -45,6 +77,16 @@ export default class RealmSettingsPage { valueInput = "value-input"; deleteAction = "delete-action"; modalConfirm = "modalConfirm"; + ssoSessionIdleInput = "sso-session-idle-input"; + ssoSessionMaxInput = "sso-session-max-input"; + ssoSessionIdleRememberMeInput = "sso-session-idle-remember-me-input"; + ssoSessionMaxRememberMeInput = "sso-session-max-remember-me-input"; + clientSessionIdleInput = "client-session-idle-input"; + clientSessionMaxInput = "client-session-max-input"; + offlineSessionIdleInput = "offline-session-idle-input"; + offlineSessionMaxSwitch = "offline-session-max-switch"; + loginTimeoutInput = "login-timeout-input"; + loginActionTimeoutInput = "login-action-timeout-input"; selectLoginThemeType(themeType: string) { cy.get(this.selectLoginTheme).click(); @@ -192,6 +234,86 @@ export default class RealmSettingsPage { return this; } + changeTimeUnit( + unit: "Minutes" | "Hours" | "Days", + inputType: string, + listType: string + ) { + switch (unit) { + case "Minutes": + cy.get(inputType).click(); + cy.get(listType).contains(unit).click(); + break; + case "Hours": + cy.get(inputType).click(); + cy.get(listType).contains(unit).click(); + break; + case "Days": + cy.get(inputType).click(); + cy.get(listType).contains(unit).click(); + break; + default: + throw "Invalid unit, must be 'minutes', 'hours', or 'days'."; + } + return this; + } + + populateSessionsPage() { + cy.getId(this.ssoSessionIdleInput).clear().type("1"); + this.changeTimeUnit( + "Minutes", + this.ssoSessionIdleSelectMenu, + this.ssoSessionIdleSelectMenuList + ); + cy.getId(this.ssoSessionMaxInput).clear().type("2"); + this.changeTimeUnit( + "Hours", + this.ssoSessionMaxSelectMenu, + this.ssoSessionMaxSelectMenuList + ); + cy.getId(this.ssoSessionIdleRememberMeInput).clear().type("3"); + this.changeTimeUnit( + "Days", + this.ssoSessionIdleRememberMeSelectMenu, + this.ssoSessionIdleRememberMeSelectMenuList + ); + cy.getId(this.ssoSessionMaxRememberMeInput).clear().type("4"); + this.changeTimeUnit( + "Minutes", + this.ssoSessionMaxRememberMeSelectMenu, + this.ssoSessionMaxRememberMeSelectMenuList + ); + + cy.getId(this.clientSessionIdleInput).clear().type("5"); + this.changeTimeUnit( + "Hours", + this.clientSessionIdleSelectMenu, + this.clientSessionIdleSelectMenuList + ); + cy.getId(this.clientSessionMaxInput).clear().type("6"); + this.changeTimeUnit( + "Days", + this.clientSessionMaxSelectMenu, + this.clientSessionMaxSelectMenuList + ); + + cy.getId(this.offlineSessionIdleInput).clear().type("7"); + this.toggleSwitch(this.offlineSessionMaxSwitch); + + cy.getId(this.loginTimeoutInput).clear().type("9"); + this.changeTimeUnit( + "Minutes", + this.loginTimeoutSelectMenu, + this.loginTimeoutSelectMenuList + ); + cy.getId(this.loginActionTimeoutInput).clear().type("10"); + this.changeTimeUnit( + "Days", + this.loginActionTimeoutSelectMenu, + this.loginActionTimeoutSelectMenuList + ); + } + checkUserEvents(events: string[]) { cy.get(this.eventTypeColumn).should((event) => { for (const user of events) { diff --git a/public/index.css b/public/index.css index 4e85418721..0da5ce088e 100644 --- a/public/index.css +++ b/public/index.css @@ -10,21 +10,12 @@ margin-bottom: 52px; } -input[type='checkbox'] { +input[type="checkbox"] { height: 20px; width: 20px; vertical-align: baseline; } -label.pf-c-form__label { - display: inline-flex; -} - -.pf-c-form__group-label { - display: flex; - align-items: end; -} - .pf-c-select__toggle:before { border-top: var(--pf-c-select__toggle--before--BorderTopWidth) solid var(--pf-c-select__toggle--before--BorderTopColor); @@ -52,7 +43,7 @@ label.pf-c-form__label { cursor: pointer; } -td.pf-c-table__check > input[type='checkbox'] { +td.pf-c-table__check > input[type="checkbox"] { vertical-align: text-bottom; } @@ -64,3 +55,7 @@ td.pf-c-table__check > input[type='checkbox'] { .pf-c-pagination.pf-m-bottom.pf-m-compact { padding: 0px; } + +.kc-time-select-dropdown { + min-width: 170px; +} diff --git a/src/components/time-selector/TimeSelector.tsx b/src/components/time-selector/TimeSelector.tsx index 632c1c22a1..077f9b1252 100644 --- a/src/components/time-selector/TimeSelector.tsx +++ b/src/components/time-selector/TimeSelector.tsx @@ -16,12 +16,14 @@ export type TimeSelectorProps = TextInputProps & { value: number; units?: Unit[]; onChange: (time: number | string) => void; + className?: string; }; export const TimeSelector = ({ value, units = ["seconds", "minutes", "hours", "days"], onChange, + className, ...rest }: TimeSelectorProps) => { const { t } = useTranslation("common"); @@ -75,7 +77,7 @@ export const TimeSelector = ({ }; return ( - + { updateTimeout("" === value ? value : parseInt(value)); }} /> - +