Skip to content

Commit

Permalink
Merge branch '1.2.0-rc2' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohandey authored Jan 27, 2022
2 parents dc28083 + 32e32d3 commit e7e6d80
Show file tree
Hide file tree
Showing 14 changed files with 536 additions and 195 deletions.
89 changes: 73 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,79 @@
### Contains
1. Test automation code
2. Test cases in form of JSON files
3. Sample test data
4. Procedure to build and run it.
# Functional Tests

### How to build
Follow the steps in https://github.com/mosip/mosip-functional-tests/blob/master/automationtests/README.md
## Overview
This repo contains API automation test rig. The automation written using Java REST Assured and TestNG framework. The following modules are covered:
1. Pre-registration
1. Masterdata
1. Partner Management
1. ID Repository
1. IDA
1. Resident

### Reources
[Tester Documentation](https://github.com/mosip/mosip-docs/wiki/Tester-Documentation) contains complete information regarding the test rig code and design.
The test rig has multi-language support - input can be provided in any of the languages configured in a given MOSIP installation.

### How to contribute
You can contribute to MOSIP! If you see a problem, or have inputs on how we can improve, please see the [Contributor Guide](https://github.com/mosip/mosip-docs/wiki/Contributor-Guide) on how to file bugs, contribute code, and more.
## Test categories
* Smoke: only positive scenarios.
* Regression: all scenarios.

### License
This project is licensed under the terms of [Mozilla Public License 2.0](https://github.com/mosip/mosip-platform/blob/master/LICENSE)
## Coverage
Only external API endpoints are covered.

## Pre-requisites:
1. Java 11 and Maven (3.6.0) software should be installed on the machine from where the automation tests will be executed
2. Lombok should be configured. Ref. https://projectlombok.org/

### For Windows
1. Git bash (2.18.0.windows.1)
2. `settings.xml` needs to be present in one place in `.\m2`.

### For Linux
1. `settings.xml` file needs to be present in two places:
* regular maven conf folder
* copy the same settings.xml under /usr/local/maven/conf

## Access test automation code
1. From Browser:
* ‘Clone or download’ https://github.com/mosip/mosip-functional-tests as zip
* Unzip the contents
* Continue with below steps from a terminal (Linux) or command prompt (Windows)

2. From Git Bash:
* Copy the git link i.e "https://github.com/mosip/mosip-functional-tests"
* On your local sytem, gitbash at any location
* Run the "git clone https://github.com/mosip/mosip-functional-tests" command

```
cd automationtests
```

## Build Test Automation Code

### Communication
Join the [developer mailing list](https://groups.io/g/mosip-dev)
```
mvn clean install
```
This creates the jar file in the ‘target’ folder

You may also be interested in joining our community room on Gitter via [![Gitter](https://badges.gitter.im/mosip-community/community.svg)](https://gitter.im/mosip-community/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) where you could get some great community support
## Execute Test Automation Suite

Execute the jar from the target folder on the application code deployed. In this example, the application code is run on <base_env>

### Command to use:
```
cd target/
java -jar -Dmodules=prereg -Denv.user=dev2 -Denv.endpoint= <base_env> -Denv.langcode=eng,ara,fra -Denv.testLevel=smokeAndRegression automationtests-1.2.0-SNAPSHOT-jar-with-dependencies.jar
```
### Details of the arguments used
* env.user = user of the env on which you will run the jar file.
* env.endpoint = env where the application under test is deployed. Change the env hostname from <base_env> to any env that you will work on
* env.testlevel = this parameter has to be ‘smoke’ to run only smoke test cases, and it has to be ‘smokeandRegression’ to run all tests of all modules
* env.langcode = languages which are configured in the env.
* jar = specify the jar file to be executed
* The version of the jar file name changes as per development code version.
Example: Current version of Dev Code Base is 1.2.0 so the jar name will be automationtests-1.2.0-SNAPSHOT-jar-with-dependencies.jar

## Build and run

* Run smoke and regression

## License
This project is licensed under the terms of [Mozilla Public License 2.0](https://github.com/mosip/mosip-platform/blob/master/LICENSE)
107 changes: 3 additions & 104 deletions authentication-demo-service/README.md
Original file line number Diff line number Diff line change
@@ -1,107 +1,6 @@
# ID-Authentication Partner Demo Serivce
This is a helper service module that can used for ID-Authentication functional testing. This exposes many helper services such as:
1. Creating Auth Request for creating request body of Partner Authentication, Internal Authentication and KYC Authenication request.
2. Encrypt/Decrypt data using Mosip Public which will internally call the Mosip-Kernel-CryptoManager service.
3. Encode/Decode data - to do base-64-url encoding/decoding
4. Encode/Decode from/to file - to do base-64-url encoding/decoding
5. JWS Sign/Verify
# Authentication Demo Service

## Create Auth Request Service
This service can be used for creating requrest body of Partner Authentication, Internal Authentication and KYC Authenication request.
## Overview
Demo authentication service used by automation tests.

*POST /createAuthRequest?id=5879610697&idType=UIN&isInternal=false&isKyc=false*

For example:
http://localhost:8081/v1/identity/createAuthRequest?id=5879610697&idType=UIN&isInternal=false&isKyc=false

### Sample Request Body:
````
{
"otp": "123456",
"biometrics": [{
"data": {
"bioSubType": "UNKNOWN",
"bioType": "FIR",
"bioValue": "RklSADAyMAAAAC6AAAEBAQAALnAH4wsIETkBAeMAAAAAAAFZAEAADwIAQAIAQAIHAAEB9AH0AfQB9AgFHQEfAZ0AAC3",
"deviceCode": "2a4af583-da31-4800-8cb9-9340643fd1bf",
"deviceProviderID": "SYNCBYTE.LTC163",
"deviceServiceID": "",
"deviceServiceVersion": "SB.WIN.001",
"digitalId": {
"dateTime": "2019-12-05T10:41:15.052Z",
"deviceProvider": "SYNCBYTE",
"deviceProviderId": "SYNCBYTE.LTC163",
"make": "Logitech",
"model": "4d36e96c-e325-11ce-bfc1-08002be10316",
"serialNo": "78467169",
"subType": "Slab",
"type": "Finger"
},
"env": "Staging",
"mosipProcess": "Auth",
"qualityScore": 70,
"requestedScore": 70,
"timestamp": "2019-12-05T10:41:15.070Z",
"transactionId": "1234567890"
}
},
{
"data": {
"bioSubType": "FACE",
"bioType": "FACE",
"bioValue": "RkFDADAzMAAAAFo7AAEAAAAAAFoqB+MKHQ4mDwAPAAAAAAABAAEDAQMAAAAAAAAAAAAAAAAAAAAAAAACAPABQAAAAQAAAABZ",
"deviceCode": "b8c72d1b-2120-4d48-a72d-f75db4a2dd04",
"deviceProviderID": "SYNCBYTE.LTC165",
"deviceServiceID": "",
"deviceServiceVersion": "SB.WIN.001",
"digitalId": {
"dateTime": "2019-12-05T10:44:07.526Z",
"deviceProvider": "SYNCBYTE",
"deviceProviderId": "SYNCBYTE.LTC165",
"make": "Logitech",
"model": "4d36e96c-e325-11ce-bfc1-08002be10318",
"serialNo": "78467171",
"subType": "Full face",
"type": "Face"
},
"env": "Staging",
"mosipProcess": "Auth",
"qualityScore": 70,
"requestedScore": 70,
"timestamp": "2019-12-05T10:43:46.986Z",
"transactionId": "1234567890"
}
}
],
"timestamp": "2019-04-04T09:41:57.086+05:30",
"transactionID": "1234567890"
}
````

### Sample Response: Created Auth Request
````
{
"consentObtained": true,
"id": "mosip.identity.auth",
"individualId": "5879610697",
"individualIdType": "UIN",
"keyIndex": "string",
"request": "a35TsKHPgYAO5VjojI1ESZ7dQp616YnWs34nN05lLOwSNDPEhj",
"requestHMAC": "RLtdlzViKi5siX2y52tMWkvDKPMZtrtyGLO2m9B7JkvnZx",
"requestSessionKey": "nbLnLF0yLi4ggO3l0F54uE9FWwx6R9WRQtoTAzKn",
"requestTime": "2019-12-05T12:46:47.085Z",
"requestedAuth": {
"bio": true,
"demo": false,
"otp": true,
"pin": false
},
"transactionID": "1234567890",
"version": "1.0"
}
````

### Reference
The complete reference of the ID-Authentication Partner Demo services can be viewed in below link (assuming it is launched in localhost:8081)

http://localhost:8081/v1/identity/v2/api-docs
71 changes: 2 additions & 69 deletions automationtests/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,3 @@
# Automationtests
This readme provides detailed steps to build and execute the AUTOMATION TEST SUITE for sanity testing of the MOSIP platform. It can be run after successful deployment of the platform code.

## Pre-requisites:
For Windows
1. Java (8 or above) and Maven (3.6.0) software should be installed on the machine from where the automation tests will be executed
2. Git bash (2.18.0.windows.1)
3. settings.xml needs to be present in one place
* regular maven conf folder

For Linux
1. Assume Java (8 or above), Maven (3.6.0) and Git softwares are available
2. settings.xml file needs to be present in two places
* regular maven conf folder
* copy the same settings.xml under /usr/local/maven/conf

DB Properties Change
Update the following configuration files under the automationtests/src/main/resources folder for the DB details; DB url, username, password as appropriate
* auditqa.cfg.xml
* kernelqa.cfg.xml
* masterdataqa.cfg.xml
* preregqa.cfg.xml
* regproc.cfg.xml
* idaqa.cfg.xml

### 1. Access Test Automation Code
From Browser:
- ‘Clone or download’ https://github.com/mosip/mosip-functional-tests as zip
- Unzip the contents
- Continue with below steps from a terminal (Linux) or command prompt (Windows)

From Git Bash:
- Copy the git link i.e "https://github.com/mosip/mosip-functional-tests"
- On your local sytem, gitbash at any location
- Run the "git clone https://github.com/mosip/mosip-functional-tests" command

Make sure pom.xml file lists all the dependencies, as it is used to build the automation code.
Edit the pom.xml for the latest version of mosip platform Eg: <version>0.12.16</version>

**Command to use:**
<br>_cd automationtests_<br>

### 2. Build Test Automation Code
**Command to use:**
<br>_mvn clean install_<br>

This creates the jar file in the ‘target’ folder

### 3. Execute Test Automation Suite
Execute the jar from the target folder on the application code deployed. In this example, the application code is run on <base_env>

**Command to use:**
<br>_cd target/_<br>

_java -Denv.user=qa -Denv.endpoint=<base_env> -Denv.testLevel=smoke -jar automationtests-refactor-0.12.16-jar-with-dependencies.jar_

**Details of the arguments used**

_env.user_ = user of the env on which you will run the jar file. Change ‘qa’ to a valid user id on the test env.

_env.endpoint_ = env where the application under test is deployed. Change the env hostname from <base_env> to any env that you will work on

_env.testlevel_ = this parameter has to be ‘smoke’ to run only smoke test cases, and it has to be ‘smokeandRegression’ to run all tests of all modules, and it should be ‘regression’ to run all tests except smoke tests

_jar_ = specify the jar file to be executed

The version of the jar file name changes as per development code version.

Example: Current version of Dev [code base](https://github.com/mosip/mosip-platform) is 0.12.16 so the jar name will be automationtests-refactor-0.12.16-jar-with-dependencies.jar
# Automation test

All automation test code.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import io.mosip.kernel.util.Translator;
import io.mosip.service.BaseTestCase;
import io.mosip.testrunner.MosipTestRunner;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;


Expand Down Expand Up @@ -430,6 +431,63 @@ protected Response postWithFormDataAndFile(String url, String jsonInput, String
}
}

protected Response postWithMultipartFormDataAndFile(String url, String jsonInput, String cookieName, String role, String testCaseName,String idKeyName) {
Response response=null;

jsonInput = inputJsonKeyWordHandeler(jsonInput, testCaseName);
jsonInput = jsonInput.replace("\r\n", "");

HashMap<String, String> formParams = new HashMap<String, String>();
formParams.put("NotificationRequestDTO", jsonInput);
if(BaseTestCase.languageList.size()==1) formParams.put("langCode", BaseTestCase.languageList.get(0));
else if(BaseTestCase.languageList.size()==2) formParams.put("langCode", BaseTestCase.languageList.get(0)+","+BaseTestCase.languageList.get(1));
else formParams.put("langCode", BaseTestCase.languageList.get(0)+","+BaseTestCase.languageList.get(1)+","+BaseTestCase.languageList.get(2));
formParams.put("attachment", "");

/* String absolueFilePath = null; */
/*
* JSONArray josnArray = req.getJSONArray("files"); for (int index = 0; index <
* josnArray.length(); index++) { String csvFilePath = (String)
* josnArray.get(index); absolueFilePath = getResourcePath() + csvFilePath; if
* (formParams.get("category").equalsIgnoreCase("masterData")) { absolueFilePath
* = StringUtils.substringBefore(absolueFilePath, "FilesToUpload") +
* "FilesToUpload"; } }
*/
/*
* File file = new File(absolueFilePath); File[] listFiles = file.listFiles();
*/
/*
* for (File specificFile : listFiles) { if
* (formParams.get("operation").equalsIgnoreCase("insert") &&
* specificFile.getName().equals(formParams.get("tableName") + ".csv")) {
* specificFile=updateCSV(specificFile.getAbsolutePath(),"OLD",1,0); listFiles =
* new File[1]; listFiles[0] = specificFile; } else { if
* (formParams.get("operation").equalsIgnoreCase("update") &&
* specificFile.getName().equalsIgnoreCase("update" +
* formParams.get("tableName") + ".csv")) { listFiles = new File[1];
* listFiles[0] = specificFile; } } }
*/
token = kernelAuthLib.getTokenByRole(role);
logger.info("******Post request Json to EndPointUrl: " + url + " *******");
Reporter.log("<pre>" + ReportUtil.getTextAreaJsonMsgHtml(jsonInput) + "</pre>");

try {
response = RestClient.postWithMultipartFormDataAndFile(url, formParams,
MediaType.MULTIPART_FORM_DATA, token);
Reporter.log("<b><u>Actual Response Content: </u></b>(EndPointUrl: " + url + ") <pre>"
+ ReportUtil.getTextAreaJsonMsgHtml(response.asString()) + "</pre>");
if(testCaseName.toLowerCase().contains("_sid"))
{
writeAutoGeneratedId(response, idKeyName, testCaseName);
}

return response;
} catch (Exception e) {
logger.error("Exception " + e);
return response;
}
}

protected Response postWithFormDataAndMultipleFile(String url, String jsonInput, String cookieName, String role, String testCaseName,String idKeyName) {
Response response=null;
String inputJson = inputJsonKeyWordHandeler(jsonInput, testCaseName);
Expand Down Expand Up @@ -1091,7 +1149,13 @@ private String replaceIdWithAutogeneratedId(String jsonString, String idKey, Str
} catch (IOException e) {
logger.error("Exception while loading the autogenerated id: "+e.getMessage());
}
jsonString = jsonString.replace(keyToReplace, props.getProperty(keyForIdProperty));
if(keyForIdProperty.contains("time_slot_from")) {
String time = props.getProperty(keyForIdProperty);
if(time.compareTo("12:00")>=0) time+=" PM";
else time+=" AM";
jsonString = jsonString.replace(keyToReplace, time);
}else jsonString = jsonString.replace(keyToReplace, props.getProperty(keyForIdProperty));

jsonString =replaceIdWithAutogeneratedId(jsonString, idKey, autoGenIdFileName);
}
return jsonString;
Expand Down
Loading

0 comments on commit e7e6d80

Please sign in to comment.