diff --git a/src/components/keycloak-card/KeycloakCard.tsx b/src/components/keycloak-card/KeycloakCard.tsx index 8c36a538f0..acb2758caa 100644 --- a/src/components/keycloak-card/KeycloakCard.tsx +++ b/src/components/keycloak-card/KeycloakCard.tsx @@ -67,7 +67,7 @@ export const KeycloakCard = ({ /> )} - {title} + {title} diff --git a/src/user-federation/UserFederationKerberosSettings.tsx b/src/user-federation/UserFederationKerberosSettings.tsx index d84d2d7f75..e16afb281d 100644 --- a/src/user-federation/UserFederationKerberosSettings.tsx +++ b/src/user-federation/UserFederationKerberosSettings.tsx @@ -170,12 +170,13 @@ export const UserFederationKerberosSettings = () => {
- diff --git a/src/user-federation/UserFederationSection.tsx b/src/user-federation/UserFederationSection.tsx index 9948af9937..1ebe6a2be9 100644 --- a/src/user-federation/UserFederationSection.tsx +++ b/src/user-federation/UserFederationSection.tsx @@ -47,7 +47,7 @@ export const UserFederationSection = () => { () => { const testParams: { [name: string]: string | number } = { parentId: realm, - type: "org.keycloak.storage.UserStorageProvider", // MF note that this is providerType in the output, but API call is still type + type: "org.keycloak.storage.UserStorageProvider", }; return adminClient.components.find(testParams); }, @@ -172,7 +172,11 @@ export const UserFederationSection = () => {
- + history.push(`${url}/kerberos/new`)} + data-cy="kerberos-card" + > diff --git a/src/user-federation/kerberos/KerberosSettingsRequired.tsx b/src/user-federation/kerberos/KerberosSettingsRequired.tsx index 6d85aa923e..e53e6c0259 100644 --- a/src/user-federation/kerberos/KerberosSettingsRequired.tsx +++ b/src/user-federation/kerberos/KerberosSettingsRequired.tsx @@ -107,6 +107,7 @@ export const KerberosSettingsRequired = ({ message: `${t("validateName")}`, }, })} + data-cy="kerberos-name" /> {form.errors.name && (
{form.errors.name.message}
@@ -136,6 +137,7 @@ export const KerberosSettingsRequired = ({ message: `${t("validateRealm")}`, }, })} + data-cy="kerberos-realm" /> {form.errors.config && form.errors.config.kerberosRealm && @@ -169,6 +171,7 @@ export const KerberosSettingsRequired = ({ message: `${t("validateServerPrincipal")}`, }, })} + data-cy="kerberos-principal" /> {form.errors.config && form.errors.config.serverPrincipal && @@ -202,6 +205,7 @@ export const KerberosSettingsRequired = ({ message: `${t("validateKeyTab")}`, }, })} + data-cy="kerberos-keytab" /> {form.errors.config && form.errors.config.keyTab && diff --git a/src/user-federation/shared/SettingsCache.tsx b/src/user-federation/shared/SettingsCache.tsx index ba41fb576a..69bc9b56c0 100644 --- a/src/user-federation/shared/SettingsCache.tsx +++ b/src/user-federation/shared/SettingsCache.tsx @@ -126,6 +126,7 @@ export const SettingsCache = ({ }} selections={value} variant={SelectVariant.single} + data-cy="kerberos-cache-policy" > @@ -292,6 +293,7 @@ export const SettingsCache = ({ id="kc-max-lifespan" name="config.maxLifespan[0]" ref={form.register} + data-cy="kerberos-cache-lifespan" /> ) : ( diff --git a/tests/cypress/integration/user_fed_kerberos_test.spec.ts b/tests/cypress/integration/user_fed_kerberos_test.spec.ts new file mode 100644 index 0000000000..87bbac1ada --- /dev/null +++ b/tests/cypress/integration/user_fed_kerberos_test.spec.ts @@ -0,0 +1,85 @@ +import LoginPage from "../support/pages/LoginPage"; +import SidebarPage from "../support/pages/admin_console/SidebarPage"; +// import ListingPage from "../support/pages/admin_console/ListingPage"; +import CreateKerberosProviderPage from "../support/pages/admin_console/manage/providers/CreateKerberosProviderPage"; +// import Masthead from "../support/pages/admin_console/Masthead"; +// import { wait } from "@testing-library/react"; + +const loginPage = new LoginPage(); +// const masthead = new Masthead(); +const sidebarPage = new SidebarPage(); +// const listingPage = new ListingPage(); +const providersPage = new CreateKerberosProviderPage(); + +// config info +const kerberosName = "my-kerberos"; +const kerberosRealm = "my-realm"; +const kerberosPrincipal = "my-principal"; +const kerberosKeytab = "my-keytab"; +// const kerberosSecondName = "my-kerberos-2"; + +const policy = "EVICT_WEEKLY" +const kerberosDay = "Tuesday"; +const kerberosHour = "11"; +const kerberosMinute = "45"; +// const kerberosLifespan = "24"; + +describe('User Fed Kerberos test', () => { + it('Kerberos provider creation from empty state', () => { + cy.visit(""); + loginPage.logIn(); + + // CREATE FROM EMPTY STATE CARD PAGE + sidebarPage.goToUserFederation(); + cy.get('[data-cy=kerberos-card]').click(); + // cy.get('[data-cy=kerberos-name]').type("my-kerberos-provider"); + providersPage.fillKerberosRequiredData(kerberosName, kerberosRealm, kerberosPrincipal, kerberosKeytab); + providersPage.save(); + // TODO verify save message + + + // UPDATE + sidebarPage.goToUserFederation(); + cy.get('[data-cy="keycloak-card-title"]').contains("my-kerberos").click(); + + + providersPage.selectCacheType(policy); + // cy.get('[data-cy="kerberos-cache-policy"]').select(policy); + providersPage.fillCachedData( kerberosHour, kerberosMinute) + + + + + // TODO verify update message + + + // CREATE FROM USER FED CARD PAGE + + + + + + }) + + // Messages: + // User federation provider successfully created + // The user federation provider has been deleted. + + + + + // it("should open kerberos empty settings page by clicking card", function () { + + // // // listingPage.goToCreateItem(); + // // cy.get('[data-cy=kerberos-card]').click(); + // // cy.get('[data-cy=kerberos-name]').type("my-kerberos-provider"); + // // // providersPage.fillKerberosRequiredData(kerberosName, kerberosRealm, kerberosPrincipal, kerberosKeytab); + + // // // providersPage.save(); + + // // // The error should inform about duplicated name/id (THIS MESSAGE DOES NOT HAVE QUOTES AS THE OTHERS) + // // // masthead.checkNotificationMessage( + // // // "Could not create role: Role with name admin already exists" + // // // ); + // }); +}) \ No newline at end of file diff --git a/tests/cypress/support/pages/admin_console/manage/providers/CreateKerberosProviderPage.ts b/tests/cypress/support/pages/admin_console/manage/providers/CreateKerberosProviderPage.ts new file mode 100644 index 0000000000..3355843086 --- /dev/null +++ b/tests/cypress/support/pages/admin_console/manage/providers/CreateKerberosProviderPage.ts @@ -0,0 +1,133 @@ +export default class CreateKerberosProviderPage { + kerberosNameInput: string; + kerberosRealmInput: string; + kerberosPrincipalInput: string; + kerberosKeytabInput: string; + + // clientScopeTypeDrpDwn: string; + // this.clientScopeTypeDrpDwn = "#kc-protocol"; + // selectClientScopeType(clientScopeType: string) { + // cy.get(this.clientScopeTypeDrpDwn).click(); + // cy.get(this.clientScopeTypeList).contains(clientScopeType).click(); + + // return this; + // } + + // kerberosCachePolicyInput: string; + kerberosCacheDayInput: string; + kerberosCacheDayList: string; + kerberosCacheHourInput: string; + kerberosCacheHourList: string; + kerberosCacheMinuteInput: string; + kerberosCacheMinuteList: string; + // kerberosCacheLifespanInput: string; + + kerberosCachePolicyInput: string; + kerberosCachePolicyList: string; + + realmRoleNameError: string; + realmRoleDescriptionInput: string; + saveBtn: string; + cancelBtn: string; + + constructor() { + // cypress IDs + this.kerberosNameInput = "data-cy=kerberos-name"; + this.kerberosRealmInput = "data-cy=kerberos-realm"; + this.kerberosPrincipalInput = "data-cy=kerberos-principal"; + this.kerberosKeytabInput = "data-cy=kerberos-keytab"; + + this.kerberosCachePolicyInput = "#kc-cache-policy"; + this.kerberosCachePolicyList = "#kc-cache-policy + ul"; + + this.kerberosCacheDayInput = "#kc-eviction-day"; + this.kerberosCacheDayList = "#kc-eviction-day + ul"; + this.kerberosCacheHourInput = "#kc-eviction-hour"; + this.kerberosCacheHourList = "#kc-eviction-hour + ul"; + this.kerberosCacheMinuteInput = "#kc-eviction-minute"; + this.kerberosCacheMinuteList = "#kc-eviction-minute + ul"; + // this.kerberosCacheLifespanInput = "data-cy=kerberos-cache-lifespan"; + + this.realmRoleNameError = "#kc-name-helper"; + this.realmRoleDescriptionInput = "#kc-role-description"; + + this.saveBtn = "data-cy=kerberos-save"; + this.cancelBtn = "data-cy=kerberos-cancel"; + + // this.cardTitle = "keycloak-card-title"; + } + + //#region Required Settings + fillKerberosRequiredData( + name: string, + realm: string, + principal: string, + keytab: string + ) { + // cy.get(this.realmRoleNameInput).clear(); + if (name) { + cy.get(`[${this.kerberosNameInput}]`).type(name); + } + if (realm) { + cy.get(`[${this.kerberosRealmInput}]`).type(realm); + } + if (principal) { + cy.get(`[${this.kerberosPrincipalInput}]`).type(principal); + } + if (keytab) { + cy.get(`[${this.kerberosKeytabInput}]`).type(keytab); + } + + return this; + } + + selectCacheType(cacheType: string) { + cy.get(this.kerberosCachePolicyInput).click(); + + cy.get(this.kerberosCachePolicyList).contains(cacheType).click(); + + return this; + } + + // fillCachedData(day: string, hour: string, minute: string) { + fillCachedData(hour: string, minute: string) { + // cy.get(this.realmRoleNameInput).clear(); + // if (policy) { + // cy.get(`[${this.kerberosNameInput}]`).type(policy); + // } + // if (day) { + // cy.get(this.kerberosCacheDayInput).click(); + // // cy.get(this.kerberosCacheDayInput).contains(day).click(); + // cy.get(this.kerberosCacheDayInput).contains().click(); + + // } + if (hour) { + cy.get(this.kerberosCacheHourInput).click(); + cy.get(this.kerberosCacheHourInput).contains(hour).click(); + } + if (minute) { + cy.get(this.kerberosCacheMinuteInput).click(); + cy.get(this.kerberosCacheMinuteInput).contains(minute).click(); + } + return this; + } + + // checkRealmRoleNameRequiredMessage(exist = true) { + // cy.get(this.realmRoleNameError).should((!exist ? "not." : "") + "exist"); + + // return this; + // } + //#endregion + + save() { + cy.get(`[${this.saveBtn}]`).click(); + + return this; + } + + cancel() { + cy.get(this.cancelBtn).click(); + + return this; + } +} diff --git a/tests/cypress/tsconfig.json b/tests/cypress/tsconfig.json new file mode 100644 index 0000000000..08bba6121a --- /dev/null +++ b/tests/cypress/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress"] + }, + "include": [ + "**/*.ts" + ] + } \ No newline at end of file