Skip to content

Commit

Permalink
fix: proxy method on Http Pull calls (#3956)
Browse files Browse the repository at this point in the history
* fix: proxy method on Http Pull calls

* dependencies
  • Loading branch information
ndr-brt committed Mar 5, 2024
1 parent 908cdf0 commit 19671bc
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static org.eclipse.edc.connector.dataplane.spi.schema.DataFlowRequestSchema.METHOD;
import static org.eclipse.edc.connector.dataplane.spi.schema.DataFlowRequestSchema.PATH;
import static org.eclipse.edc.connector.dataplane.spi.schema.DataFlowRequestSchema.QUERY_PARAMS;
import static org.eclipse.edc.spi.types.domain.transfer.FlowType.PULL;

public class BaseSourceHttpParamsDecorator implements HttpParamsDecorator {

Expand All @@ -53,7 +54,7 @@ public HttpRequestParams.Builder decorate(DataFlowStartMessage request, HttpData
}

private @NotNull String extractMethod(HttpDataAddress address, DataFlowStartMessage request) {
if (Boolean.parseBoolean(address.getProxyMethod()) && "HttpProxy".equals(request.getDestinationDataAddress().getType())) {
if (Boolean.parseBoolean(address.getProxyMethod()) && PULL.equals(request.getFlowType())) {
return Optional.ofNullable(request.getProperties().get(METHOD))
.orElseThrow(() -> new EdcException(format("DataFlowRequest %s: 'method' property is missing", request.getId())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.edc.spi.EdcException;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.spi.types.domain.transfer.DataFlowStartMessage;
import org.eclipse.edc.spi.types.domain.transfer.FlowType;
import org.junit.jupiter.api.Test;

import java.util.Map;
Expand Down Expand Up @@ -77,6 +78,7 @@ void shouldMapDataFlowRequestToHttpRequest_proxyDataFlowRequest() {
.nonChunkedTransfer(true)
.build();
var dataFlowRequest = DataFlowStartMessage.Builder.newInstance()
.flowType(FlowType.PULL)
.processId(UUID.randomUUID().toString())
.sourceDataAddress(source)
.destinationDataAddress(DataAddress.Builder.newInstance().type("HttpProxy").build())
Expand Down Expand Up @@ -132,6 +134,7 @@ void shouldThrowException_whenProxyMethodIsMissingAndDestinationIsHttpProxy() {
.nonChunkedTransfer(true)
.build();
var dataFlowRequest = DataFlowStartMessage.Builder.newInstance()
.flowType(FlowType.PULL)
.processId(UUID.randomUUID().toString())
.sourceDataAddress(source)
.destinationDataAddress(DataAddress.Builder.newInstance().type("HttpProxy").build())
Expand Down
Loading

0 comments on commit 19671bc

Please sign in to comment.