-
Notifications
You must be signed in to change notification settings - Fork 48
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
fix: add a check for / suffix for basyx external url in registry integration #333
Conversation
….com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into fix-slash-check-registry-integration
….com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into fix-slash-check-registry-integration
….com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into fix-slash-check-registry-integration
public void testUrlWithTrailingSlashAndPathWithLeadingSlash() { | ||
String baseURLWithSlash = AAS_REPO_URL + "/"; | ||
|
||
assertEquals(baseURLWithSlash + AAS_REPOSITORY_PATH_WITHOUT_SLASH, AasDescriptorFactory.createAasRepositoryUrl(baseURLWithSlash)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion is wrongly defined
public void testUrlWithoutTrailingSlashAndPathWithoutLeadingSlash() { | ||
String baseURLWithoutSlash = AAS_REPO_URL; | ||
|
||
assertEquals(baseURLWithoutSlash + AAS_REPOSITORY_PATH_WITH_SLASH , AasDescriptorFactory.createAasRepositoryUrl(baseURLWithoutSlash)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion is wrongly defined
private static final String AAS_REPO_URL = "http://localhost:8081"; | ||
|
||
private static final String AAS_REPOSITORY_PATH_WITH_SLASH = "/shells"; | ||
private static final String AAS_REPOSITORY_PATH_WITHOUT_SLASH = "shells"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either stick to building the withSlash/withoutSlash for both path and repo_url in the test or define them consistenly as final vars; but don't mix both approaches.
public void testUrlWithTrailingSlashAndPathWithLeadingSlash() { | ||
String baseURLWithSlash = SUBMODEL_REPO_URL + "/"; | ||
|
||
assertEquals(baseURLWithSlash + SUBMODEL_REPOSITORY_PATH_WITHOUT_SLASH, SubmodelDescriptorFactory.createSubmodelRepositoryUrl(baseURLWithSlash)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion is wrongly defined
private static final String SUBMODEL_REPO_URL = "http://localhost:8081"; | ||
|
||
|
||
private static final String SUBMODEL_REPOSITORY_PATH_WITH_SLASH = "/submodels"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as in the TestAasDescriptorFactory
public void testUrlWithoutTrailingSlashAndPathWithoutLeadingSlash() { | ||
String baseURLWithoutSlash = SUBMODEL_REPO_URL; | ||
|
||
assertEquals(baseURLWithoutSlash + SUBMODEL_REPOSITORY_PATH_WITH_SLASH , SubmodelDescriptorFactory.createSubmodelRepositoryUrl(baseURLWithoutSlash)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion is wrongly defined
|
||
public static String createRepositoryUrl(String baseUrl, String additionalPath) { | ||
try { | ||
// Create a URI from the base URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please the remove the comments
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
|
||
public class Helper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the name of the helper class. Please also change the test's name
|
||
@Test | ||
public void testUrlWithTrailingSlashAndPathNameWithNoLeadingSlash() { | ||
assertEquals(BASE_URL + "/" + PATH, Helper.createRepositoryUrl(BASE_URL + "/", PATH)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab
|
||
@Test | ||
public void testUrlWithTrailingSlashAndPathNameWithLeadingSlash() { | ||
assertEquals(BASE_URL + "/" + PATH, Helper.createRepositoryUrl(BASE_URL + "/", "/" + PATH)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab
|
||
@Test | ||
public void testUrlWithoutTrailingSlashAndPathNameWithNoLeadingSlash() { | ||
assertEquals(BASE_URL + "/" + PATH , Helper.createRepositoryUrl(BASE_URL, PATH)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make BASE_URL + "/" + PATH a private static final String EXPECTED_URL
public void testUrlWithoutTrailingSlashAndPathNameWithLeadingSlash() { | ||
assertEquals(BASE_URL + "/" + PATH , Helper.createRepositoryUrl(BASE_URL, "/" + PATH)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for urls with a contextPath already set
….com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into fix-slash-check-registry-integration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main issue is that there is no explicit test for the externalUrl URL in the registry-integration features. I was expecting tests for externalUrl in the aasrepository-feature-registry-integration and submodelrepository-feature-registry-integration features. Please find below the entry point to where the externalUrl is mapped (similarly for the submodel feature):
What happens when the / suffix is added or not added to the externalUrl there?
@@ -0,0 +1,36 @@ | |||
package org.eclipse.digitaltwin.basyx.core; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add license header
@@ -0,0 +1,59 @@ | |||
package org.eclipse.digitaltwin.basyx.core; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add license header
@@ -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); |
There was a problem hiding this comment.
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.
….com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into fix-slash-check-registry-integration
Added a trailing slash in case one was missing for the basyx external url in registry integration.
Closes #414