-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #485 from affinidi/integration-test
Manual Integration tests and fix for authprovider junits
- Loading branch information
Showing
7 changed files
with
267 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
AFFINIDI_TDK_ENVIRONMENT=prod | ||
|
||
PROJECT_ID="" | ||
KEY_ID= | ||
TOKEN_ID="" | ||
PASSPHRASE="" | ||
PRIVATE_KEY="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>jar</packaging> | ||
<groupId>com.affinidi.tdk</groupId> | ||
<artifactId>reference</artifactId> | ||
<version>1.0</version> | ||
<name>reference</name> | ||
<url>https://github.com/affinidi/affinidi-tdk</url> | ||
<licenses> | ||
<license> | ||
<name>Apache-2.0</name> | ||
<url>https://github.com/affinidi/affinidi-tdk/blob/main/LICENSE</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Affinidi</name> | ||
<email>...</email> | ||
<organization>Affinidi</organization> | ||
<organizationUrl>https://affinidi.com</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>${java.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.version}</maven.compiler.target> | ||
<affinidi-common-version>1.0</affinidi-common-version> | ||
<affinidi-auth-version>1.0</affinidi-auth-version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>com.affinidi.tdk</groupId> | ||
<artifactId>common</artifactId> | ||
<version>${affinidi-common-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.affinidi.tdk</groupId> | ||
<artifactId>auth.provider</artifactId> | ||
<version>${affinidi-auth-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.affinidi.tdk</groupId> | ||
<artifactId>wallets.client</artifactId> | ||
<version>1.0.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.affinidi.tdk</groupId> | ||
<artifactId>credential.issuance.client</artifactId> | ||
<version>1.0.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>3.5.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
116 changes: 116 additions & 0 deletions
116
tests/integration/java/reference/src/main/java/com/affinidi/reference/TdkTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
|
||
package com.affinidi.reference; | ||
|
||
|
||
|
||
|
||
import com.affinidi.tdk.authProvider.AuthProvider; | ||
|
||
import com.affinidi.tdk.credential.issuance.client.apis.IssuanceApi; | ||
|
||
import com.affinidi.tdk.wallets.client.ApiClient; | ||
import com.affinidi.tdk.wallets.client.Configuration; | ||
import com.affinidi.tdk.wallets.client.apis.WalletApi; | ||
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth; | ||
import com.affinidi.tdk.wallets.client.models.WalletsListDto; | ||
|
||
|
||
/** | ||
* To execute this class, | ||
1. Ensure that base package of the working directory contains a valid .env file with values for each property | ||
as present in .env.example | ||
2. Ensure that auth-provider and common package jar is present in either the central maven respository | ||
3. Or you can go to the resective pakage and run mvn clean install : in order to deply these jars in local | ||
maven respository | ||
* | ||
* @author Priyanka | ||
* | ||
*/ | ||
|
||
public class TdkTestUtil { | ||
|
||
public static void main(String arg[]){ | ||
try{ | ||
System.out.println("\n\n============================="); | ||
System.out.println("01. Testing Wallet Client using TDK java packages"); | ||
System.out.println("=============================\n\n"); | ||
testWalletClient(); | ||
System.out.println("\n\n============================="); | ||
System.out.println("Wallet Client testing using TDK java packages completed"); | ||
System.out.println("=============================\n\n"); | ||
|
||
|
||
System.out.println("\n\n============================="); | ||
System.out.println("02. Testing Issuance Client using TDK java packages"); | ||
System.out.println("=============================\n\n"); | ||
testIssuanceClient(); | ||
System.out.println("\n\n============================="); | ||
System.out.println("Issuance Client testing using TDK java packages completed"); | ||
System.out.println("=============================\n\n"); | ||
}catch(Exception exception){ | ||
exception.printStackTrace(); | ||
} | ||
} | ||
|
||
public static void testWalletClient() throws Exception{ | ||
|
||
System.out.println("Getting projectScopenToken before calling wallet API"); | ||
|
||
AuthProvider authProvider = new AuthProvider.Configurations().buildWithEnv(); | ||
String projectToken = authProvider.fetchProjectScopedToken(); | ||
System.out.println("ProjectScopeToken > > > > > : "+projectToken); | ||
|
||
// Creating an API Client using the above token | ||
ApiClient defaultClient = Configuration.getDefaultApiClient(); | ||
ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth"); | ||
ProjectTokenAuth.setApiKey(projectToken); | ||
|
||
WalletApi apiInstance = new WalletApi(defaultClient); | ||
String didType = null; | ||
|
||
System.out.println("Calling listWallets "); | ||
WalletsListDto response = apiInstance.listWallets(didType); | ||
System.out.println("Total wallets : "+response.getWallets().size()); | ||
|
||
|
||
System.out.println("Should AuthProvider refresh the token before any further call ? "+authProvider.shouldRefreshToken()); | ||
} | ||
|
||
public static void testIssuanceClient() throws Exception{ | ||
|
||
System.out.println("Getting projectScopenToken before calling issuance API"); | ||
AuthProvider authProvider = new AuthProvider.Configurations().buildWithEnv(); | ||
String projectToken = authProvider.fetchProjectScopedToken(); | ||
|
||
// Creating an API Client using the above token | ||
com.affinidi.tdk.credential.issuance.client.ApiClient issuanceClient = com.affinidi.tdk.credential.issuance.client.Configuration.getDefaultApiClient(); | ||
com.affinidi.tdk.credential.issuance.client.auth.ApiKeyAuth issueTokenAuth = (com.affinidi.tdk.credential.issuance.client.auth.ApiKeyAuth) issuanceClient.getAuthentication("ProjectTokenAuth"); | ||
issueTokenAuth.setApiKey(projectToken); | ||
|
||
IssuanceApi issuanceApi = new IssuanceApi(issuanceClient); | ||
String projectIdForTesting = "084036a6-a775-478a-9a97-a1323738897f"; | ||
System.out.println(issuanceApi.listIssuance(projectIdForTesting)); | ||
|
||
/* Uncomment to test startIssuance. Provide the relevant projectId and crdential data | ||
StartIssuanceInput startIssuanceInput = new StartIssuanceInput(); | ||
startIssuanceInput.setHolderDid("did:key:zQ3shNb7dEAa7z4LY8eAbPafNM4iSxppwuvndoHkTUUp8Hbt6"); | ||
startIssuanceInput.setClaimMode(ClaimModeEnum.NORMAL); | ||
StartIssuanceInputDataInner innerData = new StartIssuanceInputDataInner(); | ||
innerData.setCredentialTypeId("AlumniIdentityCard"); | ||
List<StartIssuanceInputDataInner> list = new ArrayList<StartIssuanceInputDataInner>(); | ||
list.add(innerData); | ||
startIssuanceInput.setData(list); | ||
System.out.println(issuanceApi.startIssuance("<projectid>", startIssuanceInput)); | ||
*/ | ||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
} |