diff --git a/cypress/integration/clients_saml_test.spec.ts b/cypress/integration/clients_saml_test.spec.ts index dc13fe0019..3a3040f163 100644 --- a/cypress/integration/clients_saml_test.spec.ts +++ b/cypress/integration/clients_saml_test.spec.ts @@ -45,11 +45,7 @@ describe("Clients SAML tests", () => { }); it("should save force name id format", () => { - const load = "auth/admin/realms/master/client-scopes"; - cy.intercept(load).as("load"); - cy.get(".pf-c-jump-links__list").contains("SAML capabilities").click(); - cy.wait("@load"); cy.findByTestId("forceNameIdFormat").click({ force: true, @@ -142,6 +138,9 @@ describe("Clients SAML tests", () => { it("Should update the resource server settings", () => { listingPage.searchItem(clientName).goToItemDetails(clientName); authenticationTab.goToTab(); + authenticationTab.setPolicy("DISABLED").saveSettings(); + + masthead.checkNotificationMessage("Resource successfully updated"); }); it("Should create a resource", () => { diff --git a/cypress/support/pages/admin_console/manage/clients/Authentication.ts b/cypress/support/pages/admin_console/manage/clients/Authentication.ts index 498759878a..856124f48d 100644 --- a/cypress/support/pages/admin_console/manage/clients/Authentication.ts +++ b/cypress/support/pages/admin_console/manage/clients/Authentication.ts @@ -36,11 +36,21 @@ export default class AuthenticationTab { return this; } + setPolicy(policyName: string) { + cy.findByTestId(policyName).click(); + return this; + } + save() { cy.findByTestId("save").click(); return this; } + saveSettings() { + cy.findByTestId("authenticationSettingsSave").click(); + return this; + } + pressCancel() { cy.findAllByTestId("cancel").click(); return this; diff --git a/src/clients/ClientDetails.tsx b/src/clients/ClientDetails.tsx index fbefd523da..d456e639a5 100644 --- a/src/clients/ClientDetails.tsx +++ b/src/clients/ClientDetails.tsx @@ -361,7 +361,7 @@ export default function ClientDetails() { /> - + setAuthorizationSubTab(key as number)} + mountOnEnter + unmountOnExit > { const [resource, setResource] = useState(); const [importDialog, toggleImportDialog] = useToggle(); - const { control, reset } = useForm({ - shouldUnregister: false, - }); + const { control, reset, handleSubmit } = + useForm({ + shouldUnregister: false, + }); const adminClient = useAdminClient(); + const { addAlert, addError } = useAlerts(); useFetch( () => adminClient.clients.getResourceServer({ id: clientId }), @@ -46,8 +50,26 @@ export const AuthorizationSettings = ({ clientId }: { clientId: string }) => { [] ); - const importResource = () => { - //different PR + const importResource = async (value: ResourceServerRepresentation) => { + try { + await adminClient.clients.importResource({ id: clientId }, value); + addAlert(t("importResourceSuccess"), AlertVariant.success); + reset({ ...value }); + } catch (error) { + addError("clients:importResourceError", error); + } + }; + + const save = async (resource: ResourceServerRepresentation) => { + try { + await adminClient.clients.updateResourceServer( + { id: clientId }, + resource + ); + addAlert(t("updateResourceSuccess"), AlertVariant.success); + } catch (error) { + addError("clients:resourceSaveError", error); + } }; if (!resource) { @@ -174,10 +196,8 @@ export const AuthorizationSettings = ({ clientId }: { clientId: string }) => { /> { - // another PR - }} + name="authenticationSettings" + save={() => handleSubmit(save)()} reset={() => reset(resource)} /> diff --git a/src/clients/messages.ts b/src/clients/messages.ts index c80f7079cb..d06ec18a2a 100644 --- a/src/clients/messages.ts +++ b/src/clients/messages.ts @@ -64,6 +64,8 @@ export default { importResources: "The following settings and data will be imported:", importWarning: "The data and settings imported above may overwrite the data and settings that already exist.", + importResourceSuccess: "The resource was successfully imported", + importResourceError: "Could not import the resource due to {{error}}", createResource: "Create resource", createResourceBasedPermission: "Create resource-based permission", displayName: "Display name",