forked from eclipse-edc/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: http proxy sample (eclipse-edc#363)
* build: update shadow plugin group id * docs: add samples for proxy data-plane * feat: add transfer-06 sample for custom proxy component
- Loading branch information
Showing
25 changed files
with
534 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...ts/src/test/java/org/eclipse/edc/samples/transfer/Transfer06customProxyDataPlaneTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2022 Microsoft Corporation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial test implementation for sample | ||
* Mercedes-Benz Tech Innovation GmbH - refactor test cases | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.samples.transfer; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates; | ||
import org.eclipse.edc.junit.annotations.EndToEndTest; | ||
import org.eclipse.edc.junit.extensions.RuntimeExtension; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.apache.http.HttpHeaders.AUTHORIZATION; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath; | ||
import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation; | ||
import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_KEY; | ||
import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_VALUE; | ||
import static org.eclipse.edc.samples.common.PrerequisitesCommon.CONSUMER_MANAGEMENT_URL; | ||
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer; | ||
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider; | ||
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus; | ||
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer; | ||
import static org.hamcrest.Matchers.emptyString; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
@EndToEndTest | ||
public class Transfer06customProxyDataPlaneTest { | ||
|
||
private static final String SAMPLE_NAME = "transfer-06-custom-proxy-data-plane"; | ||
private static final String START_TRANSFER_FILE_PATH = "transfer/%s/resources/start-transfer.json".formatted(SAMPLE_NAME); | ||
|
||
@RegisterExtension | ||
static RuntimeExtension provider = getProvider( | ||
":transfer:%s:provider-proxy-data-plane".formatted(SAMPLE_NAME), | ||
"transfer/%s/resources/configuration/provider.properties".formatted(SAMPLE_NAME) | ||
); | ||
|
||
@RegisterExtension | ||
static RuntimeExtension consumer = getConsumer(); | ||
|
||
@Test | ||
void runSampleSteps() { | ||
var requestBody = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH); | ||
var contractAgreementId = runNegotiation(); | ||
var transferProcessId = startTransfer(requestBody, contractAgreementId); | ||
checkTransferStatus(transferProcessId, TransferProcessStates.STARTED); | ||
|
||
var edr = given() | ||
.when() | ||
.get(CONSUMER_MANAGEMENT_URL + "/v3/edrs/{id}/dataaddress", transferProcessId) | ||
.then() | ||
.log().ifValidationFails() | ||
.statusCode(200) | ||
.extract().body().jsonPath(); | ||
|
||
var result = given() | ||
.header(API_KEY_HEADER_KEY, API_KEY_HEADER_VALUE) | ||
.header(AUTHORIZATION, edr.getString("authorization")) | ||
.when() | ||
.get(edr.getString("endpoint")) | ||
.then() | ||
.statusCode(HttpStatus.SC_OK) | ||
.log().ifValidationFails() | ||
.body("[0].name", not(emptyString())) | ||
.extract() | ||
.jsonPath() | ||
.get("[0].name"); | ||
|
||
assertThat(result).isEqualTo("Leanne Graham"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.