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

fix: add a check for / suffix for basyx external url in registry integration #333

Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
82a79d2
fix: –add a check for / suffix for basyx external url in registry int…
ShehriyarShariq-Fraunhofer Jul 9, 2024
4a7a8aa
fix: submodal integration test
ShehriyarShariq-Fraunhofer Jul 9, 2024
62d44d1
Empty commit for the CI to run
mateusmolina-iese Jul 9, 2024
13868a9
fix: registry integration create url logic
ShehriyarShariq-Fraunhofer Jul 9, 2024
94923af
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Jul 9, 2024
bb3e3e9
Empty commit for the CI to run
mateusmolina-iese Jul 9, 2024
437ac16
fix: latest merge
ShehriyarShariq-Fraunhofer Jul 16, 2024
9bdb684
Empty commit for the CI to run
mateusmolina-iese Jul 16, 2024
c410c6a
fix: feature-registry-integration createURL remove static reference i…
ShehriyarShariq-Fraunhofer Jul 16, 2024
245bae2
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Jul 16, 2024
dae87d7
Triggering the CI
mateusmolina-iese Jul 23, 2024
ba08cbd
fix: createUrl method issue with path without leading slash resolved
ShehriyarShariq-Fraunhofer Jul 23, 2024
99a47de
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Jul 23, 2024
9d86f9e
fix: use main static createUrl method in DescriptorFactory test cases
ShehriyarShariq-Fraunhofer Jul 23, 2024
c75b166
refactor: remove create*Url method from Dummy*DescriptorFactory
ShehriyarShariq-Fraunhofer Jul 25, 2024
9272437
fix: Test*DescriptorFactory refactor tests
ShehriyarShariq-Fraunhofer Jul 25, 2024
ad5b8a1
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Jul 26, 2024
27e19d4
refactor: make createRepositoryUrl common + refactor implementation
ShehriyarShariq-Fraunhofer Jul 31, 2024
da4b87b
fix: RepositoryUrlHelper - add tests with context path in url
ShehriyarShariq-Fraunhofer Aug 1, 2024
3306f65
refactor: reformat RepositoryUrlHelper + Test
ShehriyarShariq-Fraunhofer Aug 1, 2024
2be64c0
fix: resolve merge conflicts with latest updates from main
ShehriyarShariq-Fraunhofer Aug 26, 2024
7b303c4
Empty commit to trigger the CI
mateusmolina-iese Aug 27, 2024
b4afd85
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Sep 2, 2024
bcdef6e
fix: refactor utility url functions
ShehriyarShariq-Fraunhofer Sep 2, 2024
d30b228
Triggering the CI
mateusmolina-iese Sep 3, 2024
37bc55e
fix: aas repository feature auth url function fix
ShehriyarShariq-Fraunhofer Sep 3, 2024
a29ab5a
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Sep 3, 2024
66b6354
Triggering the CI
mateusmolina-iese Sep 3, 2024
581e641
fix: revert pom + update createRepositoryUrl functionality
ShehriyarShariq-Fraunhofer Sep 16, 2024
dedc173
Triggering the CI
mateusmolina-iese Sep 17, 2024
3ccbec3
fix: add license headers
ShehriyarShariq-Fraunhofer Sep 24, 2024
9c118a4
fix: update test for external url
ShehriyarShariq-Fraunhofer Sep 30, 2024
27bdb45
stash
ShehriyarShariq-Fraunhofer Oct 1, 2024
ec7e126
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Oct 14, 2024
c7f3d55
feat: AasRepositoryRegistryLinkDescriptorGenerationTest
ShehriyarShariq-Fraunhofer Oct 15, 2024
5bd2f77
stash
ShehriyarShariq-Fraunhofer Oct 27, 2024
09f00d0
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Oct 27, 2024
493f177
stash
ShehriyarShariq-Fraunhofer Oct 27, 2024
d0ba025
stash
ShehriyarShariq-Fraunhofer Oct 28, 2024
2b5163f
stash
ShehriyarShariq-Fraunhofer Oct 29, 2024
0de2d33
fix: working registry url slash test
ShehriyarShariq-Fraunhofer Oct 29, 2024
b1babf6
feat: working test
ShehriyarShariq-Fraunhofer Oct 29, 2024
ec123aa
fix: merge from main
ShehriyarShariq-Fraunhofer Oct 29, 2024
ae3c928
feat: add Submodel Repo Registry Test
ShehriyarShariq-Fraunhofer Oct 29, 2024
d15ef4d
fix: merge with main
ShehriyarShariq-Fraunhofer Oct 29, 2024
f03d036
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Oct 29, 2024
a9f4ad2
fix: revert pom.xml
ShehriyarShariq-Fraunhofer Oct 29, 2024
ed11d33
style: code clean-up
mateusmolina-iese Nov 4, 2024
4913629
test: refactor *RepositoryRegistryLink tests to be parameterized
mateusmolina-iese Nov 4, 2024
1119feb
style: minor fixes
mateusmolina-iese Nov 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ProtocolInformation;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.mapper.AttributeMapper;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;

