From 096a0b785a583925719011e94570766e068815b7 Mon Sep 17 00:00:00 2001 From: Nandhukumar <100744358+nandhu-kumar@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:41:15 +0530 Subject: [PATCH] MOSIP-38311 | synced latest changes from develop (#1374) * MOSIP-38311 Signed-off-by: Nandhukumar * MOSIP-38311 Signed-off-by: Nandhukumar --------- Signed-off-by: Nandhukumar --- api-test/README.md | 174 +++++++++++++++++- api-test/pom.xml | 8 +- .../resident/testrunner/MosipTestRunner.java | 10 +- .../config/idrepoCertDataDeleteQueries.txt | 3 + .../resident/AddIdentity/AddIdentity.yml | 60 +++--- 5 files changed, 216 insertions(+), 39 deletions(-) create mode 100644 api-test/src/main/resources/config/idrepoCertDataDeleteQueries.txt diff --git a/api-test/README.md b/api-test/README.md index 51b6226796a..b3af76a8d16 100644 --- a/api-test/README.md +++ b/api-test/README.md @@ -1,3 +1,173 @@ -# Automation test +# Resident API Test Rig -All automation test code. +## Overview + +The **Resident API Test Rig** is designed for the execution of module-wise automation API tests for the resident services. This test rig utilizes **Java REST Assured** and **TestNG** frameworks to automate testing of the resident-service API functionalities. The key focus is to validate the VID Generation, Auth lock, Auth unlock, Identity Management and related functionalities provided by the resident service 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 resident services module. + +--- + +## Pre-requisites + +Before running the automation tests, ensure the following software is installed on the machine: + +- **Java 21** ([download here](https://jdk.java.net/)) +- **Maven 3.9.6** or higher ([installation guide](https://maven.apache.org/install.html)) +- **Lombok** (Refer to [Lombok Project](https://projectlombok.org/)) +- **setting.xml** ([download here](https://github.com/mosip/mosip-functional-tests/blob/master/settings.xml)) +- **apitest-commons** library should be cloned and the JAR should be built. Refer to ([README](https://github.com/mosip/mosip-functional-tests/blob/release-1.3.0/apitest-commons/README.md)) + +### 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/resident-services). +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/resident-services` +2. Open **Git Bash** on your local machine. +3. Run the following command to clone the repository: + ```sh + git clone https://github.com/mosip/resident-services + ``` + +--- + +## 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 api-test + ``` + +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 + +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 + cd target/ + ``` + +2. Run the automation test suite JAR file: + ``` + java -jar -Dmodules=resident -Denv.user=api-internal. -Denv.endpoint= -Denv.testLevel=smokeAndRegression -jar apitest-resident-1.3.0-SNAPSHOT-jar-with-dependencies.jar + ``` + +# 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/). + +## 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.resident.testrunner.MosipTestRunner`. + - In the **Arguments** tab, add the necessary **VM arguments**: + - **VM Arguments**: + ``` + -Dmodules=resident -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. + - Two reports will gets generated + - First report is for pre-requisite testcases + - Second report is for core testcases + +--- + +## Details of Arguments Used + +- **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-resident-1.3.0-SNAPSHOT-jar-with-dependencies.jar`. + +### Build and Run Info + +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 resident services API functionalities. + +--- + +## License + +This project is licensed under the terms of the [Mozilla Public License 2.0](https://github.com/mosip/mosip-platform/blob/master/LICENSE) diff --git a/api-test/pom.xml b/api-test/pom.xml index 3ee4368477d..39c67982bd2 100644 --- a/api-test/pom.xml +++ b/api-test/pom.xml @@ -8,7 +8,7 @@ apitest-resident Parent project of MOSIP Resident Services apitests https://github.com/mosip/resident-services - 1.2.1-SNAPSHOT + 1.3.0-SNAPSHOT @@ -49,14 +49,14 @@ 2.2.1 3.0.1 - apitest-resident-1.2.1-SNAPSHOT-jar-with-dependencies + apitest-resident-1.3.0-SNAPSHOT-jar-with-dependencies - io.mosip.testrig.apirig.apitest.commons + io.mosip.testrig.apitest.commons apitest-commons - 1.2.2-SNAPSHOT + 1.3.0 diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/resident/testrunner/MosipTestRunner.java b/api-test/src/main/java/io/mosip/testrig/apirig/resident/testrunner/MosipTestRunner.java index fa83026ef26..bc5d9307487 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/resident/testrunner/MosipTestRunner.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/resident/testrunner/MosipTestRunner.java @@ -136,13 +136,17 @@ public static void suiteSetup(String runType) { BaseTestCase.certsForModule = GlobalConstants.RESIDENT; DBManager.executeDBQueries(ResidentConfigManager.getKMDbUrl(), ResidentConfigManager.getKMDbUser(), ResidentConfigManager.getKMDbPass(), ResidentConfigManager.getKMDbSchema(), - getGlobalResourcePath() + "/" + "config/keyManagerDataDeleteQueriesForEsignet.txt"); + getGlobalResourcePath() + "/" + "config/keyManagerCertDataDeleteQueries.txt"); DBManager.executeDBQueries(ResidentConfigManager.getIdaDbUrl(), ResidentConfigManager.getIdaDbUser(), ResidentConfigManager.getPMSDbPass(), ResidentConfigManager.getIdaDbSchema(), - getGlobalResourcePath() + "/" + "config/idaDeleteQueriesForEsignet.txt"); + getGlobalResourcePath() + "/" + "config/idaCertDataDeleteQueries.txt"); DBManager.executeDBQueries(ResidentConfigManager.getMASTERDbUrl(), ResidentConfigManager.getMasterDbUser(), ResidentConfigManager.getMasterDbPass(), ResidentConfigManager.getMasterDbSchema(), - getGlobalResourcePath() + "/" + "config/masterDataDeleteQueriesForEsignet.txt"); + getGlobalResourcePath() + "/" + "config/masterDataCertDataDeleteQueries.txt"); + + DBManager.executeDBQueries(ResidentConfigManager.getIdRepoDbUrl(), ResidentConfigManager.getIdRepoDbUser(), + ResidentConfigManager.getPMSDbPass(), "idrepo", + getGlobalResourcePath() + "/" + "config/idrepoCertDataDeleteQueries.txt"); AdminTestUtil.copyResidentTestResource(); BaseTestCase.otpListener = new OTPListener(); BaseTestCase.otpListener.run(); diff --git a/api-test/src/main/resources/config/idrepoCertDataDeleteQueries.txt b/api-test/src/main/resources/config/idrepoCertDataDeleteQueries.txt new file mode 100644 index 00000000000..f6333031281 --- /dev/null +++ b/api-test/src/main/resources/config/idrepoCertDataDeleteQueries.txt @@ -0,0 +1,3 @@ +##### DB queries to be executed to tear down the data used and generated during the test rig run + +delete from idrepo.handle WHERE cr_by ='service-account-mosip-testrig-client' \ No newline at end of file diff --git a/api-test/src/main/resources/resident/AddIdentity/AddIdentity.yml b/api-test/src/main/resources/resident/AddIdentity/AddIdentity.yml index 11803d6dc3a..d37b4d5a5e2 100644 --- a/api-test/src/main/resources/resident/AddIdentity/AddIdentity.yml +++ b/api-test/src/main/resources/resident/AddIdentity/AddIdentity.yml @@ -3,7 +3,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -33,7 +33,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with the maximum email characters and valid parameters - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -63,7 +63,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -93,7 +93,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity in a positive manner - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -123,7 +123,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity in a positive manner to expire the Perpetual VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -153,7 +153,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add the identity in a positive manner to deactivate the perpetual VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -183,7 +183,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add the identity in a positive manner to deactivate the Temporary VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -213,7 +213,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add the identity in a positive manner to reactivate the perpetual VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -243,7 +243,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add the identity in a positive manner to reactivate the temporary VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -274,7 +274,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity using valid parameters - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -306,7 +306,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity using valid parameters ensuring that the user is successfully added - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -338,7 +338,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Adding new identity using valid parameters and verifies the channel - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -370,7 +370,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity using valid parameters for revoke VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -401,7 +401,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Integrate Esignet functionality while adding a new identity - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -432,7 +432,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Integrate VID within Esignet functionality while adding a new identity - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -463,7 +463,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity in a positive manner while retrieving RID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -494,7 +494,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity in a positive manner while updating count - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -525,7 +525,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity in a positive manner for expired OTP functionality - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -556,7 +556,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with VID positively for the expired OTP functionality - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -587,7 +587,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with temporary VID in a positive manner the expired OTP functionality - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -618,7 +618,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with onetime VID in a positive manner the expired OTP functionality - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -649,7 +649,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity in a positive manner with valid order status - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -680,7 +680,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with an invalid scenario and VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -711,7 +711,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with an invalid DOB - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/error @@ -746,7 +746,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Adding identity with valid parameters to generate a VID under the Six scenario - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -777,7 +777,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters in a positive manner to create perpetual VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -808,7 +808,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters in a positive manner to create three perpetual VID - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -839,7 +839,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters to generate a temporary VID using the Use 3 method - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -870,7 +870,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters to send OTP - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult @@ -901,7 +901,7 @@ AddIdentity: endPoint: /idrepository/v1/identity/ uniqueIdentifier: Dependent_Idrepo description: Add identity with valid parameters to check ten transactions - role: idrepo + role: testrig restMethod: post inputTemplate: resident/AddIdentity/addIdentity_$LANGNUMBER$ outputTemplate: resident/AddIdentity/addIdentityResult