Skip to content

Commit

Permalink
Fix retrieveSingleContractAgreement
Browse files Browse the repository at this point in the history
  • Loading branch information
ununhexium committed Oct 17, 2024
1 parent 16ececb commit f1b480c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/api/sovity-edc-api-wrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@
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
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();
}
Expand Down
3 changes: 0 additions & 3 deletions tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit f1b480c

Please sign in to comment.