Skip to content

Commit

Permalink
feat(build): bump EDC version to latest nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jun 18, 2024
1 parent d728d83 commit 9ca51bb
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
*/
Expand All @@ -35,8 +38,8 @@ class BdrsClientAudienceMapper implements AudienceResolver {
}

@Override
public String resolve(RemoteMessage remoteMessage) {
return client.resolve(remoteMessage.getCounterPartyId());
public Result<String> resolve(RemoteMessage remoteMessage) {
return Result.from(Optional.ofNullable(client.resolve(remoteMessage.getCounterPartyId())));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");

}

Expand All @@ -51,7 +51,7 @@ void resolve_notFound() {

var did = clientAudienceMapper.resolve(new TestMessage("bpn1"));

assertThat(did).isNull();
assertThat(did).isFailed();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ private Result<Void> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ private Result<Request> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +38,7 @@ public TestAudienceMapper(Map<String, String> audienceMapping) {
}

@Override
public String resolve(RemoteMessage remoteMessage) {
return Optional.ofNullable(audienceMapping.get(remoteMessage.getCounterPartyId())).orElse(remoteMessage.getCounterPartyId());
public Result<String> resolve(RemoteMessage remoteMessage) {
return Result.success(Optional.ofNullable(audienceMapping.get(remoteMessage.getCounterPartyId())).orElse(remoteMessage.getCounterPartyId()));
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9ca51bb

Please sign in to comment.