/**
Expand Down Expand Up @@ -196,7 +197,7 @@ private String getProtocol(String endpoint) {
private List<String> createAasRepositoryUrls(List<String> aasRepositoryBaseURLs) {
List<String> toReturn = new ArrayList<>(aasRepositoryBaseURLs.size());
for (String eachUrl : aasRepositoryBaseURLs) {
toReturn.add(createAasRepositoryUrl(eachUrl));
toReturn.add(RepositoryUrlHelper.createRepositoryUrl(eachUrl, AAS_REPOSITORY_PATH));
}
return toReturn;
}
Expand All @@ -209,5 +210,4 @@ private String createAasRepositoryUrl(String aasRepositoryBaseURL) {
throw new RuntimeException("The AAS Repository Base url is malformed.\n" + e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetKind;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ProtocolInformation;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;

/**
Expand Down Expand Up @@ -76,7 +77,7 @@ private static ProtocolInformation createProtocolInformation(String aasId, Strin
}

private static String createHref(String aasId, String aasRepoBaseUrl) {
return String.format("%s/%s", createAasRepositoryUrl(aasRepoBaseUrl), Base64UrlEncodedIdentifier.encodeIdentifier(aasId));
return String.format("%s/%s", RepositoryUrlHelper.createRepositoryUrl(aasRepoBaseUrl, AAS_REPOSITORY_PATH), Base64UrlEncodedIdentifier.encodeIdentifier(aasId));
}

private static String getProtocol(String endpoint) {
Expand All @@ -86,14 +87,4 @@ private static String getProtocol(String endpoint) {
throw new RuntimeException();
}
}

private static String createAasRepositoryUrl(String aasRepositoryBaseURL) {

try {
return new URL(new URL(aasRepositoryBaseURL), AAS_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The AAS Repository Base url is malformed. " + e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.eclipse.digitaltwin.basyx.authorization.DummyCredentialStore;
import org.eclipse.digitaltwin.basyx.authorization.jwt.JwtTokenDecoder;
import org.eclipse.digitaltwin.basyx.authorization.jwt.PublicKeyUtils;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.eclipse.digitaltwin.basyx.http.serialization.BaSyxHttpTestUtils;
import org.junit.AfterClass;
Expand All @@ -73,7 +74,7 @@
*/
public class TestAuthorizedAasRepository {

private static final String AAS_REPOSITORY_PATH = "/shells";
// private static final String AAS_REPOSITORY_PATH = "/shells";
private static final String AAS_SIMPLE_2_JSON = "authorization/AasSimple_2.json";
private static final String AAS_SIMPLE_1_JSON = "authorization/AasSimple_1.json";
private static final String SPECIFIC_SHELL_ID_2 = "specificAasId-2";
Expand Down Expand Up @@ -529,10 +530,10 @@ public void getThumbnailWithCorrectRoleAndPermission() throws IOException {

String accessToken = getAccessToken(DummyCredentialStore.BASYX_READER_CREDENTIAL);

CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), accessToken);
CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), accessToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the calls to createRepositoryUrl(...) necessary? The second par is always null. Either remove them OR remove the shells context in aasRepositoryBaseUrl and use AAS_REPOSITORY_PATH and createRepositoryUrl(...) to generate the url.

assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
}

@Test
Expand All @@ -541,31 +542,31 @@ public void getThumbnailWithCorrectRoleAndSpecificAasPermission() throws IOExcep

String accessToken = getAccessToken(DummyCredentialStore.BASYX_READER_TWO_CREDENTIAL);

CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), accessToken);
CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), accessToken);
assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
}

@Test
public void getThumbnailWithCorrectRoleAndUnauthorizedSpecificAas() throws IOException {
String accessToken = getAccessToken(DummyCredentialStore.BASYX_READER_TWO_CREDENTIAL);

CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID_2), accessToken);
CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID_2), accessToken);
assertEquals(HttpStatus.FORBIDDEN.value(), retrievalResponse.getCode());
}

