adding preliminary cypress tests
This commit is contained in:
parent
1a78540c8f
commit
cf8451fe9d
8 changed files with 243 additions and 4 deletions
|
@ -67,7 +67,7 @@ export const KeycloakCard = ({
|
|||
/>
|
||||
)}
|
||||
</CardActions>
|
||||
<CardTitle>{title}</CardTitle>
|
||||
<CardTitle data-cy="keycloak-card-title">{title}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardBody />
|
||||
<CardFooter>
|
||||
|
|
|
@ -170,12 +170,13 @@ export const UserFederationKerberosSettings = () => {
|
|||
<SettingsCache form={form} showSectionHeading />
|
||||
<Form onSubmit={form.handleSubmit(save)}>
|
||||
<ActionGroup>
|
||||
<Button variant="primary" type="submit">
|
||||
<Button variant="primary" type="submit" data-cy="kerberos-save">
|
||||
{t("common:save")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="link"
|
||||
onClick={() => history.push(`/${realm}/user-federation`)}
|
||||
data-cy="kerberos-cancel"
|
||||
>
|
||||
{t("common:cancel")}
|
||||
</Button>
|
||||
|
|
|
@ -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 = () => {
|
|||
</TextContent>
|
||||
<hr className="pf-u-mb-lg" />
|
||||
<Gallery hasGutter>
|
||||
<Card isHoverable>
|
||||
<Card
|
||||
isHoverable
|
||||
onClick={() => history.push(`${url}/kerberos/new`)}
|
||||
data-cy="kerberos-card"
|
||||
>
|
||||
<CardTitle>
|
||||
<Split hasGutter>
|
||||
<SplitItem>
|
||||
|
|
|
@ -107,6 +107,7 @@ export const KerberosSettingsRequired = ({
|
|||
message: `${t("validateName")}`,
|
||||
},
|
||||
})}
|
||||
data-cy="kerberos-name"
|
||||
/>
|
||||
{form.errors.name && (
|
||||
<div className="error">{form.errors.name.message}</div>
|
||||
|
@ -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 &&
|
||||
|
|
|
@ -126,6 +126,7 @@ export const SettingsCache = ({
|
|||
}}
|
||||
selections={value}
|
||||
variant={SelectVariant.single}
|
||||
data-cy="kerberos-cache-policy"
|
||||
>
|
||||
<SelectOption key={0} value={["DEFAULT"]} isPlaceholder />
|
||||
<SelectOption key={1} value={["EVICT_DAILY"]} />
|
||||
|
@ -292,6 +293,7 @@ export const SettingsCache = ({
|
|||
id="kc-max-lifespan"
|
||||
name="config.maxLifespan[0]"
|
||||
ref={form.register}
|
||||
data-cy="kerberos-cache-lifespan"
|
||||
/>
|
||||
</FormGroup>
|
||||
) : (
|
||||
|
|
85
tests/cypress/integration/user_fed_kerberos_test.spec.ts
Normal file
85
tests/cypress/integration/user_fed_kerberos_test.spec.ts
Normal file
|
@ -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"
|
||||
// // // );
|
||||
// });
|
||||
})
|
|
@ -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;
|
||||
}
|
||||
}
|
10
tests/cypress/tsconfig.json
Normal file
10
tests/cypress/tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["es5", "dom"],
|
||||
"types": ["cypress"]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue