Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reintroduce integration test #9

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docker Image CI

on:
workflow_dispatch:
push:
branches: [ "main" ]

env:
REGISTRY: ghcr.io

jobs:
federated-catalog-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Log in to the GitHub Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: Informatievlaanderen
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/Informatievlaanderen/vsds-dataspace-connector/federated-authority
tags: |
type=raw,value={{date 'YYYYMMDDHHmmss'}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
file: ./federated-authority-connector/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
4 changes: 2 additions & 2 deletions federated-authority-connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build the jar file
FROM openjdk:18-ea-bullseye AS build
FROM openjdk:21-ea-bullseye AS build

WORKDIR /app
COPY ./ .
RUN ./gradlew clean build

# Run the jar file
FROM openjdk:18-ea-bullseye
FROM openjdk:21-ea-bullseye
WORKDIR /app
COPY --from=build /app/federated-authority-connector/build/libs/federated-authority-connector.jar .

Expand Down
25 changes: 24 additions & 1 deletion federated-authority-connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
`java-library`
id("application")
alias(libs.plugins.shadow)
id("com.google.cloud.tools.jib") version "3.4.1"
}

dependencies {
Expand Down Expand Up @@ -57,8 +58,30 @@ application {
var distTar = tasks.getByName("distTar")
var distZip = tasks.getByName("distZip")

var appName = "federated-authority";

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
mergeServiceFiles()
archiveFileName.set("federated-authority-connector.jar")
archiveFileName.set("$appName.jar")
dependsOn(distTar, distZip)
}

afterEvaluate {
tasks.named("build") {
dependsOn("jibDockerBuild")
}
}

jib {
from {
image = "openjdk:21-ea-bullseye"
}
to {
image = "vsds-dataspace-connector/$appName"
tags = setOf("local")
}
container {
mainClass = application.mainClass.get()
args = listOf("-Dedc.fs.config=\$EDC_FS_CONFIG", "-Dfcc.directory.file=\$FCC_DIRECTORY_FILE")
}
}
4 changes: 2 additions & 2 deletions http-pull-connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build the jar file
FROM openjdk:18-ea-bullseye AS build
FROM openjdk:21-ea-bullseye AS build

WORKDIR /app
COPY ./ .
RUN ./gradlew clean build

# Run the jar file
FROM openjdk:18-ea-bullseye
FROM openjdk:21-ea-bullseye
WORKDIR /app
COPY --from=build /app/http-pull-connector/build/libs/pull-connector.jar .

Expand Down
25 changes: 24 additions & 1 deletion http-pull-connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
`java-library`
id("application")
alias(libs.plugins.shadow)
id("com.google.cloud.tools.jib") version "3.4.1"
}

group = "org.eclipse.edc"
Expand Down Expand Up @@ -58,8 +59,30 @@ application {
var distTar = tasks.getByName("distTar")
var distZip = tasks.getByName("distZip")

var appName = "http-pull"

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
mergeServiceFiles()
archiveFileName.set("pull-connector.jar")
archiveFileName.set("$appName.jar")
dependsOn(distTar, distZip)
}

afterEvaluate {
tasks.named("build") {
dependsOn("jibDockerBuild")
}
}

jib {
from {
image = "openjdk:21-ea-bullseye"
}
to {
image = "vsds-dataspace-connector/$appName"
tags = setOf("local")
}
container {
mainClass = application.mainClass.get()
args = listOf("-Dedc.keystore=\$EDC_KEYSTORE", "-Dedc.keystore.password=\$EDC_KEYSTORE_PASSWORD", "-Dedc.vault=\$EDC_VAULT", "-Dedc.fs.config=\$EDC_FS_CONFIG")
}
}
48 changes: 48 additions & 0 deletions integration-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
java
id("org.springframework.boot") version "3.2.3"
id("io.spring.dependency-management") version "1.1.4"
}

group = "be.vlaanderen.informatievlaanderen.ldes.connector"
version = "0.0.1-SNAPSHOT"

repositories {
mavenCentral()
maven {
url = uri("https://repo.danubetech.com/repository/maven-public/")
}
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter")

implementation("org.springframework.boot:spring-boot-testcontainers")
implementation("org.testcontainers:mongodb")

implementation("org.apache.jena:jena-core:4.10.0")
implementation("org.apache.jena:jena-arq:4.10.0")

implementation("com.auth0:java-jwt:4.4.0")
implementation("org.web3j:crypto:5.0.0")
implementation("decentralized-identity:did-common-java:1.11.0")
implementation("io.fusionauth:fusionauth-jwt:5.3.2")


testImplementation("org.testcontainers:nginx:1.19.6")
testImplementation("io.cucumber:cucumber-java:6.10.4")
testImplementation("io.cucumber:cucumber-junit:6.10.4")
testImplementation("org.junit.vintage:junit-vintage-engine:5.7.2")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testcontainers:junit-jupiter")

}

