Skip to content

Commit 4ab5bde

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 1ed8eb5 + 7cc0cf5 commit 4ab5bde

90 files changed

Lines changed: 5547 additions & 880 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/basyx_test.yml

Lines changed: 331 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/docker_test.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,33 @@ jobs:
5454
- name: Clean up
5555
run: exit 0
5656

57+
build-test-aas-repository-mongodb:
58+
runs-on: ubuntu-latest
59+
name: AAS Repository MongoDB - Build and Start Docker Image
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Set up JDK 17
64+
uses: actions/setup-java@v4
65+
with:
66+
java-version: '17'
67+
distribution: 'adopt'
68+
cache: maven
69+
70+
- name: Build BaSyx
71+
run: |
72+
mvn clean install ${MVN_ARGS_BUILD_BASYX_NO_TESTS}
73+
74+
- name: Build AAS Repository Docker Image
75+
run: |
76+
mvn package -DskipTests -Ddocker.namespace=test --pl "org.eclipse.digitaltwin.basyx:basyx.aasrepository.component"
77+
78+
- name: Test AAS Repository MongoDB Docker Image
79+
run: chmod +x ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh && ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh ./ci/workflows/test-aas-repository-mongodb.yml test_aas_repository
80+
81+
- name: Clean up
82+
run: exit 0
83+
5784
build-test-aas-environment:
5885
runs-on: ubuntu-latest
5986
name: AAS Environment - Build and Start Docker Image
@@ -81,6 +108,33 @@ jobs:
81108
- name: Clean up
82109
run: exit 0
83110

111+
build-test-aas-environment-mongodb:
112+
runs-on: ubuntu-latest
113+
name: AAS Environment MongoDB - Build and Start Docker Image
114+
steps:
115+
- uses: actions/checkout@v4
116+
117+
- name: Set up JDK 17
118+
uses: actions/setup-java@v4
119+
with:
120+
java-version: '17'
121+
distribution: 'adopt'
122+
cache: maven
123+
124+
- name: Build BaSyx
125+
run: |
126+
mvn clean install ${MVN_ARGS_BUILD_BASYX_NO_TESTS}
127+
128+
- name: Build AAS Environment Docker Image
129+
run: |
130+
mvn package -DskipTests -Ddocker.namespace=test --pl "org.eclipse.digitaltwin.basyx:basyx.aasenvironment.component"
131+
132+
- name: Test AAS Environment MongoDB Docker Image
133+
run: chmod +x ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh && ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh ./ci/workflows/test-aas-environment-mongodb.yml test_aas_environment
134+
135+
- name: Clean up
136+
run: exit 0
137+
84138
build-test-concept-description-repository:
85139
runs-on: ubuntu-latest
86140
name: Concept Description Repository - Build and Start Docker Image
@@ -108,6 +162,33 @@ jobs:
108162
- name: Clean up
109163
run: exit 0
110164

165+
build-test-cd-repository-mongodb:
166+
runs-on: ubuntu-latest
167+
name: Concept Description Repository MongoDB - Build and Start Docker Image
168+
steps:
169+
- uses: actions/checkout@v4
170+
171+
- name: Set up JDK 17
172+
uses: actions/setup-java@v4
173+
with:
174+
java-version: '17'
175+
distribution: 'adopt'
176+
cache: maven
177+
178+
- name: Build BaSyx
179+
run: |
180+
mvn clean install ${MVN_ARGS_BUILD_BASYX_NO_TESTS}
181+
182+
- name: Build Concept Description Repository Docker Image
183+
run: |
184+
mvn package -DskipTests -Ddocker.namespace=test --pl "org.eclipse.digitaltwin.basyx:basyx.conceptdescriptionrepository.component"
185+
186+
- name: Test Concept Description Repository MongoDB Docker Image
187+
run: chmod +x ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh && ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh ./ci/workflows/test-cd-repository-mongodb.yml test_cd_repository
188+
189+
- name: Clean up
190+
run: exit 0
191+
111192
build-test-aas-discovery:
112193
runs-on: ubuntu-latest
113194
name: AAS Discovery - Build and Start Docker Image
@@ -135,6 +216,32 @@ jobs:
135216
- name: Clean up
136217
run: exit 0
137218

