added test saml advanced tab (#20880)
This commit is contained in:
parent
9c9cd4cf21
commit
c771890da8
5 changed files with 160 additions and 203 deletions
59
js/apps/admin-ui/cypress/e2e/clients_saml_advanced.spec.ts
Normal file
59
js/apps/admin-ui/cypress/e2e/clients_saml_advanced.spec.ts
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
import LoginPage from "../support/pages/LoginPage";
|
||||||
|
import Masthead from "../support/pages/admin-ui/Masthead";
|
||||||
|
import ListingPage from "../support/pages/admin-ui/ListingPage";
|
||||||
|
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
||||||
|
import adminClient from "../support/util/AdminClient";
|
||||||
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
||||||
|
import { AdvancedSamlTab } from "../support/pages/admin-ui/manage/clients/client_details/tabs/AdvancedSamlTab";
|
||||||
|
import ClientDetailsPage from "../support/pages/admin-ui/manage/clients/client_details/ClientDetailsPage";
|
||||||
|
|
||||||
|
const loginPage = new LoginPage();
|
||||||
|
const masthead = new Masthead();
|
||||||
|
const sidebarPage = new SidebarPage();
|
||||||
|
const listingPage = new ListingPage();
|
||||||
|
const advancedTab = new AdvancedSamlTab();
|
||||||
|
|
||||||
|
describe("Clients Saml advanced tab", () => {
|
||||||
|
describe("Fine Grain SAML Endpoint Configuration", () => {
|
||||||
|
const clientName = "advanced-tab";
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
adminClient.createClient({
|
||||||
|
protocol: "saml",
|
||||||
|
clientId: clientName,
|
||||||
|
publicClient: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
adminClient.deleteClient(clientName);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
loginPage.logIn();
|
||||||
|
keycloakBefore();
|
||||||
|
sidebarPage.goToClients();
|
||||||
|
listingPage.searchItem(clientName).goToItemDetails(clientName);
|
||||||
|
new ClientDetailsPage().goToAdvancedTab();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should Terms of service URL", () => {
|
||||||
|
const termsOfServiceUrl = "http://some.url/terms-of-service.html";
|
||||||
|
advancedTab.termsOfServiceUrl(termsOfServiceUrl).saveFineGrain();
|
||||||
|
masthead.checkNotificationMessage("Client successfully updated");
|
||||||
|
|
||||||
|
advancedTab
|
||||||
|
.termsOfServiceUrl("http://not.saveing.this/")
|
||||||
|
.revertFineGrain();
|
||||||
|
advancedTab.checkTermsOfServiceUrl(termsOfServiceUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Invalid terms of service URL", () => {
|
||||||
|
advancedTab.termsOfServiceUrl("not a url").saveFineGrain();
|
||||||
|
|
||||||
|
masthead.checkNotificationMessage(
|
||||||
|
"Client could not be updated: Terms of service URL is not a valid URL"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,27 @@
|
||||||
|
import PageObject from "../../../../components/PageObject";
|
||||||
|
|
||||||
|
export class AdvancedSamlTab extends PageObject {
|
||||||
|
private termsOfServiceUrlId = "attributes.tosUri";
|
||||||
|
|
||||||
|
saveFineGrain() {
|
||||||
|
cy.findAllByTestId("fineGrainSave").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
revertFineGrain() {
|
||||||
|
cy.findByTestId("fineGrainRevert").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
termsOfServiceUrl(termsOfServiceUrl: string) {
|
||||||
|
cy.findAllByTestId(this.termsOfServiceUrlId).clear();
|
||||||
|
cy.findAllByTestId(this.termsOfServiceUrlId).type(termsOfServiceUrl);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkTermsOfServiceUrl(termsOfServiceUrl: string) {
|
||||||
|
cy.findAllByTestId(this.termsOfServiceUrlId).should(
|
||||||
|
"have.value",
|
||||||
|
termsOfServiceUrl
|
||||||
|
);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,5 @@
|
||||||
import { FormGroup } from "@patternfly/react-core";
|
|
||||||
import { useFormContext } from "react-hook-form";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { TextControl } from "ui-shared";
|
||||||
import { HelpItem } from "ui-shared";
|
|
||||||
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
|
|
||||||
import { convertAttributeNameToForm } from "../../util";
|
|
||||||
import { FormFields } from "../ClientDetails";
|
|
||||||
|
|
||||||
type ApplicationUrlsProps = {
|
type ApplicationUrlsProps = {
|
||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
|
@ -13,70 +7,30 @@ type ApplicationUrlsProps = {
|
||||||
|
|
||||||
export const ApplicationUrls = (props: ApplicationUrlsProps) => {
|
export const ApplicationUrls = (props: ApplicationUrlsProps) => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { register } = useFormContext();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormGroup
|
<TextControl
|
||||||
label={t("logoUrl")}
|
name="attributes.logoUri"
|
||||||
fieldId="logoUrl"
|
label={t("clients:logoUrl")}
|
||||||
labelIcon={
|
labelIcon={t("clients-help:logoUrl")}
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:logoUrl")}
|
|
||||||
fieldLabelId="clients:logoUrl"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="logoUrl"
|
|
||||||
type="url"
|
type="url"
|
||||||
data-testid="logoUrl"
|
|
||||||
{...register(
|
|
||||||
convertAttributeNameToForm<FormFields>("attributes.logoUri")
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.policyUri"
|
||||||
label={t("policyUrl")}
|
label={t("clients:policyUrl")}
|
||||||
fieldId="policyUrl"
|
labelIcon={t("clients-help:policyUrl")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:policyUrl")}
|
|
||||||
fieldLabelId="clients:policyUrl"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="policyUrl"
|
|
||||||
data-testid="policyUrl"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register(
|
|
||||||
convertAttributeNameToForm<FormFields>("attributes.policyUri")
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.tosUri"
|
||||||
label={t("termsOfServiceUrl")}
|
label={t("clients:termsOfServiceUrl")}
|
||||||
fieldId="termsOfServiceUrl"
|
labelIcon={t("clients-help:termsOfServiceUrl")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:termsOfServiceUrl")}
|
|
||||||
fieldLabelId="clients:termsOfServiceUrl"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="termsOfServiceUrl"
|
|
||||||
type="url"
|
type="url"
|
||||||
data-testid="termsOfServiceUrl"
|
|
||||||
{...register(
|
|
||||||
convertAttributeNameToForm<FormFields>("attributes.tosUri")
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { ActionGroup, Button, FormGroup } from "@patternfly/react-core";
|
import { ActionGroup, Button } from "@patternfly/react-core";
|
||||||
import { useFormContext } from "react-hook-form";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { FormAccess } from "../../components/form/FormAccess";
|
import { FormAccess } from "../../components/form/FormAccess";
|
||||||
import { HelpItem } from "ui-shared";
|
import { TextControl } from "ui-shared";
|
||||||
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
|
|
||||||
import { ApplicationUrls } from "./ApplicationUrls";
|
import { ApplicationUrls } from "./ApplicationUrls";
|
||||||
|
|
||||||
type FineGrainSamlEndpointConfigProps = {
|
type FineGrainSamlEndpointConfigProps = {
|
||||||
|
@ -17,146 +15,63 @@ export const FineGrainSamlEndpointConfig = ({
|
||||||
reset,
|
reset,
|
||||||
}: FineGrainSamlEndpointConfigProps) => {
|
}: FineGrainSamlEndpointConfigProps) => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { register } = useFormContext();
|
|
||||||
return (
|
return (
|
||||||
<FormAccess role="manage-realm" isHorizontal>
|
<FormAccess role="manage-realm" isHorizontal>
|
||||||
<ApplicationUrls />
|
<ApplicationUrls />
|
||||||
<FormGroup
|
<TextControl
|
||||||
|
name="attributes.saml_assertion_consumer_url_post"
|
||||||
label={t("assertionConsumerServicePostBindingURL")}
|
label={t("assertionConsumerServicePostBindingURL")}
|
||||||
fieldId="assertionConsumerServicePostBindingURL"
|
labelIcon={t("clients-help:assertionConsumerServicePostBindingURL")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:assertionConsumerServicePostBindingURL")}
|
|
||||||
fieldLabelId="clients:assertionConsumerServicePostBindingURL"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="assertionConsumerServicePostBindingURL"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_assertion_consumer_url_post")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_assertion_consumer_url_redirect"
|
||||||
label={t("assertionConsumerServiceRedirectBindingURL")}
|
label={t("assertionConsumerServiceRedirectBindingURL")}
|
||||||
fieldId="assertionConsumerServiceRedirectBindingURL"
|
labelIcon={t("clients-help:assertionConsumerServiceRedirectBindingURL")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t(
|
|
||||||
"clients-help:assertionConsumerServiceRedirectBindingURL"
|
|
||||||
)}
|
|
||||||
fieldLabelId="clients:assertionConsumerServiceRedirectBindingURL"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="assertionConsumerServiceRedirectBindingURL"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_assertion_consumer_url_redirect")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_single_logout_service_url_post"
|
||||||
label={t("logoutServicePostBindingURL")}
|
label={t("logoutServicePostBindingURL")}
|
||||||
fieldId="logoutServicePostBindingURL"
|
labelIcon={t("clients-help:logoutServicePostBindingURL")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:logoutServicePostBindingURL")}
|
|
||||||
fieldLabelId="clients:logoutServicePostBindingURL"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="logoutServicePostBindingURL"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_single_logout_service_url_post")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_single_logout_service_url_redirect"
|
||||||
label={t("logoutServiceRedirectBindingURL")}
|
label={t("logoutServiceRedirectBindingURL")}
|
||||||
fieldId="logoutServiceRedirectBindingURL"
|
labelIcon={t("clients-help:logoutServiceRedirectBindingURL")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:logoutServiceRedirectBindingURL")}
|
|
||||||
fieldLabelId="clients:logoutServiceRedirectBindingURL"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="logoutServiceRedirectBindingURL"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_single_logout_service_url_redirect")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_single_logout_service_url_soap"
|
||||||
label={t("logoutServiceSoapBindingUrl")}
|
label={t("logoutServiceSoapBindingUrl")}
|
||||||
fieldId="logoutServiceSoapBindingUrl"
|
labelIcon={t("clients-help:logoutServiceSoapBindingUrl")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText="clients-help:logoutServiceSoapBindingUrl"
|
|
||||||
fieldLabelId="clients:logoutServiceSoapBindingUrl"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="logoutServiceSoapBindingUrl"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_single_logout_service_url_soap")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_single_logout_service_url_artifact"
|
||||||
label={t("logoutServiceArtifactBindingUrl")}
|
label={t("logoutServiceArtifactBindingUrl")}
|
||||||
fieldId="logoutServiceArtifactBindingUrl"
|
labelIcon={t("clients-help:logoutServiceArtifactBindingUrl")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:logoutServiceArtifactBindingUrl")}
|
|
||||||
fieldLabelId="clients:logoutServiceArtifactBindingUrl"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="logoutServiceArtifactBindingUrl"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_single_logout_service_url_artifact")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_artifact_binding_url"
|
||||||
label={t("artifactBindingUrl")}
|
label={t("artifactBindingUrl")}
|
||||||
fieldId="artifactBindingUrl"
|
labelIcon={t("clients-help:artifactBindingUrl")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:artifactBindingUrl")}
|
|
||||||
fieldLabelId="clients:artifactBindingUrl"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="artifactBindingUrl"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_artifact_binding_url")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
<TextControl
|
||||||
<FormGroup
|
name="attributes.saml_artifact_resolution_service_url"
|
||||||
label={t("artifactResolutionService")}
|
label={t("artifactResolutionService")}
|
||||||
fieldId="artifactResolutionService"
|
labelIcon={t("clients-help:artifactResolutionService")}
|
||||||
labelIcon={
|
|
||||||
<HelpItem
|
|
||||||
helpText={t("clients-help:artifactResolutionService")}
|
|
||||||
fieldLabelId="clients:artifactResolutionService"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<KeycloakTextInput
|
|
||||||
id="artifactResolutionService"
|
|
||||||
type="url"
|
type="url"
|
||||||
{...register("attributes.saml_artifact_resolution_service_url")}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
|
||||||
|
|
||||||
<ActionGroup>
|
<ActionGroup>
|
||||||
<Button variant="tertiary" onClick={save}>
|
<Button variant="tertiary" onClick={save} data-testid="fineGrainSave">
|
||||||
{t("common:save")}
|
{t("common:save")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="link" onClick={reset}>
|
<Button variant="link" onClick={reset} data-testid="fineGrainRevert">
|
||||||
{t("common:revert")}
|
{t("common:revert")}
|
||||||
</Button>
|
</Button>
|
||||||
</ActionGroup>
|
</ActionGroup>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ValidatedOptions } from "@patternfly/react-core";
|
import { TextInputProps, ValidatedOptions } from "@patternfly/react-core";
|
||||||
import {
|
import {
|
||||||
FieldPath,
|
FieldPath,
|
||||||
FieldValues,
|
FieldValues,
|
||||||
|
@ -13,7 +13,8 @@ import { FormLabel } from "./FormLabel";
|
||||||
export type TextControlProps<
|
export type TextControlProps<
|
||||||
T extends FieldValues,
|
T extends FieldValues,
|
||||||
P extends FieldPath<T> = FieldPath<T>
|
P extends FieldPath<T> = FieldPath<T>
|
||||||
> = UseControllerProps<T, P> & {
|
> = UseControllerProps<T, P> &
|
||||||
|
TextInputProps & {
|
||||||
label: string;
|
label: string;
|
||||||
labelIcon?: string;
|
labelIcon?: string;
|
||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
|
@ -49,6 +50,7 @@ export const TextControl = <
|
||||||
fieldState.error ? ValidatedOptions.error : ValidatedOptions.default
|
fieldState.error ? ValidatedOptions.error : ValidatedOptions.default
|
||||||
}
|
}
|
||||||
isDisabled={props.isDisabled}
|
isDisabled={props.isDisabled}
|
||||||
|
{...props}
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
Loading…
Reference in a new issue