Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mosip 39047 - Commons cleanup #1208

Merged
merged 13 commits into from
Mar 3, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public static void main(String[] arg) {
startTestRunner();
} else if (EsignetUtil.getIdentityPluginNameFromEsignetActuator().toLowerCase()
.contains("sunbirdrcauthenticationservice") == true) {
BaseTestCase.isTargetEnvLatest = true;
// BaseTestCase.isTargetEnvLatest = true;
EsignetUtil.getSupportedLanguage();
startTestRunner();
} else {
BaseTestCase.isTargetEnvLatest = true;
// BaseTestCase.isTargetEnvLatest = true;
EsignetUtil.getSupportedLanguage();
startTestRunner();
}
Expand Down Expand Up @@ -188,6 +188,9 @@ private static void setLogLevels() {
KernelAuthentication.setLogLevel();
BaseTestCase.setLogLevel();
EsignetUtil.setLogLevel();
KeycloakUserManager.setLogLevel();
DBManager.setLogLevel();
BiometricDataProvider.setLogLevel();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import io.mosip.testrig.apirig.utils.RestClient;
import io.restassured.response.Response;

public class AddIdentity extends AdminTestUtil implements ITest {
public class AddIdentity extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(AddIdentity.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class DeleteWithParam extends AdminTestUtil implements ITest {
public class DeleteWithParam extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(DeleteWithParam.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class EsignetBioAuth extends AdminTestUtil implements ITest {
public class EsignetBioAuth extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(EsignetBioAuth.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class GetWithParam extends AdminTestUtil implements ITest {
public class GetWithParam extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(GetWithParam.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class GetWithQueryParam extends AdminTestUtil implements ITest {
public class GetWithQueryParam extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(GetWithQueryParam.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class KycAuth extends AdminTestUtil implements ITest {
public class KycAuth extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(KycAuth.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PatchWithPathParamsAndBody extends AdminTestUtil implements ITest {
public class PatchWithPathParamsAndBody extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PatchWithPathParamsAndBody.class);
protected String testCaseName = "";
String pathParams = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithAutogenIdWithOtpGenerate extends AdminTestUtil implements ITest {
public class PostWithAutogenIdWithOtpGenerate extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithAutogenIdWithOtpGenerate.class);
protected String testCaseName = "";
public String idKeyName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithAutogenIdWithOtpGenerateForWla extends AdminTestUtil implements ITest {
public class PostWithAutogenIdWithOtpGenerateForWla extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithAutogenIdWithOtpGenerateForWla.class);
protected String testCaseName = "";
public String idKeyName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithBodyAndPathParams extends AdminTestUtil implements ITest {
public class PostWithBodyAndPathParams extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithBodyAndPathParams.class);
protected String testCaseName = "";
String pathParams = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithBodyAndQueryParamsForAutoGenId extends AdminTestUtil implements ITest {
public class PostWithBodyAndQueryParamsForAutoGenId extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithBodyAndQueryParamsForAutoGenId.class);
protected String testCaseName = "";
String queryParams = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithBodyWithOtpGenerate extends AdminTestUtil implements ITest {
public class PostWithBodyWithOtpGenerate extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithBodyWithOtpGenerate.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PostWithOnlyPathParam extends AdminTestUtil implements ITest {
public class PostWithOnlyPathParam extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PostWithOnlyPathParam.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class PutWithPathParamsAndBody extends AdminTestUtil implements ITest {
public class PutWithPathParamsAndBody extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(PutWithPathParamsAndBody.class);
protected String testCaseName = "";
String pathParams = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class SimplePatchForAutoGenId extends AdminTestUtil implements ITest {
public class SimplePatchForAutoGenId extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(SimplePatchForAutoGenId.class);
protected String testCaseName = "";
String idKeyName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class SimplePost extends AdminTestUtil implements ITest {
public class SimplePost extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(SimplePost.class);
protected String testCaseName = "";
public Response response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class SimplePostForAutoGenId extends AdminTestUtil implements ITest {
public class SimplePostForAutoGenId extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(SimplePostForAutoGenId.class);
protected String testCaseName = "";
public String idKeyName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.restassured.response.Response;

public class SimplePostForAutoGenIdForUrlEncoded extends AdminTestUtil implements ITest {
public class SimplePostForAutoGenIdForUrlEncoded extends EsignetUtil implements ITest {
private static final Logger logger = Logger.getLogger(SimplePostForAutoGenIdForUrlEncoded.class);
protected String testCaseName = "";
public String idKeyName = null;
Expand Down Expand Up @@ -153,11 +153,11 @@ public void test(TestCaseDTO testCaseDTO)
testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$ESIGNETMOCKBASEURL$", ""));
}
String endPoint = tempUrl + testCaseDTO.getEndPoint();
if (testCaseDTO.getEndPoint().contains("$GETENDPOINTFROMRESIDENTACTUATOR$")
&& BaseTestCase.currentModule.equalsIgnoreCase("resident")) {
endPoint = getValueFromActuator("mosip-config/resident-default.properties",
"mosip.iam.token_endpoint");
}
// if (testCaseDTO.getEndPoint().contains("$GETENDPOINTFROMRESIDENTACTUATOR$")
// && BaseTestCase.currentModule.equalsIgnoreCase("resident")) {
// endPoint = getValueFromActuator("mosip-config/resident-default.properties",
// "mosip.iam.token_endpoint");
// }
if (testCaseDTO.getEndPoint().contains("$GETENDPOINTFROMWELLKNOWN$")
&& BaseTestCase.currentModule.equalsIgnoreCase("esignet")) {
endPoint = EsignetUtil.getValueFromEsignetWellKnownEndPoint("token_endpoint", EsignetConfigManager.getEsignetBaseUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static void init() {
Properties props = getproperties(path);
// Convert Properties to Map and add to moduleSpecificPropertiesMap
for (String key : props.stringPropertyNames()) {
String value = System.getenv(key) == null ? props.getProperty(key) : System.getenv(key);
moduleSpecificPropertiesMap.put(key, value);
moduleSpecificPropertiesMap.put(key, props.getProperty(key));
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {

public static String inputstringKeyWordHandeler(String jsonString, String testCaseName) {
if (jsonString.contains("$ID:")) {
String autoGenIdFileName = esignetAutoGeneratedIdPropFileName;
jsonString = replaceIdWithAutogeneratedId(jsonString, "$ID:", autoGenIdFileName);
// String autoGenIdFileName = esignetAutoGeneratedIdPropFileName;
// jsonString = replaceIdWithAutogeneratedId(jsonString, "$ID:", autoGenIdFileName);
jsonString = replaceIdWithAutogeneratedId(jsonString, "$ID:");
}

if (jsonString.contains(GlobalConstants.TIMESTAMP)) {
Expand Down Expand Up @@ -1121,6 +1122,16 @@ public static String getValueFromEsignetWellKnownEndPoint(String key, String bas
protected static final String BINDINGCONSENTUSER2JWK = "bindingConsentUser2JWK";
protected static final String BINDINGCONSENTVIDUSER2JWK = "bindingConsentVidUser2JWK";

public static final String BINDINGCERTFILE = "BINDINGCERTFile";
public static final String BINDINGCERTFILEVID = "BINDINGCERTFileVid";
public static final String BINDINGCERTCONSENTFILE = "BINDINGCERTCONSENTFile";
public static final String BINDINGCERTCONSENTVIDFILE = "BINDINGCERTCONSENTVidFile";
public static final String BINDINGCERTCONSENTSAMECLAIMFILE = "BINDINGCERTCONSENTSAMECLAIMFile";
public static final String BINDINGCERTCONSENTVIDSAMECLAIMFILE = "BINDINGCERTCONSENTVIDSAMECLAIMFile";
public static final String BINDINGCERTCONSENTEMPTYCLAIMFILE = "BINDINGCERTCONSENTEMPTYCLAIMFile";
public static final String BINDINGCERTCONSENTUSER2FILE = "BINDINGCERTCONSENTUSER2File";
public static final String BINDINGCERTVIDCONSENTUSER2FILE = "BINDINGCERTCONSENTVIDUSER2File";

protected static final String OIDCJWK1 = "oidcJWK1";
protected static final String OIDCJWK2 = "oidcJWK2";
protected static final String OIDCJWK3 = "oidcJWK3";
Expand Down Expand Up @@ -1397,4 +1408,73 @@ public static Response putWithPathParamsAndBodyAndBearerToken(String url, String
return response;
}
}

protected Response postRequestWithCookieAuthHeaderForAutoGenId(String url, String jsonInput, String cookieName,
String role, String testCaseName, String idKeyName) {
Response response = null;
String inputJson = inputJsonKeyWordHandeler(jsonInput, testCaseName);
token = kernelAuthLib.getTokenByRole(role);
String apiKey = null;
String partnerId = null;
JSONObject req = new JSONObject(inputJson);
apiKey = req.getString(GlobalConstants.APIKEY);
req.remove(GlobalConstants.APIKEY);
partnerId = req.getString(GlobalConstants.PARTNERID);
req.remove(GlobalConstants.PARTNERID);

HashMap<String, String> headers = new HashMap<>();
headers.put("PARTNER-API-KEY", apiKey);
headers.put("PARTNER-ID", partnerId);
headers.put(cookieName, "Bearer " + token);
inputJson = req.toString();
if (BaseTestCase.currentModule.equals(GlobalConstants.ESIGNET)) {
inputJson = smtpOtpHandler(inputJson, testCaseName);
}
logger.info(GlobalConstants.POST_REQ_URL + url);
GlobalMethods.reportRequest(headers.toString(), inputJson, url);
try {
response = RestClient.postRequestWithMultipleHeadersWithoutCookie(url, inputJson,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, headers);
GlobalMethods.reportResponse(response.getHeaders().asList().toString(), url, response);
if (testCaseName.toLowerCase().contains("_sid")) {
writeAutoGeneratedId(response, idKeyName, testCaseName);
}

if (testCaseName.toLowerCase().contains("_scert")) {
cacheCertificate(response, testCaseName);
}
return response;
} catch (Exception e) {
logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
return response;
}
}

public static void cacheCertificate(Response response, String testCaseName) {
String certsKey = null;
if (testCaseName.contains("Wla_uin_")) {
certsKey = BINDINGCERTFILE;
} else if (testCaseName.contains("Wla_Vid_")) {
certsKey = BINDINGCERTFILEVID;
} else if (testCaseName.contains("_Consentuin_")) {
certsKey = BINDINGCERTCONSENTFILE;
} else if (testCaseName.contains("_ConsentVid_")) {
certsKey = BINDINGCERTCONSENTVIDFILE;
} else if (testCaseName.contains("_Consent_SameClaim_uin_")) {
certsKey = BINDINGCERTCONSENTSAMECLAIMFILE;
} else if (testCaseName.contains("_Consent_SameClaim_Vid_")) {
certsKey = BINDINGCERTCONSENTVIDSAMECLAIMFILE;
} else if (testCaseName.contains("_Consent_EmptyClaim_uin_")) {
certsKey = BINDINGCERTCONSENTEMPTYCLAIMFILE;
} else if (testCaseName.contains("_Consent_User2_uin_SCert_")) {
certsKey = BINDINGCERTCONSENTUSER2FILE;
} else if (testCaseName.contains("_Consent_User2_Vid_SCert_")) {
certsKey = BINDINGCERTVIDCONSENTUSER2FILE;
}

String certificateData = new JSONObject(response.getBody().asString()).getJSONObject(GlobalConstants.RESPONSE)
.get("certificate").toString();

CertsUtil.addCertificateToCache(certsKey, certificateData);
}
}
30 changes: 15 additions & 15 deletions api-test/src/main/resources/config/application.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## End point(s) relative URLs
internalSignEndpoint=/idauthentication/v1/internal/jwtSign
signJsonPath=config/sign.json
#internalSignEndpoint=/idauthentication/v1/internal/jwtSign
#signJsonPath=config/sign.json
encryptionPath=v1/identity/encrypt?isInternal=false
internalEncryptionPath=v1/identity/encrypt?isInternal=true
encodePath=v1/identity/encode
Expand Down Expand Up @@ -47,19 +47,19 @@ validateSignatureUrl=v1/identity/validateSign
vciContextURL=https://www.w3.org/2018/credentials/v1

## Auto generated properties while running the test rig(s)
adminAutoGeneratedIdPropFileName=/admin/autoGeneratedId.properties
masterDataAutoGeneratedIdPropFileName=/masterdata/autoGeneratedId.properties
syncDataAutoGeneratedIdPropFileName=/syncdata/autoGeneratedId.properties
preregAutoGeneratedIdPropFileName=/preReg/autoGeneratedId.properties
partnerAutoGeneratedIdPropFileName=/partner/autoGeneratedId.properties
idrepoAutoGeneratedIdPropFileName=/idRepository/autoGeneratedId.properties
residentAutoGeneratedIdPropFileName=/resident/autoGeneratedId.properties
esignetAutoGeneratedIdPropFileName=/esignet/autoGeneratedId.properties
mimotoAutoGeneratedIdPropFileName=/mimoto/autoGeneratedId.properties
authAutoGeneratedIdPropFileName=/ida/autoGeneratedId.properties
prerequisiteAutoGeneratedIdPropFileName=/prerequisite/autoGeneratedId.properties
regProcAutoGeneratedIdPropFileName=/regProc/autoGeneratedId.properties
mobileIdAutoGeneratedIdPropFileName=/mobileId/autoGeneratedId.properties
#adminAutoGeneratedIdPropFileName=/admin/autoGeneratedId.properties
#masterDataAutoGeneratedIdPropFileName=/masterdata/autoGeneratedId.properties
#syncDataAutoGeneratedIdPropFileName=/syncdata/autoGeneratedId.properties
#preregAutoGeneratedIdPropFileName=/preReg/autoGeneratedId.properties
#partnerAutoGeneratedIdPropFileName=/partner/autoGeneratedId.properties
#idrepoAutoGeneratedIdPropFileName=/idRepository/autoGeneratedId.properties
#residentAutoGeneratedIdPropFileName=/resident/autoGeneratedId.properties
#esignetAutoGeneratedIdPropFileName=/esignet/autoGeneratedId.properties
#mimotoAutoGeneratedIdPropFileName=/mimoto/autoGeneratedId.properties
#authAutoGeneratedIdPropFileName=/ida/autoGeneratedId.properties
#prerequisiteAutoGeneratedIdPropFileName=/prerequisite/autoGeneratedId.properties
#regProcAutoGeneratedIdPropFileName=/regProc/autoGeneratedId.properties
#mobileIdAutoGeneratedIdPropFileName=/mobileId/autoGeneratedId.properties

## As below are non changble values, move these out from properties file
appIdForCertificate=IDA
Expand Down
2 changes: 1 addition & 1 deletion api-test/src/main/resources/config/esignet.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
actuatorEsignetEndpoint=/v1/esignet/actuator/env
actuatorSignupEndpoint=/v1/signup/actuator/env
tokenEndpoint=/v1/esignet/oauth/token
validateBindingEndpoint=ida-binding
#validateBindingEndpoint=ida-binding
esignetWellKnownEndPoint=/v1/esignet/oidc/.well-known/openid-configuration
keycloakAuthTokenEndPoint=/auth/realms/mosip/protocol/openid-connect/token
signupSettingsEndPoint=/v1/signup/settings
Expand Down
Loading