@Test
public void getThumbnailWithInsufficientPermissionRole() throws IOException {
String accessToken = getAccessToken(DummyCredentialStore.BASYX_DELETER_CREDENTIAL);

CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), accessToken);
CloseableHttpResponse retrievalResponse = getElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), accessToken);
assertEquals(HttpStatus.FORBIDDEN.value(), retrievalResponse.getCode());
}

@Test
public void getThumbnailWithNoAuthorization() throws IOException {
CloseableHttpResponse retrievalResponse = getElementWithNoAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID));
CloseableHttpResponse retrievalResponse = getElementWithNoAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID));

assertEquals(HttpStatus.UNAUTHORIZED.value(), retrievalResponse.getCode());
}
Expand All @@ -577,7 +578,7 @@ public void setThumbnailWithCorrectRoleAndPermission() throws IOException {
CloseableHttpResponse retrievalResponse = setThumbnailToAasWithAuthorization(SPECIFIC_SHELL_ID, accessToken);
assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
}

@Test
Expand All @@ -587,7 +588,7 @@ public void setThumbnailWithCorrectRoleAndSpecificAasPermission() throws IOExcep
CloseableHttpResponse retrievalResponse = setThumbnailToAasWithAuthorization(SPECIFIC_SHELL_ID, accessToken);
assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
}

@Test
Expand Down Expand Up @@ -619,10 +620,10 @@ public void deleteThumbnailWithCorrectRoleAndPermission() throws IOException {

String accessToken = getAccessToken(DummyCredentialStore.BASYX_ASSET_UPDATER_CREDENTIAL);

CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), accessToken);
CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), accessToken);
assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

assertElementIsNotOnServer(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
assertElementIsNotOnServer(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
}

@Test
Expand All @@ -633,32 +634,32 @@ public void deleteThumbnailWithCorrectRoleAndSpecificAasPermission() throws IOEx

String accessToken = getAccessToken(DummyCredentialStore.BASYX_ASSET_UPDATER_TWO_CREDENTIAL);

CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID_2), accessToken);
CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID_2), accessToken);
assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

assertElementIsNotOnServer(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID_2), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
assertElementIsNotOnServer(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID_2), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
deleteElementWithAuthorization(getSpecificAasAccessURL(SPECIFIC_SHELL_ID_2), getAccessToken(DummyCredentialStore.ADMIN_CREDENTIAL));
}

@Test
public void deleteThumbnailWithCorrectRoleAndUnauthorizedSpecificAas() throws IOException {
String accessToken = getAccessToken(DummyCredentialStore.BASYX_ASSET_UPDATER_TWO_CREDENTIAL);

CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), accessToken);
CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), accessToken);
assertEquals(HttpStatus.FORBIDDEN.value(), retrievalResponse.getCode());
}

@Test
public void deleteThumbnailWithInsufficientPermissionRole() throws IOException {
String accessToken = getAccessToken(DummyCredentialStore.BASYX_CREATOR_CREDENTIAL);

CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID), accessToken);
CloseableHttpResponse retrievalResponse = deleteElementWithAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID), accessToken);
assertEquals(HttpStatus.FORBIDDEN.value(), retrievalResponse.getCode());
}

@Test
public void deleteThumbnailWithNoAuthorization() throws IOException {
CloseableHttpResponse retrievalResponse = deleteElementWithNoAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(createAasRepositoryUrl(aasRepositoryBaseUrl), SPECIFIC_SHELL_ID));
CloseableHttpResponse retrievalResponse = deleteElementWithNoAuthorization(BaSyxHttpTestUtils.getThumbnailAccessURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), SPECIFIC_SHELL_ID));

assertEquals(HttpStatus.UNAUTHORIZED.value(), retrievalResponse.getCode());
}
Expand Down Expand Up @@ -716,11 +717,11 @@ private String getAccessToken(DummyCredential dummyCredential) {
}

protected CloseableHttpResponse getAllAasWithAuthorization(String accessToken) throws IOException {
return BaSyxHttpTestUtils.executeAuthorizedGetOnURL(createAasRepositoryUrl(aasRepositoryBaseUrl), accessToken);
return BaSyxHttpTestUtils.executeAuthorizedGetOnURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), accessToken);
}

protected CloseableHttpResponse getAllAasNoAuthorization() throws IOException {
return BaSyxHttpTestUtils.executeGetOnURL(createAasRepositoryUrl(aasRepositoryBaseUrl));
return BaSyxHttpTestUtils.executeGetOnURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null));
}

protected CloseableHttpResponse getElementWithAuthorization(String url, String accessToken) throws IOException {
Expand All @@ -732,11 +733,11 @@ protected CloseableHttpResponse getElementWithNoAuthorization(String url) throws
}

