diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/AddMapperPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/AddMapperPage.ts index d781912b66..7a01dd57bc 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/AddMapperPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/AddMapperPage.ts @@ -1,3 +1,4 @@ +import Select from "../../../../forms/Select"; import LegacyKeyValueInput from "../LegacyKeyValueInput"; export default class AddMapperPage { @@ -7,7 +8,7 @@ export default class AddMapperPage { #idpMapperSelect = "idp-mapper-select"; #addMapperButton = "#add-mapper-button"; - #mapperNameInput = "#kc-name"; + #mapperNameInput = "name"; #attribute = "config.user🍺attribute"; #attributeName = "attribute.name"; #attributeFriendlyName = "attribute.friendly.name"; @@ -64,15 +65,15 @@ export default class AddMapperPage { return this; } + typeName(name: string) { + cy.findByTestId(this.#mapperNameInput).clear(); + cy.findByTestId(this.#mapperNameInput).type(name); + } + fillSocialMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("legacy").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Legacy"); cy.get(this.#idpMapperSelectToggle).click(); cy.findByTestId(this.#idpMapperSelect) @@ -101,13 +102,8 @@ export default class AddMapperPage { } addAdvancedAttrToRoleMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -132,13 +128,8 @@ export default class AddMapperPage { } addUsernameTemplateImporterMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -157,13 +148,8 @@ export default class AddMapperPage { } addHardcodedUserSessionAttrMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -185,13 +171,9 @@ export default class AddMapperPage { } addSAMLAttrImporterMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); + this.typeName(name); - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -215,14 +197,9 @@ export default class AddMapperPage { } addOIDCAttrImporterMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); cy.findByTestId(this.#idpMapperSelect) @@ -238,13 +215,8 @@ export default class AddMapperPage { } addHardcodedRoleMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -257,13 +229,8 @@ export default class AddMapperPage { } addHardcodedAttrMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -283,13 +250,9 @@ export default class AddMapperPage { } addSAMLAttributeToRoleMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); + this.typeName(name); - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); @@ -305,9 +268,7 @@ export default class AddMapperPage { } editUsernameTemplateImporterMapper() { - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("legacy").click(); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Legacy"); cy.findByTestId(this.#template).type("_edited"); @@ -319,9 +280,7 @@ export default class AddMapperPage { } editSocialMapper() { - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.findByTestId(this.#socialProfileJSONfieldPath).clear(); @@ -339,9 +298,7 @@ export default class AddMapperPage { } editSAMLorOIDCMapper() { - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("legacy").click(); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#attributesKeyInput).clear(); cy.get(this.#attributesKeyInput).type("key_edited"); @@ -357,14 +314,9 @@ export default class AddMapperPage { } addOIDCAttributeImporterMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); - - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + this.typeName(name); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); cy.findByTestId(this.#idpMapperSelect) @@ -383,13 +335,9 @@ export default class AddMapperPage { } addOIDCClaimToRoleMapper(name: string) { - cy.get(this.#mapperNameInput).clear(); + this.typeName(name); - cy.get(this.#mapperNameInput).clear().type(name); - - cy.get(this.#syncmodeSelectToggle).click(); - - cy.findByTestId("inherit").click(); + Select.selectItem(cy.get(this.#syncmodeSelectToggle), "Inherit"); cy.get(this.#idpMapperSelectToggle).click(); diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/social/ProviderSAMLSettings.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/social/ProviderSAMLSettings.ts index 2efc29fe38..e8a9e3f29e 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/social/ProviderSAMLSettings.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/identity_providers/social/ProviderSAMLSettings.ts @@ -1,3 +1,4 @@ +import Select from "../../../../../forms/Select"; import PageObject from "../../../components/PageObject"; import Masthead from "../../../Masthead"; @@ -6,44 +7,32 @@ const masthead = new Masthead(); export default class ProviderSAMLSettings extends PageObject { #samlSwitch = "Saml-switch"; #modalConfirm = "#modal-confirm"; - #serviceProviderEntityID = "serviceProviderEntityId"; + #serviceProviderEntityID = "config.entityId"; #identityProviderEntityId = "identityProviderEntityId"; - #ssoServiceUrl = "sso-service-url"; - #singleLogoutServiceUrl = "single-logout-service-url"; - #nameIdPolicyFormat = "#kc-nameIdPolicyFormat"; - #principalType = "#kc-principalType"; - #principalAttribute = "principalAttribute"; - #principalSubjectNameId = "subjectNameId-option"; - #principalAttributeName = "attributeName-option"; - #principalFriendlyAttribute = "attributeFriendlyName-option"; + #ssoServiceUrl = "config.singleSignOnServiceUrl"; + #singleLogoutServiceUrl = "config.singleLogoutServiceUrl"; + #nameIdPolicyFormat = "#nameIDPolicyFormat"; + #principalType = "#principalType"; - #transientPolicy = "transient-option"; - #emailPolicy = "email-option"; - #kerberosPolicy = "kerberos-option"; - #x509Policy = "x509-option"; - #windowsDomainQNPolicy = "windowsDomainQN-option"; - #unspecifiedPolicy = "unspecified-option"; - #persistentPolicy = "persistent-option"; + #allowCreate = "config.allowCreate"; + #httpPostBindingResponse = "config.postBindingResponse"; + #httpPostBindingAuthnRequest = "config.postBindingAuthnRequest"; + #httpPostBindingLogout = "config.postBindingLogout"; + #wantAuthnRequestsSigned = "config.wantAuthnRequestsSigned"; - #allowCreate = "#allowCreate"; - #httpPostBindingResponse = "#httpPostBindingResponse"; - #httpPostBindingAuthnRequest = "#httpPostBindingAuthnRequest"; - #httpPostBindingLogout = "#httpPostBindingLogout"; - #wantAuthnRequestsSigned = "#wantAuthnRequestsSigned"; + #signatureAlgorithm = "#signatureAlgorithm"; + #samlSignatureKeyName = "#xmlSigKeyInfoKeyNameTransformer"; - #signatureAlgorithm = "#kc-signatureAlgorithm"; - #samlSignatureKeyName = "#kc-samlSignatureKeyName"; - - #wantAssertionsSigned = "#wantAssertionsSigned"; - #wantAssertionsEncrypted = "#wantAssertionsEncrypted"; - #forceAuthentication = "#forceAuthentication"; - #validateSignature = "#validateSignature"; - #validatingX509Certs = "validatingX509Certs"; - #signServiceProviderMetadata = "#signServiceProviderMetadata"; - #passSubject = "#passSubject"; - #allowedClockSkew = "allowedClockSkew"; - #attributeConsumingServiceIndex = "attributeConsumingServiceIndex"; - #attributeConsumingServiceName = "attributeConsumingServiceName"; + #wantAssertionsSigned = "config.wantAssertionsSigned"; + #wantAssertionsEncrypted = "config.wantAssertionsEncrypted"; + #forceAuthentication = "config.forceAuthn"; + #validateSignature = "config.validateSignature"; + #validatingX509Certs = "config.signingCertificate"; + #signServiceProviderMetadata = "config.signSpMetadata"; + #passSubject = "config.loginHint"; + #allowedClockSkew = "#config\\.allowedClockSkew"; + #attributeConsumingServiceIndex = "#config\\.attributeConsumingServiceIndex"; + #attributeConsumingServiceName = "config.attributeConsumingServiceName"; #comparison = "#comparison"; #saveBtn = "idp-details-save"; @@ -95,26 +84,33 @@ export default class ProviderSAMLSettings extends PageObject { } public typeX509Certs(cert: string) { - cy.findByTestId(this.#validatingX509Certs).clear().type(cert); + cy.findByTestId(this.#validatingX509Certs).clear(); + cy.findByTestId(this.#validatingX509Certs).type(cert); return this; } - public selectNamePolicyIdFormat() { - cy.get(this.#nameIdPolicyFormat).scrollIntoView().click(); + public selectNamePolicyIdFormat(option: string) { + cy.get(this.#nameIdPolicyFormat).scrollIntoView(); + Select.selectItem(cy.get(this.#nameIdPolicyFormat), option); + Select.assertSelectedItem(cy.get(this.#nameIdPolicyFormat), option); + return this; } - public selectPrincipalFormat() { - cy.get(this.#principalType).scrollIntoView().click(); + public selectPrincipalFormat(option: string) { + cy.get(this.#principalType).scrollIntoView(); + Select.selectItem(cy.get(this.#principalType), option); + Select.assertSelectedItem(cy.get(this.#principalType), option); + return this; } public selectSignatureAlgorithm(algorithm: string) { - cy.get(this.#signatureAlgorithm).scrollIntoView().click(); - cy.findByText(algorithm).click(); + cy.get(this.#signatureAlgorithm).scrollIntoView(); + Select.selectItem(cy.get(this.#signatureAlgorithm), algorithm); } public selectSAMLSignature(key: string) { - cy.get(this.#samlSignatureKeyName).scrollIntoView().click(); - cy.findByText(key).click(); + cy.get(this.#samlSignatureKeyName).scrollIntoView(); + Select.selectItem(cy.get(this.#samlSignatureKeyName), key); } public selectComparison(comparison: string) { @@ -143,25 +139,18 @@ export default class ProviderSAMLSettings extends PageObject { } public assertNameIdPolicyFormat() { - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#transientPolicy).click(); - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#emailPolicy).click(); - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#kerberosPolicy).click(); - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#x509Policy).click(); - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#windowsDomainQNPolicy).click(); - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#unspecifiedPolicy).click(); - this.selectNamePolicyIdFormat(); - cy.findByTestId(this.#persistentPolicy).click(); + this.selectNamePolicyIdFormat("Transient"); + this.selectNamePolicyIdFormat("Email"); + this.selectNamePolicyIdFormat("Kerberos"); + this.selectNamePolicyIdFormat("X.509 Subject Name"); + this.selectNamePolicyIdFormat("Windows Domain Qualified Name"); + this.selectNamePolicyIdFormat("Unspecified"); + this.selectNamePolicyIdFormat("Persistent"); return this; } public assertSignatureAlgorithm() { - cy.get(this.#wantAuthnRequestsSigned).parent().click(); + cy.findByTestId(this.#wantAuthnRequestsSigned).parent().click(); cy.get(this.#signatureAlgorithm).should("not.exist"); cy.get(this.#samlSignatureKeyName).should("not.exist"); this.clickRevertBtn(); @@ -183,38 +172,32 @@ export default class ProviderSAMLSettings extends PageObject { } public assertPrincipalType() { - this.selectPrincipalFormat(); - cy.findByTestId(this.#principalAttributeName).click(); - cy.findByTestId(this.#principalAttribute).should("exist").scrollIntoView(); - this.selectPrincipalFormat(); - cy.findByTestId(this.#principalFriendlyAttribute).click(); - cy.findByTestId(this.#principalAttribute).should("exist"); - this.selectPrincipalFormat(); - cy.findByTestId(this.#principalSubjectNameId).click(); - cy.findByTestId(this.#principalAttribute).should("not.exist"); + this.selectPrincipalFormat("Subject NameID"); + this.selectPrincipalFormat("Attribute [Name]"); + this.selectPrincipalFormat("Attribute [Friendly Name]"); return this; } public assertSAMLSwitches() { - cy.get(this.#allowCreate).parent().click(); - cy.get(this.#httpPostBindingResponse).parent().click(); - cy.get(this.#httpPostBindingLogout).parent().click(); - cy.get(this.#httpPostBindingAuthnRequest).parent().click(); + cy.findByTestId(this.#allowCreate).parent().click(); + cy.findByTestId(this.#httpPostBindingResponse).parent().click(); + cy.findByTestId(this.#httpPostBindingLogout).parent().click(); + cy.findByTestId(this.#httpPostBindingAuthnRequest).parent().click(); - cy.get(this.#wantAssertionsSigned).parent().click(); - cy.get(this.#wantAssertionsEncrypted).parent().click(); - cy.get(this.#forceAuthentication).parent().click(); + cy.findByTestId(this.#wantAssertionsSigned).parent().click(); + cy.findByTestId(this.#wantAssertionsEncrypted).parent().click(); + cy.findByTestId(this.#forceAuthentication).parent().click(); - cy.get(this.#signServiceProviderMetadata).parent().click(); - cy.get(this.#passSubject).parent().click(); + cy.findByTestId(this.#signServiceProviderMetadata).parent().click(); + cy.findByTestId(this.#passSubject).parent().click(); return this; } public assertValidateSignatures() { - cy.get(this.#validateSignature).parent().click(); + cy.findByTestId(this.#validateSignature).parent().click(); cy.findByTestId(this.#validatingX509Certs).should("not.exist"); - cy.get(this.#validateSignature).parent().click(); + cy.findByTestId(this.#validateSignature).parent().click(); this.typeX509Certs("X509 Certificate"); this.clickRevertBtn(); cy.findByTestId(this.#validatingX509Certs); @@ -223,13 +206,13 @@ export default class ProviderSAMLSettings extends PageObject { } public assertTextFields() { - cy.findByTestId(this.#allowedClockSkew) + cy.get(this.#allowedClockSkew) .find("input") .should("have.value", 0) .clear() .type("111"); - cy.findByTestId(this.#attributeConsumingServiceIndex) + cy.get(this.#attributeConsumingServiceIndex) .find("input") .should("have.value", 0) .clear() diff --git a/js/apps/admin-ui/src/identity-providers/add/AddMapper.tsx b/js/apps/admin-ui/src/identity-providers/add/AddMapper.tsx index 07e029821d..b77360d914 100644 --- a/js/apps/admin-ui/src/identity-providers/add/AddMapper.tsx +++ b/js/apps/admin-ui/src/identity-providers/add/AddMapper.tsx @@ -7,15 +7,14 @@ import { Button, ButtonVariant, DropdownItem, - FormGroup, PageSection, - ValidatedOptions, } from "@patternfly/react-core"; import { useState } from "react"; import { FormProvider, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { Link, useNavigate } from "react-router-dom"; +import { TextControl } from "ui-shared"; import { adminClient } from "../../admin-client"; import { useAlerts } from "../../components/alert/Alerts"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; @@ -23,7 +22,6 @@ import { DynamicComponents } from "../../components/dynamic/DynamicComponents"; import { FormAccess } from "../../components/form/FormAccess"; import type { AttributeForm } from "../../components/key-value-form/AttributeForm"; import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner"; -import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; import { ViewHeader } from "../../components/view-header/ViewHeader"; import { useRealm } from "../../context/realm-context/RealmContext"; import { convertFormValuesToObject, convertToFormValues } from "../../util"; @@ -50,11 +48,7 @@ export default function AddMapper() { const form = useForm({ shouldUnregister: true, }); - const { - handleSubmit, - register, - formState: { errors }, - } = form; + const { handleSubmit } = form; const { addAlert, addError } = useAlerts(); const navigate = useNavigate(); const localeSort = useLocaleSort(); @@ -202,41 +196,31 @@ export default function AddMapper() { onSubmit={handleSubmit(save)} className="pf-u-mt-lg" > - {id && ( - - + {id && ( + - - )} - {currentMapper.properties && ( - <> - - - - - - )} + )} + {currentMapper.properties && ( + <> + + + + )} +