219+
build-test-aas-discovery-mongodb:
220+
runs-on: ubuntu-latest
221+
name: AAS Discovery MongoDB - Build and Start Docker Image
222+
steps:
223+
- uses: actions/checkout@v4
224+
225+
- name: Set up JDK 17
226+
uses: actions/setup-java@v4
227+
with:
228+
java-version: '17'
229+
distribution: 'adopt'
230+
cache: maven
231+
232+
- name: Build BaSyx
233+
run: |
234+
mvn clean install ${MVN_ARGS_BUILD_BASYX_NO_TESTS}
235+
236+
- name: Build AAS Discovery Docker Image
237+
run: |
238+
mvn package -DskipTests -Ddocker.namespace=test --pl "org.eclipse.digitaltwin.basyx:basyx.aasdiscoveryservice.component"
239+
240+
- name: Test AAS Discovery MongoDB Docker Image
241+
run: chmod +x ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh && ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh ./ci/workflows/test-aas-discovery-mongodb.yml test_aas_discovery
242+
243+
- name: Clean up
244+
run: exit 0
138245
build-test-aasx-fileserver:
139246
runs-on: ubuntu-latest
140247
name: AASX File Server - Build and Start Docker Image
@@ -189,6 +296,33 @@ jobs:
189296
- name: Clean up
190297
run: exit 0
191298

299+
build-test-submodel-repository-mongodb:
300+
runs-on: ubuntu-latest
301+
name: Submodel Repository MongoDB - Build and Start Docker Image
302+
steps:
303+
- uses: actions/checkout@v4
304+
305+
- name: Set up JDK 17
306+
uses: actions/setup-java@v4
307+
with:
308+
java-version: '17'
309+
distribution: 'adopt'
310+
cache: maven
311+
312+
- name: Build BaSyx
313+
run: |
314+
mvn clean install ${MVN_ARGS_BUILD_BASYX_NO_TESTS}
315+
316+
- name: Build Submodel Repository Docker Image
317+
run: |
318+
mvn package -DskipTests -Ddocker.namespace=test --pl "org.eclipse.digitaltwin.basyx:basyx.submodelrepository.component"
319+
320+
- name: Test Submodel Repository MongoDB Docker Image
321+
run: chmod +x ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh && ./.github/workflows/scripts/build_start_docker_image_docker_compose.sh ./ci/workflows/test-submodel-repository-mongodb.yml test_submodel_repository
322+
323+
- name: Clean up
324+
run: exit 0
325+
192326
build-test-submodel-service:
193327
runs-on: ubuntu-latest
194328
name: Submodel Service - Build and Start Docker Image

basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestAuthorizedConnectedAasEnvironment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static void cleanUpContext() {
9393

9494
@Before
9595
public void setup() throws IOException {
96-
TokenManager mockTokenManager = new TokenManager("http://localhost:9096/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom")));
96+
TokenManager mockTokenManager = new TokenManager("http://localhost:9098/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom")));
9797

9898
aasEnvironment = new AuthorizedConnectedAasEnvironment(mockTokenManager);
9999
}

basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestAuthorizedConnectedAasManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public class TestAuthorizedConnectedAasManager extends TestConnectedAasManager {
6363
protected final static String AAS_REGISTRY_BASE_PATH = "http://localhost:8051";
6464
protected final static String SM_REGISTRY_BASE_PATH = "http://localhost:8061";
6565

66-
private final static TokenManager TOKEN_MANAGER = new TokenManager("http://localhost:9096/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom")));
67-
private final static TokenManager TOKEN_MANAGER_REGISTRY = new TokenManager("http://localhost:9097/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom")));
66+
private final static TokenManager TOKEN_MANAGER = new TokenManager("http://localhost:9098/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom")));
67+
private final static TokenManager TOKEN_MANAGER_REGISTRY = new TokenManager("http://localhost/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom")));
6868

6969
private static AuthorizedConnectedAasRepository connectedAasRepository;
7070
private static AuthorizedConnectedSubmodelRepository connectedSmRepository;

basyx.aasenvironment/basyx.aasenvironment-client/src/test/resources/application-authorization.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ basyx.feature.authorization.enabled = true
3737
basyx.feature.authorization.type = rbac
3838
basyx.feature.authorization.jwtBearerTokenProvider = keycloak
3939
basyx.feature.authorization.rbac.file = classpath:rbac_rules.json
40-
spring.security.oauth2.resourceserver.jwt.issuer-uri= http://localhost:9096/realms/BaSyx
40+
spring.security.oauth2.resourceserver.jwt.issuer-uri= http://localhost:9098/realms/BaSyx
4141

4242
####################################################################################
4343
# Operation Delegation

basyx.aasrepository/basyx.aasrepository-client/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/client/internal/AssetAdministrationShellRepositoryApi.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,6 @@ private void addAuthorizationHeaderIfAuthIsEnabled(HttpRequest.Builder localVarR
10891089
try {
10901090
localVarRequestBuilder.header("Authorization", "Bearer " + tokenManager.getAccessToken());
10911091
} catch (IOException e) {
1092-
e.printStackTrace();
10931092
throw new AccessTokenRetrievalException("Unable to request access token");
10941093
}
10951094
}

