Skip to content

Commit

Permalink
MOSIP-37547 incorporate new changes (#1059)
Browse files Browse the repository at this point in the history
* MOSIP-36647

Signed-off-by: Anup Nehe <[email protected]>

* MOSIP-37915

Signed-off-by: Anup Nehe <[email protected]>

* MOSIP-34116

Signed-off-by: Anup Nehe <[email protected]>

* MOSIP-37889

Signed-off-by: Anup Nehe <[email protected]>

* MOSIP-38558

Signed-off-by: Anup Nehe <[email protected]>

* reslove conflicts

Signed-off-by: Anup Nehe <[email protected]>

* resolve conflicts

Signed-off-by: Anup Nehe <[email protected]>

* resolve conflicts

Signed-off-by: Anup Nehe <[email protected]>

---------

Signed-off-by: Anup Nehe <[email protected]>
  • Loading branch information
anup-nehe authored Jan 2, 2025
1 parent a40a591 commit 5f4f6f2
Show file tree
Hide file tree
Showing 44 changed files with 392 additions and 247 deletions.
4 changes: 2 additions & 2 deletions api-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@

<dependencies>
<dependency>
<groupId>io.mosip.testrig.apirig.apitest.commons</groupId>
<groupId>io.mosip.testrig.apitest.commons</groupId>
<artifactId>apitest-commons</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
</dependency>
</dependencies>

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

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.testng.ITest;
import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.internal.BaseTestMethod;
import org.testng.internal.TestResult;

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
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.PMSRevampConfigManger;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithBodyAndPathParamsAndAutoGenId extends AdminTestUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithBodyAndPathParamsAndAutoGenId.class);
protected String testCaseName = "";
String pathParams = null;
public String idKeyName = null;
String headers = null;
public Response response = null;

@BeforeClass
public static void setLogLevel() {
if (PMSRevampConfigManger.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
}

/**
* get current testcaseName
*/
@Override
public String getTestName() {
return testCaseName;
}
/**
* Data provider class provides test case list
*
* @return object of data provider
*/
@DataProvider(name = "testcaselist")
public Object[] getTestCaseList(ITestContext context) {
String ymlFile = context.getCurrentXmlTest().getLocalParameters().get("ymlFile");
pathParams = context.getCurrentXmlTest().getLocalParameters().get("pathParams");
idKeyName = context.getCurrentXmlTest().getLocalParameters().get("idKeyName");
headers = context.getCurrentXmlTest().getLocalParameters().get("headers");
logger.info("Started executing yml: " + ymlFile);
return getYmlTestData(ymlFile);
}

/**
* Test method for OTP Generation execution
*
* @param objTestParameters
* @param testScenario
* @param testcaseName
* @throws AuthenticationTestException
* @throws AdminTestException
*/
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
String[] templateFields = testCaseDTO.getTemplateFields();

if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

testCaseDTO = AdminTestUtil.filterHbs(testCaseDTO);
String inputJson = getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate());
String outputJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());

if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) {
ArrayList<JSONObject> inputtestCases = AdminTestUtil.getInputTestCase(testCaseDTO);
ArrayList<JSONObject> outputtestcase = AdminTestUtil.getOutputTestCase(testCaseDTO);
for (int i = 0; i < languageList.size(); i++) {
response = postWithPathParamsBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(),
getJsonFromTemplate(inputtestCases.get(i).toString(), testCaseDTO.getInputTemplate()),
COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), pathParams);

Map<String, List<OutputValidationDto>> ouputValid = OutputValidationUtil.doJsonOutputValidation(
response.asString(),
getJsonFromTemplate(outputtestcase.get(i).toString(), testCaseDTO.getOutputTemplate()),
testCaseDTO, response.getStatusCode());
Reporter.log(ReportUtil.getOutputValidationReport(ouputValid));

if (!OutputValidationUtil.publishOutputResult(ouputValid))
throw new AdminTestException("Failed at output validation");
}
}

else {
response = postWithPathParamsBodyAndCookieForAutoGeneratedId(ApplnURI + testCaseDTO.getEndPoint(), inputJson, COOKIENAME,
testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), pathParams,idKeyName);
}
Map<String, List<OutputValidationDto>> ouputValid = OutputValidationUtil
.doJsonOutputValidation(response.asString(), outputJson, testCaseDTO, response.getStatusCode());
Reporter.log(ReportUtil.getOutputValidationReport(ouputValid));

if (!OutputValidationUtil.publishOutputResult(ouputValid))
throw new AdminTestException("Failed at output validation");
}




