From f1b480c823bb834e89fd3241137f59dd9e9fa3b7 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Thu, 17 Oct 2024 10:49:17 +0200 Subject: [PATCH] Fix retrieveSingleContractAgreement --- docs/api/sovity-edc-api-wrapper.yaml | 4 ++++ .../wrapper/api/ui/model/ContractNegotiationRequest.java | 3 +++ .../pages/contract_negotiations/ContractOfferMapper.java | 9 +++++---- .../test/java/de/sovity/edc/e2e/UiApiWrapperTest.java | 3 --- .../connector/remotes/api_wrapper/E2eTestScenario.java | 1 + .../remotes/api_wrapper/E2eTestScenarioConfig.java | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/api/sovity-edc-api-wrapper.yaml b/docs/api/sovity-edc-api-wrapper.yaml index 4e99d328f..22b34dfb4 100644 --- a/docs/api/sovity-edc-api-wrapper.yaml +++ b/docs/api/sovity-edc-api-wrapper.yaml @@ -1887,9 +1887,13 @@ components: - assetId - contractOfferId - counterPartyAddress + - counterPartyId - policyJsonLd type: object properties: + counterPartyId: + type: string + description: Counter Party Id counterPartyAddress: type: string description: Counter Party Address diff --git a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractNegotiationRequest.java b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractNegotiationRequest.java index e800c63f5..247a05307 100644 --- a/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractNegotiationRequest.java +++ b/extensions/wrapper/wrapper-api/src/main/java/de/sovity/edc/ext/wrapper/api/ui/model/ContractNegotiationRequest.java @@ -30,6 +30,9 @@ @Schema(description = "Data for initiating a Contract Negotiation") public class ContractNegotiationRequest { + @Schema(description = "Counter Party Id", requiredMode = Schema.RequiredMode.REQUIRED) + private String counterPartyId; + @Schema(description = "Counter Party Address", requiredMode = Schema.RequiredMode.REQUIRED) private String counterPartyAddress; diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_negotiations/ContractOfferMapper.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_negotiations/ContractOfferMapper.java index ce31ec397..7435a9235 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_negotiations/ContractOfferMapper.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/contract_negotiations/ContractOfferMapper.java @@ -18,8 +18,8 @@ import de.sovity.edc.ext.wrapper.api.common.mappers.PolicyMapper; import de.sovity.edc.ext.wrapper.api.ui.model.ContractNegotiationRequest; import lombok.RequiredArgsConstructor; +import lombok.val; import org.eclipse.edc.connector.controlplane.contract.spi.types.offer.ContractOffer; -import org.eclipse.edc.policy.model.Policy; @RequiredArgsConstructor @@ -27,18 +27,19 @@ public class ContractOfferMapper { private final PolicyMapper policyMapper; public ContractOffer buildContractOffer(ContractNegotiationRequest contractRequest) { - var policy = policyMapper.buildPolicy(contractRequest.getPolicyJsonLd()); + val policy = policyMapper.buildPolicy(contractRequest.getPolicyJsonLd()); // Required or Eclipse EDC Validation in DSP panics // despite assetId being a field on the ContractOffer // despite the catalog not putting it out while policies aren't asset specific - policy = policy.toBuilder() + val patchedPolicy = policy.toBuilder() .target(contractRequest.getAssetId()) + .assigner(contractRequest.getCounterPartyId()) .build(); return ContractOffer.Builder.newInstance() .id(contractRequest.getContractOfferId()) - .policy(policy) + .policy(patchedPolicy) .assetId(contractRequest.getAssetId()) .build(); } diff --git a/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java b/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java index e30e5baf1..e0de233aa 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java @@ -619,10 +619,7 @@ void retrieveSingleContractAgreement( // arrange val assetId = scenario.createAsset(); - val assetPage = providerClient.uiApi().getAssetPage(); - scenario.createContractDefinition(assetId); - // TODO: why does it want an x-api-key and not a token? val negotiation = scenario.negotiateAssetAndAwait(assetId); // act diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenario.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenario.java index dc3d03297..faeab1bac 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenario.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenario.java @@ -175,6 +175,7 @@ public UiContractNegotiation negotiateAssetAndAwait(String assetId) { val firstContractOffer = offersContainingContract.get(0).getContractOffers().get(0); val dataOffer = offersContainingContract.get(0); var negotiationRequest = ContractNegotiationRequest.builder() + .counterPartyId(dataOffer.getParticipantId()) .counterPartyAddress(dataOffer.getEndpoint()) .assetId(dataOffer.getAsset().getAssetId()) .contractOfferId(firstContractOffer.getContractOfferId()) diff --git a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenarioConfig.java b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenarioConfig.java index 17a94d741..24b2c4191 100644 --- a/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenarioConfig.java +++ b/utils/test-utils/src/main/java/de/sovity/edc/extension/e2e/connector/remotes/api_wrapper/E2eTestScenarioConfig.java @@ -43,7 +43,7 @@ public class E2eTestScenarioConfig { public static E2eTestScenarioConfig forProviderConfig(Config providerConfig) { return builder() .providerParticipantId(ConfigUtils.getParticipantId(providerConfig)) - .providerProtocolApiUrl(ConfigUtils.getManagementApiUrl(providerConfig)) + .providerProtocolApiUrl(ConfigUtils.getProtocolApiUrl(providerConfig)) .build(); } }