basyx.aasrepository/basyx.aasrepository-feature-registry-integration/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/feature/registry/integration/AuthorizedAasRepositoryRegistryLinkTest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,22 @@
2727

2828
import static org.junit.Assert.assertEquals;
2929
import static org.junit.Assert.assertThrows;
30+
3031
import java.io.FileNotFoundException;
3132
import java.io.IOException;
33+
import java.util.List;
3234

3335
import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiException;
3436
import org.eclipse.digitaltwin.basyx.aasregistry.client.api.RegistryAndDiscoveryInterfaceApi;
3537
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
3638
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.AuthorizedConnectedAasRegistry;
39+
import org.eclipse.digitaltwin.basyx.client.internal.authorization.AccessTokenProviderFactory;
3740
import org.eclipse.digitaltwin.basyx.client.internal.authorization.TokenManager;
41+
import org.eclipse.digitaltwin.basyx.client.internal.authorization.grant.AccessTokenProvider;
42+
import org.eclipse.digitaltwin.basyx.client.internal.authorization.grant.GrantType;
3843
import org.junit.AfterClass;
3944
import org.junit.BeforeClass;
4045
import org.junit.Test;
41-
import org.mockito.Mockito;
4246
import org.springframework.boot.SpringApplication;
4347
import org.springframework.context.ConfigurableApplicationContext;
4448
import org.springframework.http.HttpStatus;
@@ -51,7 +55,7 @@
5155
public class AuthorizedAasRepositoryRegistryLinkTest extends AasRepositoryRegistryLinkTestSuite {
5256

5357
private static final String AAS_REPO_URL = "http://localhost:8081";
54-
private static final String AAS_REGISTRY_BASE_URL = "http://localhost:8051";
58+
private static final String AAS_REGISTRY_BASE_URL = "http://localhost:8052";
5559
private static ConfigurableApplicationContext appContext;
5660
private static AasRepositoryRegistryLink aasRepositoryRegistryLink;
5761

@@ -70,21 +74,26 @@ public static void tearDown() {
7074
appContext.close();
7175
}
7276

77+
7378
@Test
7479
public void sendUnauthorizedRequest() throws IOException {
75-
TokenManager mockTokenManager = Mockito.mock(TokenManager.class);
76-
77-
Mockito.when(mockTokenManager.getAccessToken()).thenReturn("mockedAccessToken");
80+
String clientId = "workstation-1";
81+
String clientSecret = "nY0mjyECF60DGzNmQUjL81XurSl8etom";
82+
83+
AccessTokenProviderFactory factory = new AccessTokenProviderFactory(GrantType.CLIENT_CREDENTIALS, List.of());
84+
factory.setClientCredentials(clientId, clientSecret);
85+
AccessTokenProvider provider = factory.create();
86+
//issuer will also have the port number and will not match the registry issuer -> 401 invalid token, unauthorized
87+
TokenManager tokenManager = new TokenManager("http://localhost:9098/realms/BaSyx/protocol/openid-connect/token", provider);
7888

79-
RegistryAndDiscoveryInterfaceApi registryApi = new AuthorizedConnectedAasRegistry(AAS_REGISTRY_BASE_URL, mockTokenManager);
89+
RegistryAndDiscoveryInterfaceApi registryApi = new AuthorizedConnectedAasRegistry("http://localhost:8051", tokenManager);
8090

8191
AssetAdministrationShellDescriptor descriptor = new AssetAdministrationShellDescriptor();
8292
descriptor.setIdShort("shortId");
8393

8494
ApiException exception = assertThrows(ApiException.class, () -> {
8595
registryApi.postAssetAdministrationShellDescriptor(descriptor);
8696
});
87-
8897
assertEquals(HttpStatus.UNAUTHORIZED.value(), exception.getCode());
8998
}
9099

basyx.aasrepository/basyx.aasrepository-feature-registry-integration/src/test/resources/application-authregistry.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ basyx.externalurl=http://localhost:8081
3636

3737
# Authorized registry integration
3838
basyx.aasrepository.feature.registryintegration.authorization.enabled=true
39-
basyx.aasrepository.feature.registryintegration.authorization.token-endpoint=http://localhost:9097/realms/BaSyx/protocol/openid-connect/token
39+
basyx.aasrepository.feature.registryintegration.authorization.token-endpoint=http://localhost/realms/BaSyx/protocol/openid-connect/token
4040
basyx.aasrepository.feature.registryintegration.authorization.grant-type = CLIENT_CREDENTIALS
4141
basyx.aasrepository.feature.registryintegration.authorization.client-id=workstation-1
4242
basyx.aasrepository.feature.registryintegration.authorization.client-secret=nY0mjyECF60DGzNmQUjL81XurSl8etom

0 commit comments

Comments
 (0)