Skip to content

Commit

Permalink
fix: add getAasServiceWithThumnail in new Client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShehriyarShariq-Fraunhofer committed Jun 19, 2024
1 parent a72aa05 commit b2dbd37
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.eclipse.digitaltwin.basyx.aasrepository.AasRepositorySuite;
import org.eclipse.digitaltwin.basyx.aasrepository.DummyAasFactory;
import org.eclipse.digitaltwin.basyx.aasrepository.feature.authorization.DummyAuthorizedAasRepositoryComponent;
import org.eclipse.digitaltwin.basyx.aasservice.AasService;
import org.eclipse.digitaltwin.basyx.aasservice.DummyAssetAdministrationShellFactory;
import org.eclipse.digitaltwin.basyx.aasservice.client.TestAuthorizedConnectedAasService;
import org.eclipse.digitaltwin.basyx.client.internal.ApiException;
import org.eclipse.digitaltwin.basyx.client.internal.authorization.TokenManager;
Expand Down Expand Up @@ -104,4 +106,14 @@ public void sendUnauthorizedRequest() throws IOException {
protected AasRepository getAasRepository() {
return new AuthorizedConnectedAasRepository("http://localhost:8081", new TokenManager("http://localhost:9096/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom"))));
}

@Override
protected AasService getAasServiceWithThumbnail() throws IOException {
AssetAdministrationShell expected = DummyAssetAdministrationShellFactory.createForThumbnail();
AasService aasServiceWithThumbnail = getAasService(expected);

aasServiceWithThumbnail.setThumbnail("dummyImgA.jpeg", "", createDummyImageIS_A());

return aasServiceWithThumbnail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.digitaltwin.basyx.aasrepository.feature.authorization.DummyAuthorizedAasRepositoryComponent;
import org.eclipse.digitaltwin.basyx.aasservice.AasService;
import org.eclipse.digitaltwin.basyx.aasservice.AasServiceSuite;
import org.eclipse.digitaltwin.basyx.aasservice.DummyAssetAdministrationShellFactory;
import org.eclipse.digitaltwin.basyx.authorization.AccessTokenProvider;
import org.eclipse.digitaltwin.basyx.authorization.DummyCredential;
import org.eclipse.digitaltwin.basyx.authorization.DummyCredentialStore;
Expand Down Expand Up @@ -129,6 +130,16 @@ protected AasService getAasService(AssetAdministrationShell shell) {
String base64UrlEncodedId = Base64UrlEncodedIdentifier.encodeIdentifier(shell.getId());
return new AuthorizedConnectedAasService(AAS_REPO_URL + base64UrlEncodedId, new TokenManager("http://localhost:9096/realms/BaSyx/protocol/openid-connect/token", new ClientCredentialAccessTokenProvider(new ClientCredential("workstation-1", "nY0mjyECF60DGzNmQUjL81XurSl8etom"))));
}

@Override
protected AasService getAasServiceWithThumbnail() throws IOException {
AssetAdministrationShell expected = DummyAssetAdministrationShellFactory.createForThumbnail();
AasService aasServiceWithThumbnail = getAasService(expected);

aasServiceWithThumbnail.setThumbnail("dummyImgA.jpeg", "", createDummyImageIS_A());

return aasServiceWithThumbnail;
}

public static void configureSecurityContext(AccessTokenProvider accessTokenProvider) throws FileNotFoundException, IOException {
String adminToken = getAdminAccessToken(accessTokenProvider);
Expand Down

0 comments on commit b2dbd37

Please sign in to comment.