Skip to content

Commit

Permalink
Merge branch 'mosip:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanachandran-s authored Nov 27, 2024
2 parents 7566893 + a8d44e6 commit 0fd4acf
Show file tree
Hide file tree
Showing 25 changed files with 313 additions and 130 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ Pre-registration module consists of the following services:
5. Capthca

## Database
See [DB guide](db_scripts/README.md)
See [DB guide](db_scripts)

## Config-Server
To run Pre-registration services, run [Config Server](https://docs.mosip.io/1.2.0/modules/module-configuration#config-server)

## Build & run (for developers)
Prerequisites:
1. [Config Server](https://docs.mosip.io/1.2.0/modules/module-configuration#config-server)
1. JDK 21 and Java21 Artifactory Jars [here](https://oss.sonatype.org/content/repositories/snapshots/io/mosip/)
1. Build and install:
2. The project requires JDK 21.0.3 and mvn version - 3.9.6
3. Build and install:
```
$ cd kernel
$ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip=true
```
1. Build Docker for a service:
4. Build Docker for a service:
```
$ cd <service folder>
$ docker build -f Dockerfile
Expand Down Expand Up @@ -54,14 +54,17 @@ Prerequisites:
$ ./restart.sh
```
## Deploy
To deploy services on Kubernetes cluster using Dockers refer to [Sandbox Deployment](https://docs.mosip.io/1.2.0/deploymentnew/v3-installation).
## Configuration
Refer to the [configuration guide](docs/configuration.md).
## Test
Automated functional tests available in [Functional Tests repo](https://github.com/mosip/mosip-functional-tests).
Automated functional tests available in [Functional Tests repo](api-test).
## APIs
API documentation is available [here](https://mosip.github.io/documentation/).
API documentation is available [here](https://mosip.github.io/documentation/1.2.0/1.2.0.html).
## License
This project is licensed under the terms of [Mozilla Public License 2.0](LICENSE).
Expand Down
4 changes: 2 additions & 2 deletions api-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mosipdev/openjdk-21-jre:latest
FROM mosipid/openjdk-21-jre:21.0.4

ARG SOURCE
ARG COMMIT_HASH
Expand Down Expand Up @@ -54,4 +54,4 @@ ENV ENV_USER=
ENV ENV_ENDPOINT=
ENV ENV_TESTLEVEL=smokeAndRegression

ENTRYPOINT ["./entrypoint.sh"]
ENTRYPOINT ["./entrypoint.sh"]
153 changes: 151 additions & 2 deletions api-test/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,152 @@
# Automation test
# Pre Registration API Test Rig

All automation test code.
## Overview

The **Pre Registration API Test Rig** is designed for the execution of module-wise automation API tests for the pre-registration services. This test rig utilizes **Java REST Assured** and **TestNG** frameworks to automate testing of the pre-registration API functionalities. The key focus is to validate the pre-registration creation, appointment booking and related functionalities provided by the pre-registration 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 admin services 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/pre-registration).
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/pre-registration`
2. Open **Git Bash** on your local machine.
3. Run the following command to clone the repository:
```sh
git clone https://github.com/mosip/pre-registration
```

## 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=prereg -Denv.user=api-internal.<env_name> -Denv.endpoint=<base_env> -Denv.testLevel=smokeAndRegression -jar apitest-prereg-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.esignet.testrunner.MosipTestRunner`.
- In the **Arguments** tab, add the necessary **VM arguments**:
- **VM Arguments**:
```
-Dmodules=prereg -Denv.user=api-internal.<env_name> -Denv.endpoint=<base_env> -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**: Replace `<env_name>` with the appropriate environment name (e.g., `dev`, `qa`, etc.).
- **env.endpoint**: The environment where the application under test is deployed. Replace `<base_env>` with the correct base URL for the environment (e.g., `https://api-internal.<env_name>.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-prereg-1.3.0-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 admin services API functionalities.
## License
This project is licensed under the terms of the [Mozilla Public License 2.0]
2 changes: 1 addition & 1 deletion api-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>
io.mosip.testrig.apirig.testrunner.MosipTestRunner</mainClass>
io.mosip.testrig.apirig.prereg.testrunner.MosipTestRunner</mainClass>
</transformer>
</transformers>
<!-- add this to prevent some security issues when
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.testrig.apirig.testrunner;
package io.mosip.testrig.apirig.prereg.testrunner;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -22,6 +22,11 @@
import com.nimbusds.jose.jwk.KeyUse;
import com.nimbusds.jose.jwk.RSAKey;

import io.mosip.testrig.apirig.prereg.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.ExtractResource;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.testrunner.OTPListener;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthTestsUtil;
import io.mosip.testrig.apirig.utils.CertsUtil;
Expand All @@ -33,7 +38,6 @@
import io.mosip.testrig.apirig.utils.MispPartnerAndLicenseKeyGeneration;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PartnerRegistration;
import io.mosip.testrig.apirig.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.utils.SkipTestCaseHandler;

/**
Expand Down Expand Up @@ -75,6 +79,7 @@ public static void main(String[] arg) {
suiteSetup(getRunType());
SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt");
setLogLevels();
AdminTestUtil.getRequiredField();

// For now we are not doing health check for qa-115.
if (BaseTestCase.isTargetEnvLTS()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.testrig.apirig.testscripts;
package io.mosip.testrig.apirig.prereg.testscripts;

import java.lang.reflect.Field;
import java.util.List;
Expand All @@ -23,6 +23,8 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.prereg.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.prereg.utils.PreRegUtil;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
Expand All @@ -31,8 +33,6 @@
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.KernelAuthentication;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.utils.PreRegUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.mosip.testrig.apirig.utils.RestClient;
import io.restassured.response.Response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.testrig.apirig.testscripts;
package io.mosip.testrig.apirig.prereg.testscripts;

import java.lang.reflect.Field;
import java.util.List;
Expand All @@ -23,6 +23,8 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.prereg.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.prereg.utils.PreRegUtil;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
Expand All @@ -31,8 +33,6 @@
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.KernelAuthentication;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.utils.PreRegUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.mosip.testrig.apirig.utils.RestClient;
import io.restassured.response.Response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.testrig.apirig.testscripts;
package io.mosip.testrig.apirig.prereg.testscripts;

import java.lang.reflect.Field;
import java.security.NoSuchAlgorithmException;
Expand All @@ -24,6 +24,8 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.prereg.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.prereg.utils.PreRegUtil;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
Expand All @@ -32,8 +34,6 @@
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.utils.PreRegUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

Expand Down Expand Up @@ -95,7 +95,7 @@ public void test(TestCaseDTO testCaseDTO)
String[] templateFields = testCaseDTO.getTemplateFields();

String jsonInput = testCaseDTO.getInput();

testCaseName = isTestCaseValidForExecution(testCaseDTO);
String inputJson = getJsonFromTemplate(jsonInput, testCaseDTO.getInputTemplate(), false);
String outputJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.testrig.apirig.testscripts;
package io.mosip.testrig.apirig.prereg.testscripts;

import java.lang.reflect.Field;
import java.util.ArrayList;
Expand All @@ -22,15 +22,15 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.prereg.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.prereg.utils.PreRegUtil;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.utils.PreRegUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.mosip.testrig.apirig.testscripts;
package io.mosip.testrig.apirig.prereg.testscripts;

import java.lang.reflect.Field;
import java.util.ArrayList;
Expand All @@ -22,15 +22,15 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.prereg.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.prereg.utils.PreRegUtil;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PreRegConfigManager;
import io.mosip.testrig.apirig.utils.PreRegUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

Expand Down
Loading

0 comments on commit 0fd4acf

Please sign in to comment.