From 35fbef07eb45dc14b1eafde7379b6d9f12d6fd49 Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Wed, 13 Nov 2024 14:30:42 +0530 Subject: [PATCH 1/8] MOSIP-37214 Signed-off-by: Nandhukumar --- api-test/README.md | 101 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/api-test/README.md b/api-test/README.md index 51b622679..53b70877d 100644 --- a/api-test/README.md +++ b/api-test/README.md @@ -1,3 +1,100 @@ -# Automation test +# eSignet API Test Rig -All automation test code. +## Overview + +The **eSignet API Test Rig** is designed for the execution of module-wise automation API tests for the eSignet service. This test rig utilizes **Java REST Assured** and **TestNG** frameworks to automate testing of the eSignet API functionalities. The key focus is to validate the authentication, signature generation, and related functionalities provided by the eSignet module. + +## Test Categories + +- **Smoke**: Contains only positive test scenarios for quick verification. +- **Regression**: Includes all test scenarios, covering both positive and negative cases. + +## Coverage + +This test rig covers only **external API endpoints** exposed by the eSignet module. + +## Pre-requisites + +Before running the automation tests, ensure the following software is installed on the machine: + +- **Java 21** (or a compatible version) +- **Maven 3.9.6** (or higher) +- **Lombok** (Refer to [Lombok Project](https://projectlombok.org/)) + +### For Windows + +- **Git Bash 2.18.0** or higher +- Ensure the `settings.xml` file is present in the `.m2` folder. + +### For Linux + +- The `settings.xml` file should be present in two places: + - In the regular Maven configuration folder (`/conf`) + - Under `/usr/local/maven/conf/` + +## Access Test Automation Code + +You can access the test automation code using either of the following methods: + +### From Browser + +1. Clone or download the repository as a zip file from [GitHub](https://github.com/mosip/esignet). +2. Unzip the contents to your local machine. +3. Open a terminal (Linux) or command prompt (Windows) and continue with the following steps. + +### From Git Bash + +1. Copy the Git repository URL: `https://github.com/mosip/esignet` +2. Open **Git Bash** on your local machine. +3. Run the following command to clone the repository: + ```sh + git clone https://github.com/mosip/esignet + ``` + +## Build Test Automation Code + +Once the repository is cloned or downloaded, follow these steps to build and install the test automation code: + +1. Navigate to the project directory: + ```sh + cd apitest + ``` + +2. Build the project using Maven: + ```sh + mvn clean install -Dgpg.skip=true -Dmaven.gitcommitid.skip=true + ``` + +This will download the required dependencies and prepare the test suite for execution. + +## Execute Test Automation Suite + +To execute the tests, use the following steps: + +1. Navigate to the `target` directory where the JAR file is generated: + ```sh + cd target/ + ``` + +2. Run the automation test suite JAR file: + ```sh + java -jar -Dmodules=esignet -Denv.user=api-internal. -Denv.endpoint= -Denv.testLevel=smokeAndRegression -jar apitest-esignet-1.5.0-SNAPSHOT-jar-with-dependencies.jar + ``` + +### Details of Arguments Used + +- **env.user**: The user of the environment where the tests will be executed. +- **env.endpoint**: The environment where the application under test is deployed. Replace `` with the actual environment hostname. +- **env.testLevel**: Set this to `smoke` to run only smoke test cases, or `smokeAndRegression` to run both smoke and regression tests. +- **jar**: Specify the name of the JAR file to execute. The version will change according to the development code version. For example, the current version may look like `automationtests-1.2.0.1-SNAPSHOT-jar-with-dependencies.jar`. + +## Build and Run + +To run the tests for both **Smoke** and **Regression**: + +1. Ensure the correct environment and test level parameters are set. +2. Execute the tests as shown in the command above to validate eSignet's API functionalities. + +## License + +This project is licensed under the terms of the [Mozilla Public License 2.0] \ No newline at end of file From c4ce47470ff10fdfa1ab9e06e5e8070e445d0a12 Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Wed, 13 Nov 2024 15:37:15 +0530 Subject: [PATCH 2/8] MOSIP-37214 Signed-off-by: Nandhukumar --- api-test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-test/README.md b/api-test/README.md index 53b70877d..992d43cfb 100644 --- a/api-test/README.md +++ b/api-test/README.md @@ -86,7 +86,7 @@ To execute the tests, use the following steps: - **env.user**: The user of the environment where the tests will be executed. - **env.endpoint**: The environment where the application under test is deployed. Replace `` with the actual environment hostname. - **env.testLevel**: Set this to `smoke` to run only smoke test cases, or `smokeAndRegression` to run both smoke and regression tests. -- **jar**: Specify the name of the JAR file to execute. The version will change according to the development code version. For example, the current version may look like `automationtests-1.2.0.1-SNAPSHOT-jar-with-dependencies.jar`. +- **jar**: Specify the name of the JAR file to execute. The version will change according to the development code version. For example, the current version may look like `apitest-esignet-1.5.0-SNAPSHOT-jar-with-dependencies.jar`. ## Build and Run From 4c1d0c04dc478929649746fbfb971090df06e76c Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Wed, 13 Nov 2024 22:46:09 +0530 Subject: [PATCH 3/8] MOSIP-37214 Signed-off-by: Nandhukumar --- .../resources/esignet/BioAuthIdp/BioAuthIdentityEncrypt.hbs | 2 -- .../Consent/AuthenticateUserConsent/AuthenticateUserConsent.yml | 1 + .../src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml | 2 +- .../esignet/SunBirdR/GetPolicySunBirdR/GetPolicySunBirdR.yml | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api-test/src/main/resources/esignet/BioAuthIdp/BioAuthIdentityEncrypt.hbs b/api-test/src/main/resources/esignet/BioAuthIdp/BioAuthIdentityEncrypt.hbs index 86a9d985c..d5666414d 100644 --- a/api-test/src/main/resources/esignet/BioAuthIdp/BioAuthIdentityEncrypt.hbs +++ b/api-test/src/main/resources/esignet/BioAuthIdp/BioAuthIdentityEncrypt.hbs @@ -1,5 +1,4 @@ { - "identityRequest": { "biometrics": [ { "data": { @@ -35,5 +34,4 @@ ], "timestamp": "$DATETIME$", "transactionID": "{{transactionId}}" - } } \ No newline at end of file diff --git a/api-test/src/main/resources/esignet/Consent/AuthenticateUserConsent/AuthenticateUserConsent.yml b/api-test/src/main/resources/esignet/Consent/AuthenticateUserConsent/AuthenticateUserConsent.yml index 84a12d7fb..7db08ce5f 100644 --- a/api-test/src/main/resources/esignet/Consent/AuthenticateUserConsent/AuthenticateUserConsent.yml +++ b/api-test/src/main/resources/esignet/Consent/AuthenticateUserConsent/AuthenticateUserConsent.yml @@ -186,6 +186,7 @@ AuthenticateUserConsent: restMethod: post checkErrorsOnlyInResponse: true validityCheckRequired: true + allowedErrorCodes: IDA-MLC-009,invalid_individual_id, inputTemplate: esignet/Consent/AuthenticateUserConsent/AuthenticateUserConsent outputTemplate: esignet/error input: '{ diff --git a/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml b/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml index 478dfd20d..ab21d84ab 100644 --- a/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml +++ b/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml @@ -19,7 +19,7 @@ OIDCClientV2: "userClaims3": "gender", "userClaims4": "phone_number", "userClaims5": "birthdate", - "authContextRefs": [{acrValues: "mosip:idp:acr:static-code"},{acrValues: "mosip:idp:acr:generated-code"},{acrValues: "mosip:idp:acr:biometrics"}], + "authContextRefs": [{acrValues: "mosip:idp:acr:static-code"},{acrValues: "mosip:idp:acr:generated-code"},{acrValues: "mosip:idp:acr:biometrics"},{acrValues: "mosip:idp:acr:password"},{acrValues: "mosip:idp:acr:linked-wallet"},{acrValues: "mosip:idp:acr:knowledge"},{acrValues: "mosip:idp:acr:id-token"}], "grantTypes": "authorization_code", "clientAuthMethods": "private_key_jwt", "keyLang1": "$1STLANG$", diff --git a/api-test/src/main/resources/esignet/SunBirdR/GetPolicySunBirdR/GetPolicySunBirdR.yml b/api-test/src/main/resources/esignet/SunBirdR/GetPolicySunBirdR/GetPolicySunBirdR.yml index 9180f864e..b19c5dc6a 100644 --- a/api-test/src/main/resources/esignet/SunBirdR/GetPolicySunBirdR/GetPolicySunBirdR.yml +++ b/api-test/src/main/resources/esignet/SunBirdR/GetPolicySunBirdR/GetPolicySunBirdR.yml @@ -1,5 +1,5 @@ GetPolicySunBirdR: - ESignet_SunBirdR_DeletePolicy_NOAUTH_Valid_Smoke: + ESignet_SunBirdR_GetPolicy_NOAUTH_Valid_Smoke: endPoint: $SUNBIRDBASEURL$/api/v1/Insurance/{insuranceid} description: To delete policy for SunBirdR with no authorization role: resident From 0ce6bdd42c093a22def0ef7cbd35a731555eca7a Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Thu, 14 Nov 2024 10:58:52 +0530 Subject: [PATCH 4/8] MOSIP-37214 Signed-off-by: Nandhukumar --- api-test/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-test/Dockerfile b/api-test/Dockerfile index ff6cb8945..9849f8524 100644 --- a/api-test/Dockerfile +++ b/api-test/Dockerfile @@ -1,4 +1,4 @@ -FROM mosipdev/openjdk-21-jre:latest +FROM mosipid/openjdk-21-jre:21.0.4 ARG SOURCE ARG COMMIT_HASH From e18656203983c21c14ee30c0095c4e233e319d0a Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Thu, 14 Nov 2024 12:41:36 +0530 Subject: [PATCH 5/8] MOSIP-37214 Signed-off-by: Nandhukumar --- api-test/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-test/Dockerfile b/api-test/Dockerfile index 9849f8524..ff6cb8945 100644 --- a/api-test/Dockerfile +++ b/api-test/Dockerfile @@ -1,4 +1,4 @@ -FROM mosipid/openjdk-21-jre:21.0.4 +FROM mosipdev/openjdk-21-jre:latest ARG SOURCE ARG COMMIT_HASH From 159390b267fc4ae3ec29f7e19f4dbb948c483cc4 Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Thu, 14 Nov 2024 13:31:25 +0530 Subject: [PATCH 6/8] MOSIP-37214 Signed-off-by: Nandhukumar --- api-test/README.md | 60 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/api-test/README.md b/api-test/README.md index 992d43cfb..7a42c5975 100644 --- a/api-test/README.md +++ b/api-test/README.md @@ -57,7 +57,7 @@ Once the repository is cloned or downloaded, follow these steps to build and ins 1. Navigate to the project directory: ```sh - cd apitest + cd api-test ``` 2. Build the project using Maven: @@ -69,7 +69,11 @@ This will download the required dependencies and prepare the test suite for exec ## Execute Test Automation Suite -To execute the tests, use the following steps: +You can execute the test automation code using either of the following methods: + +### Using Jar + +To execute the tests using Jar, use the following steps: 1. Navigate to the `target` directory where the JAR file is generated: ```sh @@ -77,14 +81,60 @@ To execute the tests, use the following steps: ``` 2. Run the automation test suite JAR file: - ```sh + ``` java -jar -Dmodules=esignet -Denv.user=api-internal. -Denv.endpoint= -Denv.testLevel=smokeAndRegression -jar apitest-esignet-1.5.0-SNAPSHOT-jar-with-dependencies.jar ``` +# Using Eclipse IDE + +## 1. **Install Eclipse (Latest Version)** + - Download and install the latest version of Eclipse IDE from the [Eclipse Downloads](https://www.eclipse.org/downloads/). + +## 2. **Import the Maven Project** + + After Eclipse is installed, follow these steps to import the Maven project: + + - Open Eclipse IDE. + - Go to `File` > `Import`. + - In the **Import** wizard, select `Maven` > `Existing Maven Projects`, then click **Next**. + - Browse to the location where the `api-test` folder is saved (either from the cloned Git repository or downloaded zip). + - Select the folder, and Eclipse will automatically detect the Maven project. Click **Finish** to import the project. + +## 3. **Build the Project** + + - Right-click on the project in the **Project Explorer** and select `Maven` > `Update Project`. + - This will download the required dependencies as defined in the `pom.xml` and ensure everything is correctly set up. + +## 4. **Run the Tests** + + To execute the test automation suite, you need to configure the run parameters in Eclipse: + + - Go to `Run` > `Run Configurations`. + - In the **Run Configurations** window, create a new configuration for your tests: + - Right-click on **Java Application** and select **New**. + - In the **Main** tab, select the project by browsing the location where the `api-test` folder is saved, and select the **Main class** as `io.mosip.testrig.apirig.esignet.testrunner.MosipTestRunner`. + - In the **Arguments** tab, add the necessary **VM arguments**: + - **VM Arguments**: + ``` + -Dmodules=esignet -Denv.user=api-internal. -Denv.endpoint= -Denv.testLevel=smokeAndRegression``` + +## 5. **Run the Configuration** + + - Once the configuration is set up, click **Run** to execute the test suite. + - The tests will run, and the results will be shown in the **Console** tab of Eclipse. + + **Note**: You can also run in **Debug Mode** to troubleshoot issues by setting breakpoints in your code and choosing `Debug` instead of `Run`. + +## 6. **View Test Results** + + - After the tests are executed, you can view the detailed results in the `api-test\testng-report` directory. + + + ### Details of Arguments Used -- **env.user**: The user of the environment where the tests will be executed. -- **env.endpoint**: The environment where the application under test is deployed. Replace `` with the actual environment hostname. +- **env.user**: Replace `` with the appropriate environment name (e.g., `dev`, `qa`, etc.). +- **env.endpoint**: The environment where the application under test is deployed. Replace `` with the correct base URL for the environment (e.g., `https://api-internal..mosip.net`). - **env.testLevel**: Set this to `smoke` to run only smoke test cases, or `smokeAndRegression` to run both smoke and regression tests. - **jar**: Specify the name of the JAR file to execute. The version will change according to the development code version. For example, the current version may look like `apitest-esignet-1.5.0-SNAPSHOT-jar-with-dependencies.jar`. From bb78dd7a9894a224941c073d832ad37578c7f6ec Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Thu, 14 Nov 2024 16:41:06 +0530 Subject: [PATCH 7/8] MOSIP-37214 Signed-off-by: Nandhukumar --- api-test/README.md | 2 ++ .../src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api-test/README.md b/api-test/README.md index 7a42c5975..21b3435b1 100644 --- a/api-test/README.md +++ b/api-test/README.md @@ -87,6 +87,8 @@ To execute the tests using Jar, use the following steps: # Using Eclipse IDE +To execute the tests using Eclipse IDE, use the following steps: + ## 1. **Install Eclipse (Latest Version)** - Download and install the latest version of Eclipse IDE from the [Eclipse Downloads](https://www.eclipse.org/downloads/). diff --git a/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml b/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml index ab21d84ab..d09126466 100644 --- a/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml +++ b/api-test/src/main/resources/esignet/OIDCClientV2/OIDCClientV2.yml @@ -50,7 +50,7 @@ OIDCClientV2: "userClaims3": "gender", "userClaims4": "phone_number", "userClaims5": "birthdate", - "authContextRefs": [{acrValues: "mosip:idp:acr:static-code"},{acrValues: "mosip:idp:acr:generated-code"},{acrValues: "mosip:idp:acr:biometrics"}], + "authContextRefs": [{acrValues: "mosip:idp:acr:static-code"},{acrValues: "mosip:idp:acr:generated-code"},{acrValues: "mosip:idp:acr:biometrics"},{acrValues: "mosip:idp:acr:password"},{acrValues: "mosip:idp:acr:linked-wallet"},{acrValues: "mosip:idp:acr:knowledge"},{acrValues: "mosip:idp:acr:id-token"}], "grantTypes": "authorization_code", "clientAuthMethods": "private_key_jwt", "keyLang1": "$1STLANG$", From 09d83d2237b56cbb5bfa5bc975180caf6b9c7791 Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Fri, 15 Nov 2024 08:56:36 +0530 Subject: [PATCH 8/8] MOSIP-37214 Signed-off-by: Nandhukumar --- .../LinkedAuthenticationWla/LinkedAuthenticationWla.yml | 2 +- .../LinkedAuthorizationConsent.yml | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/api-test/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml b/api-test/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml index 53b93a3ba..ae7be5d5c 100644 --- a/api-test/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml +++ b/api-test/src/main/resources/esignet/LinkedAuthenticationWla/LinkedAuthenticationWla.yml @@ -144,7 +144,7 @@ LinkedAuthenticationWla: } }' output: '{ - "consentAction": "NOCAPTURE", + "consentAction": "CAPTURE", "sendOtpResp":{ "maskedMobile": "$IGNORE$", "sendOtpResTemplate":"esignet/SendBindingOtp/SendBindingOtpResult", diff --git a/api-test/src/main/resources/esignet/LinkedAuthorizationConsent/LinkedAuthorizationConsent.yml b/api-test/src/main/resources/esignet/LinkedAuthorizationConsent/LinkedAuthorizationConsent.yml index 21ba8b1b3..e289def93 100644 --- a/api-test/src/main/resources/esignet/LinkedAuthorizationConsent/LinkedAuthorizationConsent.yml +++ b/api-test/src/main/resources/esignet/LinkedAuthorizationConsent/LinkedAuthorizationConsent.yml @@ -37,7 +37,7 @@ LinkedAuthorizationConsent: }' - ESignet_LinkedAuthorizationConsent_Consent_uin_User2_Neg: + ESignet_LinkedAuthorizationConsent_Consent_uin_User2: endPoint: /v1/esignet/linked-authorization/v2/consent description: Linked authorization consent with User2 UIN role: resident @@ -45,7 +45,7 @@ LinkedAuthorizationConsent: restMethod: post validityCheckRequired: true inputTemplate: esignet/LinkedConsent/LinkAuthorizationConsent/LinkAuthorizationConsent - outputTemplate: esignet/error + outputTemplate: esignet/LinkedAuthorizationConsent/LinkedAuthorizationConsentResult input: '{ "requestTime": "$TIMESTAMP$", "linkedTransactionId": "$ID:LinkTransaction_Consent_uin_User2_all_Valid_Smoke_sid_linkTransactionId$", @@ -53,11 +53,6 @@ LinkedAuthorizationConsent: "signature": "$CONSENTDETACHEDSIGNATUREUSER2$" }' output: '{ - "errors": [ - { - "errorCode": "invalid_transaction" - } - ] }' ESignet_LinkedAuthorizationConsent_Consent_Vid_User2_Neg: