diff --git a/edc-extensions/bdrs-client/src/main/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapper.java b/edc-extensions/bdrs-client/src/main/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapper.java index fbfa0b434..813b83df3 100644 --- a/edc-extensions/bdrs-client/src/main/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapper.java +++ b/edc-extensions/bdrs-client/src/main/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapper.java @@ -20,9 +20,12 @@ package org.eclipse.tractusx.edc.identity.mapper; import org.eclipse.edc.spi.iam.AudienceResolver; +import org.eclipse.edc.spi.result.Result; import org.eclipse.edc.spi.types.domain.message.RemoteMessage; import org.eclipse.tractusx.edc.spi.identity.mapper.BdrsClient; +import java.util.Optional; + /** * An incoming {@link RemoteMessage} is mapped to a DID by calling {@link BdrsClient#resolve(String)} with the {@link RemoteMessage#getCounterPartyId()} */ @@ -35,8 +38,8 @@ class BdrsClientAudienceMapper implements AudienceResolver { } @Override - public String resolve(RemoteMessage remoteMessage) { - return client.resolve(remoteMessage.getCounterPartyId()); + public Result resolve(RemoteMessage remoteMessage) { + return Result.from(Optional.ofNullable(client.resolve(remoteMessage.getCounterPartyId()))); } } diff --git a/edc-extensions/bdrs-client/src/test/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapperTest.java b/edc-extensions/bdrs-client/src/test/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapperTest.java index 4f6cc2649..42c524f98 100644 --- a/edc-extensions/bdrs-client/src/test/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapperTest.java +++ b/edc-extensions/bdrs-client/src/test/java/org/eclipse/tractusx/edc/identity/mapper/BdrsClientAudienceMapperTest.java @@ -23,7 +23,7 @@ import org.eclipse.tractusx.edc.spi.identity.mapper.BdrsClient; import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -40,7 +40,7 @@ void resolve() { var did = clientAudienceMapper.resolve(new TestMessage("bpn1")); - assertThat(did).isEqualTo("did:web:did1"); + assertThat(did).isSucceeded().isEqualTo("did:web:did1"); } @@ -51,7 +51,7 @@ void resolve_notFound() { var did = clientAudienceMapper.resolve(new TestMessage("bpn1")); - assertThat(did).isNull(); + assertThat(did).isFailed(); } diff --git a/edc-extensions/edr/edr-callback/src/main/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallback.java b/edc-extensions/edr/edr-callback/src/main/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallback.java index b9e2afda0..b401b2887 100644 --- a/edc-extensions/edr/edr-callback/src/main/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallback.java +++ b/edc-extensions/edr/edr-callback/src/main/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallback.java @@ -58,7 +58,6 @@ private Result initiateTransfer(ContractNegotiationFinalized negotiationFi var transferRequest = TransferRequest.Builder.newInstance() .id(UUID.randomUUID().toString()) - .assetId(negotiationFinalized.getContractAgreement().getAssetId()) .contractId(negotiationFinalized.getContractAgreement().getId()) .counterPartyAddress(negotiationFinalized.getCounterPartyAddress()) .protocol(negotiationFinalized.getProtocol()) diff --git a/edc-extensions/edr/edr-callback/src/test/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallbackTest.java b/edc-extensions/edr/edr-callback/src/test/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallbackTest.java index 9247bda85..88f6983f7 100644 --- a/edc-extensions/edr/edr-callback/src/test/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallbackTest.java +++ b/edc-extensions/edr/edr-callback/src/test/java/org/eclipse/tractusx/edc/callback/ContractNegotiationCallbackTest.java @@ -105,7 +105,6 @@ void invoke_shouldStartTransferProcess() { assertThat(transferRequest).satisfies(tp -> { assertThat(tp.getContractId()).isEqualTo(event.getContractAgreement().getId()); - assertThat(tp.getAssetId()).isEqualTo(event.getContractAgreement().getAssetId()); assertThat(tp.getCounterPartyAddress()).isEqualTo(event.getCounterPartyAddress()); assertThat(tp.getProtocol()).isEqualTo(event.getProtocol()); assertThat(tp.getDataDestination()).usingRecursiveComparison().isEqualTo(DATA_DESTINATION); diff --git a/edc-extensions/tokenrefresh-handler/src/main/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImpl.java b/edc-extensions/tokenrefresh-handler/src/main/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImpl.java index 7ede6ca8e..ee0eef952 100644 --- a/edc-extensions/tokenrefresh-handler/src/main/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImpl.java +++ b/edc-extensions/tokenrefresh-handler/src/main/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImpl.java @@ -178,6 +178,7 @@ private Result createTokenRefreshRequest(String refreshEndpoint, String return success(new Request.Builder() .addHeader("Authorization", bearerToken) + .addHeader("Content-Type", "application/x-www-form-urlencoded") .url(url) .post(RequestBody.create(new byte[0])) .build()); diff --git a/edc-extensions/tokenrefresh-handler/src/test/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImplTest.java b/edc-extensions/tokenrefresh-handler/src/test/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImplTest.java index e210ecbad..4676ed378 100644 --- a/edc-extensions/tokenrefresh-handler/src/test/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImplTest.java +++ b/edc-extensions/tokenrefresh-handler/src/test/java/org/eclipse/tractusx/edc/common/tokenrefresh/TokenRefreshHandlerImplTest.java @@ -64,6 +64,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.mock; @@ -116,6 +117,10 @@ void refresh_validateCorrectRequest() throws IOException { Assertions.assertThat(tr.getProperties()).containsEntry(EDR_PROPERTY_REFRESH_TOKEN, "new-refresh-token"); Assertions.assertThat(tr.getProperties()).containsEntry(EDR_PROPERTY_REFRESH_ENDPOINT, REFRESH_ENDPOINT); }); + verify(mockedHttpClient).execute(argThat(r -> { + var hdr = r.header("Content-Type"); + return hdr != null && hdr.equalsIgnoreCase("application/x-www-form-urlencoded"); + })); } @Test @@ -179,7 +184,7 @@ void refresh_ioException() throws IOException { assertThat(tokenRefreshHandler.refreshToken("token-id")).isFailed() .detail().isEqualTo("Error executing token refresh request: java.io.IOException: test exception"); } - + @Test void refresh_tokenGenerationFailed() { when(edrCache.get(anyString())).thenReturn(StoreResult.success(createEdr().build())); diff --git a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntime.java b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntime.java index c7f1b0190..29834cdcc 100644 --- a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntime.java +++ b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/ParticipantRuntime.java @@ -34,7 +34,6 @@ import org.eclipse.edc.spi.security.Vault; import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; -import org.eclipse.edc.spi.types.domain.message.RemoteMessage; import org.eclipse.edc.token.JwtGenerationService; import org.eclipse.tractusx.edc.spi.identity.mapper.BdrsClient; import org.eclipse.tractusx.edc.tests.MockBpnIdentityService; @@ -61,7 +60,7 @@ public ParticipantRuntime(String moduleName, String runtimeName, String bpn, Map super(runtimeName, properties, moduleName); this.properties = properties; this.registerServiceMock(IdentityService.class, new MockBpnIdentityService(bpn)); - this.registerServiceMock(AudienceResolver.class, RemoteMessage::getCounterPartyAddress); + this.registerServiceMock(AudienceResolver.class, remoteMessage -> Result.success(remoteMessage.getCounterPartyAddress())); this.registerServiceMock(BdrsClient.class, (s) -> s); var kid = properties.get("edc.iam.issuer.id") + "#key-1"; try { diff --git a/edc-tests/runtime/iatp/iatp-extensions/src/main/java/org/eclipse/tractusx/edc/iatp/TestAudienceMapper.java b/edc-tests/runtime/iatp/iatp-extensions/src/main/java/org/eclipse/tractusx/edc/iatp/TestAudienceMapper.java index f37c7efbf..db1e54f51 100644 --- a/edc-tests/runtime/iatp/iatp-extensions/src/main/java/org/eclipse/tractusx/edc/iatp/TestAudienceMapper.java +++ b/edc-tests/runtime/iatp/iatp-extensions/src/main/java/org/eclipse/tractusx/edc/iatp/TestAudienceMapper.java @@ -20,6 +20,7 @@ package org.eclipse.tractusx.edc.iatp; import org.eclipse.edc.spi.iam.AudienceResolver; +import org.eclipse.edc.spi.result.Result; import org.eclipse.edc.spi.types.domain.message.RemoteMessage; import java.util.Map; @@ -37,7 +38,7 @@ public TestAudienceMapper(Map audienceMapping) { } @Override - public String resolve(RemoteMessage remoteMessage) { - return Optional.ofNullable(audienceMapping.get(remoteMessage.getCounterPartyId())).orElse(remoteMessage.getCounterPartyId()); + public Result resolve(RemoteMessage remoteMessage) { + return Result.success(Optional.ofNullable(audienceMapping.get(remoteMessage.getCounterPartyId())).orElse(remoteMessage.getCounterPartyId())); } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 988ba2ee3..45e694575 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ format.version = "1.1" [versions] -edc = "0.7.1-20240610-SNAPSHOT" +edc = "0.7.1-20240618-SNAPSHOT" apache-sshd = "2.12.1" assertj = "3.26.0" awaitility = "4.2.1"