springBoot {
mainClass.set("connector.LdesServerContainer")
}

tasks.withType<Test> {
useJUnitPlatform()
}
109 changes: 109 additions & 0 deletions integration-test/src/main/java/connector/DataSpaceInteractor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package connector;

import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;

public class DataSpaceInteractor {
public static String dataPlaneCreationRequest(String providerUrl, int publicPort, int controlPort) {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
jsonBuilder.add("@context", Json.createObjectBuilder()
.add("edc", "https://w3id.org/edc/v0.0.1/ns/"));
jsonBuilder.add("url", "%s:%s/control/transfer".formatted(providerUrl, controlPort));
jsonBuilder.add("allowedSourceTypes", Json.createArrayBuilder()
.add("HttpData"));
jsonBuilder.add("allowedDestTypes", Json.createArrayBuilder()
.add("HttpProxy")
.add("HttpData"));
jsonBuilder.add("properties", Json.createObjectBuilder()
.add("https://w3id.org/edc/v0.0.1/ns/publicApiUrl", "%s:%s/public/".formatted(providerUrl, publicPort)));


return jsonBuilder.build().toString();
}

public static String assetCreationRequest(String assetName, String ldesServerStreamUrl) {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
jsonBuilder.add("@context", Json.createObjectBuilder()
.add("edc", "https://w3id.org/edc/v0.0.1/ns/"));
jsonBuilder.add("@id", assetName);
jsonBuilder.add("properties", Json.createObjectBuilder()
.add("name", assetName)
.add("contenttype", "application/n-quads"));
jsonBuilder.add("dataAddress", Json.createObjectBuilder()
.add("name", assetName)
.add("type", "HttpData")
.add("baseUrl", ldesServerStreamUrl)
.add("proxyPath", "true")
.add("proxyQueryParams", "true")
.add("header:Accept", "application/n-quads")
.add("contenttype", "application/n-quads"));

return jsonBuilder.build().toString();
}

public static String policyCreationRequest(String policyId) {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
jsonBuilder.add("@context", Json.createObjectBuilder()
.add("edc", "https://w3id.org/edc/v0.0.1/ns/")
.add("odrl", "http://www.w3.org/ns/odrl/2/"));
jsonBuilder.add("@id", policyId);
jsonBuilder.add("policy", Json.createObjectBuilder()
.add("@type", "set")
.add("odrl:permission", Json.createArrayBuilder())
.add("odrl:prohibition", Json.createArrayBuilder())
.add("odrl:obligation", Json.createArrayBuilder()));

return jsonBuilder.build().toString();
}

public static String contractCreationRequest(String contractId, String accessPolicyId,
String contractPolicyId) {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
jsonBuilder.add("@context", Json.createObjectBuilder()
.add("edc", "https://w3id.org/edc/v0.0.1/ns/"));
jsonBuilder.add("@id", contractId);
jsonBuilder.add("accessPolicyId", accessPolicyId);
jsonBuilder.add("contractPolicyId", contractPolicyId);
jsonBuilder.add("assetsSelector", Json.createArrayBuilder());

return jsonBuilder.build().toString();
}

public static String contractNegotiationRequest(String providerAddress, String providerId,
JsonObject policy, String assetId) {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
jsonBuilder.add("@context", Json.createObjectBuilder()
.add("edc", "https://w3id.org/edc/v0.0.1/ns/")
.add("odrl", "http://www.w3.org/ns/odrl/2/"));
jsonBuilder.add("@type", "NegotiationInitiateRequestDto");
jsonBuilder.add("connectorAddress", providerAddress);
jsonBuilder.add("providerId", providerId);
jsonBuilder.add("protocol", "dataspace-protocol-http");
jsonBuilder.add("offer", Json.createObjectBuilder()
.add("offerId", policy.getString("@id"))
.add("assetId", assetId)
.add("policy", policy));

return jsonBuilder.build().toString();
}

public static String transferRequest(String providerDid, String providerUrl, String contractId, String assetId, String ldioTokenEndpoint) {
JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
jsonBuilder.add("@context", Json.createObjectBuilder()
.add("@vocab", "https://w3id.org/edc/v0.0.1/ns/"));
jsonBuilder.add("@type", "TransferRequest");
jsonBuilder.add("connectorId", providerDid);
jsonBuilder.add("connectorAddress", providerUrl);
jsonBuilder.add("contractId", contractId);
jsonBuilder.add("assetId", assetId);
jsonBuilder.add("protocol", "dataspace-protocol-http");
jsonBuilder.add("dataDestination", Json.createObjectBuilder()
.add("@type", "DataAddress")
.add("type", "HttpProxy"));
jsonBuilder.add("privateProperties", Json.createObjectBuilder()
.add("receiverHttpEndpoint", ldioTokenEndpoint));

return jsonBuilder.build().toString();
}
}
Loading