Add labels for supported applications to 'OTP Policy' (#3633)
This commit is contained in:
parent
ec54a065f7
commit
a2ac19339e
4 changed files with 34 additions and 34 deletions
|
@ -20,7 +20,7 @@ describe("Policies", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should change to hotp", () => {
|
it("should change to hotp", () => {
|
||||||
otpPoliciesPage.checkSupportedActions("FreeOTP, Google Authenticator");
|
otpPoliciesPage.checkSupportedActions("FreeOTP", "Google Authenticator");
|
||||||
otpPoliciesPage.setPolicyType("hotp").increaseInitialCounter().save();
|
otpPoliciesPage.setPolicyType("hotp").increaseInitialCounter().save();
|
||||||
masthead.checkNotificationMessage("OTP policy successfully updated");
|
masthead.checkNotificationMessage("OTP policy successfully updated");
|
||||||
otpPoliciesPage.checkSupportedActions("FreeOTP");
|
otpPoliciesPage.checkSupportedActions("FreeOTP");
|
||||||
|
|
|
@ -14,8 +14,11 @@ export default class OTPPolicies {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSupportedActions(supportedActions: string) {
|
checkSupportedActions(...supportedActions: string[]) {
|
||||||
cy.findByTestId("supportedActions").should("have.value", supportedActions);
|
cy.findByTestId("supportedActions").should(
|
||||||
|
"have.text",
|
||||||
|
supportedActions.join("")
|
||||||
|
);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,10 @@
|
||||||
"initialCounter": "Initial counter",
|
"initialCounter": "Initial counter",
|
||||||
"initialCounterErrorHint": "Value needs to be between 1 and 120",
|
"initialCounterErrorHint": "Value needs to be between 1 and 120",
|
||||||
"supportedActions": "Supported actions",
|
"supportedActions": "Supported actions",
|
||||||
|
"otpSupportedApplications": {
|
||||||
|
"totpAppFreeOTPName": "FreeOTP",
|
||||||
|
"totpAppGoogleName": "Google Authenticator"
|
||||||
|
},
|
||||||
"updateOtpSuccess": "OTP policy successfully updated",
|
"updateOtpSuccess": "OTP policy successfully updated",
|
||||||
"updateOtpError": "Could not update OTP policy: {{error}}",
|
"updateOtpError": "Could not update OTP policy: {{error}}",
|
||||||
"webAuthnPolicySignatureAlgorithms": "Signature algorithms",
|
"webAuthnPolicySignatureAlgorithms": "Signature algorithms",
|
||||||
|
|
|
@ -1,30 +1,31 @@
|
||||||
import { useEffect } from "react";
|
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
|
||||||
import {
|
import {
|
||||||
PageSection,
|
|
||||||
FormGroup,
|
|
||||||
Radio,
|
|
||||||
Select,
|
|
||||||
SelectVariant,
|
|
||||||
SelectOption,
|
|
||||||
NumberInput,
|
|
||||||
ActionGroup,
|
ActionGroup,
|
||||||
|
AlertVariant,
|
||||||
Button,
|
Button,
|
||||||
ButtonVariant,
|
ButtonVariant,
|
||||||
AlertVariant,
|
Chip,
|
||||||
|
ChipGroup,
|
||||||
|
FormGroup,
|
||||||
|
NumberInput,
|
||||||
|
PageSection,
|
||||||
|
Radio,
|
||||||
|
Select,
|
||||||
|
SelectOption,
|
||||||
|
SelectVariant,
|
||||||
Switch,
|
Switch,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
import { useAlerts } from "../../components/alert/Alerts";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
import useToggle from "../../utils/useToggle";
|
|
||||||
import { TimeSelector } from "../../components/time-selector/TimeSelector";
|
import { TimeSelector } from "../../components/time-selector/TimeSelector";
|
||||||
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
|
|
||||||
import { useAdminClient } from "../../context/auth/AdminClient";
|
import { useAdminClient } from "../../context/auth/AdminClient";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import { useAlerts } from "../../components/alert/Alerts";
|
import useToggle from "../../utils/useToggle";
|
||||||
|
|
||||||
import "./otp-policy.css";
|
import "./otp-policy.css";
|
||||||
|
|
||||||
|
@ -41,7 +42,6 @@ export const OtpPolicy = ({ realm, realmUpdated }: OtpPolicyProps) => {
|
||||||
const { t } = useTranslation("authentication");
|
const { t } = useTranslation("authentication");
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
register,
|
|
||||||
reset,
|
reset,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { isDirty, errors },
|
formState: { isDirty, errors },
|
||||||
|
@ -58,11 +58,7 @@ export const OtpPolicy = ({ realm, realmUpdated }: OtpPolicyProps) => {
|
||||||
defaultValue: POLICY_TYPES[0],
|
defaultValue: POLICY_TYPES[0],
|
||||||
});
|
});
|
||||||
|
|
||||||
const setupForm = (realm: RealmRepresentation) =>
|
const setupForm = (realm: RealmRepresentation) => reset(realm);
|
||||||
reset({
|
|
||||||
...realm,
|
|
||||||
otpSupportedApplications: realm.otpSupportedApplications?.join(", "),
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => setupForm(realm), []);
|
useEffect(() => setupForm(realm), []);
|
||||||
|
|
||||||
|
@ -304,7 +300,6 @@ export const OtpPolicy = ({ realm, realmUpdated }: OtpPolicyProps) => {
|
||||||
)}
|
)}
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={t("supportedActions")}
|
label={t("supportedActions")}
|
||||||
fieldId="supportedActions"
|
|
||||||
labelIcon={
|
labelIcon={
|
||||||
<HelpItem
|
<HelpItem
|
||||||
helpText="authentication-help:supportedActions"
|
helpText="authentication-help:supportedActions"
|
||||||
|
@ -312,15 +307,13 @@ export const OtpPolicy = ({ realm, realmUpdated }: OtpPolicyProps) => {
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<KeycloakTextInput
|
<ChipGroup data-testid="supportedActions">
|
||||||
id="supportedActions"
|
{realm.otpSupportedApplications?.map((key) => (
|
||||||
name="otpSupportedApplications"
|
<Chip key={key} isReadOnly>
|
||||||
ref={register({
|
{t(`otpSupportedApplications.${key}`)}
|
||||||
setValueAs: (value) => value.split(", "),
|
</Chip>
|
||||||
})}
|
))}
|
||||||
data-testid="supportedActions"
|
</ChipGroup>
|
||||||
isReadOnly
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
{otpType === POLICY_TYPES[0] && (
|
{otpType === POLICY_TYPES[0] && (
|
||||||
|
|
Loading…
Reference in a new issue