/**
* The method ser current test name to result
*
* @param result
*/
@AfterMethod(alwaysRun = true)
public void setResultTestName(ITestResult result) {
try {
Field method = TestResult.class.getDeclaredField("m_method");
method.setAccessible(true);
method.set(result, result.getMethod().clone());
BaseTestMethod baseTestMethod = (BaseTestMethod) result.getMethod();
Field f = baseTestMethod.getClass().getSuperclass().getDeclaredField("m_methodName");
f.setAccessible(true);
f.set(baseTestMethod, testCaseName);
} catch (Exception e) {
Reporter.log("Exception : " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"id": "mosip.pms.approve.mapping.device.to.sbi.post",
"id": "mosip.pms.approval.mapping.device.to.sbi.post",
"version": "1.0",
"metadata": {},
"deviceDetailId": "{{deviceDetailId}}",
"requestTime": "{{requestTime}}",
"request": {
"partnerId": "{{partnerId}}",
"sbiId": "{{sbiId}}",
"deviceDetailId": "{{deviceDetailId}}"
"status": "approved"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ApproveMappingDeviceToSbi:
Pms_ApproveMappingDeviceToSbi_All_Valid_Smoke:
endPoint: /v1/partnermanager/admin/approve-mapping-device-to-sbi
endPoint: /v1/partnermanager/devicedetail/{deviceDetailId}/approval
role: partnerrevampdevice
restMethod: post
checkErrorsOnlyInResponse: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"id": "mosip.pms.deactivate.device.post",
"id": "mosip.pms.deactivate.device.patch",
"version": "1.0",
"requestTime": "{{requesttime}}",
"metadata": {},
"deviceId": "{{deviceId}}",
"request": {
"deviceId": "{{deviceId}}"
"status": "De-Activate"
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
DeactivateDevice:
Pms_DeactivateDevice_all_Valid_Smoke_sid:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/DeactivateDevice/DeactivateDeviceResult
input: '{
"requesttime": "$TIMESTAMP$",
"deviceId": "$ID:SaveDeviceDetails_DeviceProvider_AllValid_Smoke_sid_id$"
"deviceId": "$ID:SaveDeviceDetails_DeviceProvider_AllValid_Smoke_sid_id$",
"status": "De-Activate"
}'
output: '{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"id": "{{id}}",
"version": "{{version}}",
"requestTime": "{{requesttime}}",
"deviceId": "{{deviceId}}",
"metadata": {},
"request": {
"deviceId": "{{deviceId}}"
"status": "De-Activate"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DeactivateDeviceNegativeScenarios:
Pms_DeactivateDevice_without_authentication_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_01
description: Deactivate Device without Partner authentication
role: invalidtoken
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -20,12 +20,12 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_with_Invalid_Device_ID_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_02
description: Deactivate Device by passing invalid Device ID
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -40,12 +40,12 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_with_Invalid_requestTime_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_03
description: Deactivate Device by passing invalid requestTime
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -60,11 +60,11 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_Missing_requestTime_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_04
description: Deactivate Device while keeping requestTime paramter as Missing
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -78,12 +78,12 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_Empty_requestTime_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_05
description: Deactivate Device while keeping requestTime paramter as Empty
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -98,12 +98,12 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_with_Invalid_RandomDevice_ID_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_06
description: Deactivate Device by passwing invalid Random Device ID
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -118,12 +118,12 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_Already_deactivated_device_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_07
description: Deactivate Device which has been already Deactivated
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDevice
outputTemplate: pms/error
input: '{
Expand All @@ -138,16 +138,16 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_with_Invalid_Version_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_08
description: Deactivate Device by passing invalid Version
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDeviceNegativeScenarios
outputTemplate: pms/error
input: '{
"id": "mosip.pms.deactivate.device.post",
"id": "mosip.pms.deactivate.device.patch",
"version": "99",
"requesttime": "$TIMESTAMP$",
"deviceId": "$ID:SaveDeviceDetails_DeviceProvider_AllValid_Smoke_sid_id$"
Expand All @@ -160,16 +160,16 @@ DeactivateDeviceNegativeScenarios:
]
}'
Pms_DeactivateDevice_with_Empty_Version_Neg:
endPoint: /v1/partnermanager/devicedetail/deactivate-device
endPoint: /v1/partnermanager/devicedetail/{deviceId}
uniqueIdentifier: TC_PMS_DeactivateDevice_09
description: Deactivate Device while keeping Version parameter as Empty
role: partnerrevampdevice
checkErrorsOnlyInResponse: true
restMethod: post
restMethod: patch
inputTemplate: pms/DeactivateDevice/DeactivateDeviceNegativeScenarios
outputTemplate: pms/error
input: '{
"id": "mosip.pms.deactivate.device.post",
"id": "mosip.pms.deactivate.device.patch",
"version": "$REMOVE$",
"requesttime": "$TIMESTAMP$",
"deviceId": "$ID:SaveDeviceDetails_DeviceProvider_AllValid_Smoke_sid_id$"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"id": "mosip.pms.deactivate.ftm.post",
"id": "mosip.pms.deactivate.ftm.patch",
"version": "1.0",
"requestTime": "{{requestTime}}",
"metadata": {},
"ftmId": "{{ftmId}}",
"request": {
"ftmId": "{{ftmId}}"
"status": "De-Activate"
}
}
Loading

0 comments on commit 5f4f6f2

Please sign in to comment.