fix the name of the fields introduced test (#1199)

* fix the name of the fields introduced test

fixes: #1182

* changed to use display none to hide fields
This commit is contained in:
Erik Jan de Wit 2021-09-23 09:48:23 +02:00 committed by GitHub
parent 83d5624bf4
commit 8fc517f2a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 133 additions and 100 deletions

View file

@ -292,6 +292,23 @@ describe("Realm settings", () => {
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();

View file

@ -60,13 +60,14 @@ export default {
failureFactor: "How many failures before wait is triggered.",
permanentLockout:
"Lock the user permanently when the user exceeds the maximum login failures.",
waitIncrement:
waitIncrementSeconds:
"When failure threshold has been met, how much time should the user be locked out?",
maxFailureWait: "Max time a user will be locked out.",
maxDeltaTime: "When will failure count be reset?",
maxFailureWaitSeconds: "Max time a user will be locked out.",
maxDeltaTimeSeconds: "When will failure count be reset?",
quickLoginCheckMilliSeconds:
"If a failure happens concurrently too quickly, lock out the user.",
minimumQuickLoginWait: "How long to wait after a quick login failure.",
minimumQuickLoginWaitSeconds:
"How long to wait after a quick login failure.",
ssoSessionIdle:
"Time a session is allowed to be idle before it expires. Tokens and browser sessions are invalidated when a session is expired.",
ssoSessionMax:

View file

@ -611,11 +611,11 @@ export default {
strictTransportSecurity: "HTTP Strict Transport Security (HSTS)",
failureFactor: "Max login failures",
permanentLockout: "Permanent lockout",
waitIncrement: "Wait increment",
maxFailureWait: "Max wait",
maxDeltaTime: "Failure reset time",
waitIncrementSeconds: "Wait increment",
maxFailureWaitSeconds: "Max wait",
maxDeltaTimeSeconds: "Failure reset time",
quickLoginCheckMilliSeconds: "Quick login check milliseconds",
minimumQuickLoginWait: "Minimum quick login wait",
minimumQuickLoginWaitSeconds: "Minimum quick login wait",
},
"partial-import": {
partialImportHeaderText:

View file

@ -62,8 +62,6 @@ export const BruteForceDetection = ({
)}
/>
</FormGroup>
{enable && (
<>
<FormGroup
label={t("failureFactor")}
labelIcon={
@ -74,6 +72,7 @@ export const BruteForceDetection = ({
/>
}
fieldId="failureFactor"
style={enable ? {} : { display: "none" }}
>
<Controller
name="failureFactor"
@ -98,6 +97,7 @@ export const BruteForceDetection = ({
label={t("permanentLockout")}
fieldId="permanentLockout"
hasNoPaddingTop
style={enable ? {} : { display: "none" }}
>
<Controller
name="permanentLockout"
@ -115,13 +115,18 @@ export const BruteForceDetection = ({
/>
</FormGroup>
{!permanentLockout && (
<>
<Time name="waitIncrement" />
<Time name="maxFailureWait" />
<Time name="maxDeltaTime" />
</>
)}
<Time
name="waitIncrementSeconds"
style={enable && !permanentLockout ? {} : { display: "none" }}
/>
<Time
name="maxFailureWaitSeconds"
style={enable && !permanentLockout ? {} : { display: "none" }}
/>
<Time
name="maxDeltaTimeSeconds"
style={enable && !permanentLockout ? {} : { display: "none" }}
/>
<FormGroup
label={t("quickLoginCheckMilliSeconds")}
@ -133,6 +138,7 @@ export const BruteForceDetection = ({
/>
}
fieldId="quickLoginCheckMilliSeconds"
style={enable ? {} : { display: "none" }}
>
<Controller
name="quickLoginCheckMilliSeconds"
@ -153,9 +159,10 @@ export const BruteForceDetection = ({
/>
</FormGroup>
<Time name="minimumQuickLoginWait" />
</>
)}
<Time
name="minimumQuickLoginWaitSeconds"
style={enable ? {} : { display: "none" }}
/>
<ActionGroup>
<Button

View file

@ -1,4 +1,4 @@
import React from "react";
import React, { CSSProperties } from "react";
import { useTranslation } from "react-i18next";
import { Controller, useFormContext } from "react-hook-form";
import { FormGroup, ValidatedOptions } from "@patternfly/react-core";
@ -6,11 +6,18 @@ import { FormGroup, ValidatedOptions } from "@patternfly/react-core";
import { HelpItem } from "../../components/help-enabler/HelpItem";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
export const Time = ({ name }: { name: string }) => {
export const Time = ({
name,
style,
}: {
name: string;
style?: CSSProperties;
}) => {
const { t } = useTranslation("realm-settings");
const { control, errors } = useFormContext();
return (
<FormGroup
style={style}
label={t(name)}
fieldId={name}
labelIcon={
@ -32,6 +39,7 @@ export const Time = ({ name }: { name: string }) => {
rules={{ required: true }}
render={({ onChange, value }) => (
<TimeSelector
data-testId={name}
value={value}
onChange={onChange}
validated={