protected String getSpecificAasAccessURL(String shellId) {
return createAasRepositoryUrl(createAasRepositoryUrl(aasRepositoryBaseUrl)) + "/" + Base64UrlEncodedIdentifier.encodeIdentifier(shellId);
return RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null) + "/" + Base64UrlEncodedIdentifier.encodeIdentifier(shellId);
}

private static CloseableHttpResponse createAasOnRepositoryWithAuthorization(String aasJsonContent, String accessToken) throws IOException {
return BaSyxHttpTestUtils.executeAuthorizedPostOnURL(createAasRepositoryUrl(aasRepositoryBaseUrl), aasJsonContent, accessToken);
return BaSyxHttpTestUtils.executeAuthorizedPostOnURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), aasJsonContent, accessToken);
}

private CloseableHttpResponse setThumbnailToAasWithAuthorization(String shellId, String accessToken) throws IOException {
Expand All @@ -752,7 +753,7 @@ private CloseableHttpResponse setThumbnailToAasWithNoAuthorization(String shellI
}

private static CloseableHttpResponse createAasOnRepositoryWithNoAuthorization(String aasJsonContent) throws IOException {
return BaSyxHttpTestUtils.executePostOnURL(createAasRepositoryUrl(aasRepositoryBaseUrl), aasJsonContent);
return BaSyxHttpTestUtils.executePostOnURL(RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null), aasJsonContent);
}

private CloseableHttpResponse updateElementWithAuthorizationPutRequest(String url, String aasJsonContent, String accessToken) throws IOException {
Expand Down Expand Up @@ -812,15 +813,6 @@ private String getSpecificSubmodelReferenceUrl(String shellId, String submodelId

private static String getThumbnailAccessURL(String aasId) {
Base64UrlEncodedIdentifier identifier = new Base64UrlEncodedIdentifier(aasId);
return createAasRepositoryUrl(aasRepositoryBaseUrl) + "/" + identifier.getEncodedIdentifier() + "/asset-information/thumbnail";
}

private static String createAasRepositoryUrl(String aasRepositoryBaseURL) {

try {
return new URL(new URL(aasRepositoryBaseURL), AAS_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The AAS Repository Base url is malformed. " + e.getMessage());
}
return RepositoryUrlHelper.createRepositoryUrl(aasRepositoryBaseUrl, null) + "/" + identifier.getEncodedIdentifier() + "/asset-information/thumbnail";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiException;
import org.eclipse.digitaltwin.basyx.aasregistry.client.api.RegistryAndDiscoveryInterfaceApi;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.GetAssetAdministrationShellDescriptorsResult;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.mapper.DummyAasDescriptorFactory;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.eclipse.digitaltwin.basyx.http.serialization.BaSyxHttpTestUtils;
Expand All @@ -53,8 +52,8 @@
* @author danish
*/
public abstract class AasRepositoryRegistryLinkTestSuite {
private static final String AAS_REPOSITORY_PATH = "shells";

private static final String AAS_REPOSITORY_PATH = "/shells";
private static final String DUMMY_GLOBAL_ASSETID = "globalAssetId";
private static final String DUMMY_IDSHORT = "ExampleMotor";
private static final String DUMMY_AAS_ID = "customIdentifier";
Expand Down Expand Up @@ -129,25 +128,15 @@ private String getAas1JSONString() throws FileNotFoundException, IOException {
}

private CloseableHttpResponse createAasOnRepo(String aasJsonContent) throws IOException {
return BaSyxHttpTestUtils.executePostOnURL(createAasRepositoryUrl(getFirstAasRepoBaseUrl()), aasJsonContent);
return BaSyxHttpTestUtils.executePostOnURL(RepositoryUrlHelper.createRepositoryUrl(getFirstAasRepoBaseUrl(), AAS_REPOSITORY_PATH), aasJsonContent);
}

private String getSpecificAasAccessURL(String aasId) {
return createAasRepositoryUrl(getFirstAasRepoBaseUrl()) + "/"
return RepositoryUrlHelper.createRepositoryUrl(getFirstAasRepoBaseUrl(), AAS_REPOSITORY_PATH) + "/"
+ Base64UrlEncodedIdentifier.encodeIdentifier(aasId);
}

private String getFirstAasRepoBaseUrl() {
return getAasRepoBaseUrls()[0];
}

private static String createAasRepositoryUrl(String aasRepositoryBaseURL) {

try {
return new URL(new URL(aasRepositoryBaseURL), AAS_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The AAS Repository Base url is malformed. " + e.getMessage());
}
}

}
Loading