From 4b3db912b4c789dddca078da683563c7e83e9f76 Mon Sep 17 00:00:00 2001 From: Benjamin Monnot Date: Fri, 9 Aug 2024 16:11:25 +0000 Subject: [PATCH] PB-34290 WP3.4 - Edit standalone TOTP resource in v5 format --- .../Resource/EditStandaloneTotp/EditStandaloneTotp.js | 4 ++-- .../Resource/HandleTotpWorkflow/HandleTotpWorkflow.js | 2 ++ .../Resource/HandleTotpWorkflow/HandleTotpWorkflow.test.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/react-extension/components/Resource/EditStandaloneTotp/EditStandaloneTotp.js b/src/react-extension/components/Resource/EditStandaloneTotp/EditStandaloneTotp.js index d73dd6fb7..7c98bc8ac 100644 --- a/src/react-extension/components/Resource/EditStandaloneTotp/EditStandaloneTotp.js +++ b/src/react-extension/components/Resource/EditStandaloneTotp/EditStandaloneTotp.js @@ -43,8 +43,8 @@ class EditStandaloneTotp extends Component { */ get defaultState() { const resource = this.props.resource || {}; - const name = resource.name || ""; - const uri = resource.uri || ""; + const name = resource.metadata.name || ""; + const uri = resource.metadata.uris?.[0] || ""; return { nameOriginal: name, diff --git a/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.js b/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.js index 5dd94c850..0ac096f15 100644 --- a/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.js +++ b/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.js @@ -269,6 +269,8 @@ export class HandleTotpWorkflow extends React.Component { resourceDto.resource_type_id = this.props.context.resourceTypesSettings.findResourceTypeIdBySlug( this.props.context.resourceTypesSettings.DEFAULT_RESOURCE_TYPES_SLUGS.TOTP ); + // @TODO E2EE resource_type_id duplicate for resource + resourceDto.metadata.resource_type_id = resourceDto.resource_type_id; return this.props.context.port.request("passbolt.resources.update", resourceDto, secretDto); } diff --git a/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.test.js b/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.test.js index ccafb3446..ecffec381 100644 --- a/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.test.js +++ b/src/react-extension/components/Resource/HandleTotpWorkflow/HandleTotpWorkflow.test.js @@ -207,6 +207,7 @@ describe("HandleReviewAccountRecoveryRequestWorkflow", () => { resource_type_id: props.context.resourceTypesSettings.findResourceTypeIdBySlug("totp"), ...totp.toResourceDto() }; + resourceDto.metadata.resource_type_id = props.context.resourceTypesSettings.findResourceTypeIdBySlug("totp"); expect(props.context.port.request).toHaveBeenCalledWith("passbolt.resources.update", resourceDto, totp.toSecretDto()); expect(props.actionFeedbackContext.displaySuccess).toHaveBeenCalledWith("The TOTP has been updated successfully"); @@ -230,6 +231,7 @@ describe("HandleReviewAccountRecoveryRequestWorkflow", () => { resource_type_id: props.context.resourceTypesSettings.findResourceTypeIdBySlug("totp"), ...totp.toResourceDto() }; + resourceDto.metadata.resource_type_id = props.context.resourceTypesSettings.findResourceTypeIdBySlug("totp"); expect(props.context.port.request).toHaveBeenCalledWith("passbolt.resources.update", resourceDto, totp.toSecretDto()); expect(props.dialogContext.open).toHaveBeenCalledWith(NotifyError, {error});