Skip to content

Commit

Permalink
Merge pull request #140 from nandhu-kumar/develop
Browse files Browse the repository at this point in the history
MOSIP-37807 | Make Inji-Certify API test rig configurable to execute on particular usecase
  • Loading branch information
ckm007 authored Nov 25, 2024
2 parents 1341d6e + 1a1059b commit 17583e7
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.mosip.testrig.apirig.dataprovider.BiometricDataProvider;
import io.mosip.testrig.apirig.dbaccess.DBManager;
import io.mosip.testrig.apirig.injicertify.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.injicertify.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.report.EmailableReport;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.ExtractResource;
Expand Down Expand Up @@ -188,24 +189,50 @@ public static void startTestRunner() {
return f1.getName().compareTo(f2.getName()); // default alphabetical order
});

for (File file : files) {
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();
if (file.getName().toLowerCase().contains(GlobalConstants.INJICERTIFY)) {
if (file.getName().toLowerCase().contains("prerequisite")) {
BaseTestCase.setReportName(GlobalConstants.INJICERTIFY + "-prerequisite");
} else {
// if the prerequisite total skipped/failed count is greater than zero
if (EmailableReport.getFailedCount() > 0 || EmailableReport.getSkippedCount() > 0) {
// skipAll = true;
String useCaseToExecute = InjiCertifyConfigManager.getproperty("useCaseToExecute");

// Split the string by commas
String[] useCases = useCaseToExecute.split(",");

// Loop through the resulting array and print each element
for (String useCase : useCases) {
InjiCertifyUtil.currentUseCase = useCase;

for (File file : files) {
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();

if (file.getName().toLowerCase().contains(GlobalConstants.INJICERTIFY)) {
if (file.getName().toLowerCase().contains("prerequisite")) {
if (useCase.equals("sunbird") == true) {
continue;
} else {
if (useCase != null && useCase.isBlank() == false) {
BaseTestCase.setReportName(
GlobalConstants.INJICERTIFY + "-" + useCase + "-prerequisite");
} else {
BaseTestCase.setReportName(GlobalConstants.INJICERTIFY + "-prerequisite");
}
}
} else {
// if the prerequisite total skipped/failed count is greater than zero
if (EmailableReport.getFailedCount() > 0 || EmailableReport.getSkippedCount() > 0) {
// skipAll = true;
}
if (useCase != null && useCase.isBlank() == false) {
BaseTestCase.setReportName(GlobalConstants.INJICERTIFY + "-" + useCase);
} else {
BaseTestCase.setReportName(GlobalConstants.INJICERTIFY);
}

}
BaseTestCase.setReportName(GlobalConstants.INJICERTIFY);
suitefiles.add(file.getAbsolutePath());
runner.setTestSuites(suitefiles);
System.getProperties().setProperty("testng.outpur.dir", "testng-report");
runner.setOutputDirectory("testng-report");
runner.run();
}
suitefiles.add(file.getAbsolutePath());
runner.setTestSuites(suitefiles);
System.getProperties().setProperty("testng.outpur.dir", "testng-report");
runner.setOutputDirectory("testng-report");
runner.run();

}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class InjiCertifyUtil extends AdminTestUtil {

private static final Logger logger = Logger.getLogger(InjiCertifyUtil.class);
public static String currentUseCase = "";

public static String smtpOtpHandler(String inputJson, TestCaseDTO testCaseDTO) {
JSONObject request = new JSONObject(inputJson);
Expand Down Expand Up @@ -252,14 +253,25 @@ public static String inputstringKeyWordHandeler(String jsonString, String testCa

public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {
String testCaseName = testCaseDTO.getTestCaseName();

if (MosipTestRunner.skipAll == true) {
throw new SkipException(GlobalConstants.PRE_REQUISITE_FAILED_MESSAGE);
}

if (SkipTestCaseHandler.isTestCaseInSkippedList(testCaseName)) {
throw new SkipException(GlobalConstants.KNOWN_ISSUES);
}

if (currentUseCase.toLowerCase().equals("mock") && testCaseName.toLowerCase().contains("mock") == false) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}
if (currentUseCase.toLowerCase().equals("sunbird") && testCaseName.toLowerCase().contains("sunbird") == false) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}
if (currentUseCase.toLowerCase().equals("mosipid") && testCaseName.toLowerCase().contains("mosipid") == false) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

return testCaseName;
}

Expand Down
4 changes: 3 additions & 1 deletion api-test/src/main/resources/config/injiCertify.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ signupSettingsEndPoint=/v1/signup/settings
actuatorMimotoEndpoint=/residentmobileapp/actuator/env
esignetActuatorPropertySection=esignet-default.properties
injiCertifyWellKnownEndPoint=/v1/certify/issuance/.well-known/openid-credential-issuer
sunBirdBaseURL=https://registry.dev1.mosip.net
sunBirdBaseURL=https://registry.dev1.mosip.net
# allowed useCaseToExecute values are sunbird,mosipid,mock
useCaseToExecute=
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AddIdentity:
InjiCertify_AddIdentity_Valid_Params_VCI_uin_smoke_Pos:
InjiCertify_AddIdentity_Valid_Params_VCI_MOSIPID_uin_smoke_Pos:
endPoint: /idrepository/v1/identity/
role: idrepo
restMethod: post
Expand All @@ -13,7 +13,7 @@ AddIdentity:
"UIN": "$UIN$",
"dateOfBirth": "1992/04/15",
"postalCode": "14022",
"email": "InjiCertify_AddIdentity_Valid_Params_VCI_uin_smoke_Pos@mosip.net",
"email": "InjiCertify_AddIdentity_Valid_Params_VCI_MOSIPID_uin_smoke_Pos@mosip.net",
"phone": "9876543210",
"referenceIdentityNumber": "6789545678878",
"version": "v1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
CreateOIDCClient:
Injicertify_CreateOIDCClient_all_Valid_Smoke_sid:
Injicertify_CreateOIDCClient_MOSIPID_all_Valid_Smoke_sid:
endPoint: /v1/partnermanager/oidc/client
role: partner
restMethod: post
inputTemplate: injicertify/OidcClient/OIDCClient
outputTemplate: injicertify/OidcClient/OIDCClientResult
input: '{
"name": "$RANDOMID$",
"policyId": "$ID:DefinePolicy_All_Valid_Smoke_sid_id$",
"policyId": "$ID:DefinePolicy_MOSIPID_All_Valid_Smoke_sid_id$",
"publicKey": "$OIDCJWKKEY$",
"authPartnerId": "$ID:PartnerSelfRegistration_All_Valid_Smoke_sid_partnerId$",
"authPartnerId": "$ID:PartnerSelfRegistration_MOSIPID_All_Valid_Smoke_sid_partnerId$",
"logoUri": "https://health-services.com/logo.png",
"redirectUris": "$IDPREDIRECTURI$",
"grantTypes": "authorization_code",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ApproveAPIKey:
InjiCertify_ApproveRejectPartnerAPIKeyReq_All_Valid_Smoke:
InjiCertify_ApproveRejectPartnerAPIKeyReq_MOSIPID_All_Valid_Smoke:
endPoint: /v1/partnermanager/partners/policy/{mappingkey}
role: partner
restMethod: put
inputTemplate: injicertify/PmsIntegration/ApproveAPIKey/approveAPIKey
outputTemplate: injicertify/PmsIntegration/ApproveAPIKey/approveAPIKeyResult
input: '{
"status": "Approved",
"mappingkey": "$ID:SubmitPartnerApiKeyRequest_Rejection_All_Valid_Smoke_sid_mappingkey$",
"mappingkey": "$ID:SubmitPartnerApiKeyRequest_Rejection_MOSIPID_All_Valid_Smoke_sid_mappingkey$",
"requesttime": "$TIMESTAMP$"
}'
output: '{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
createPartnerSelfRegistration:
InjiCertify_PartnerSelfRegistration_All_Valid_Smoke_sid:
InjiCertify_PartnerSelfRegistration_MOSIPID_All_Valid_Smoke_sid:
endPoint: /v1/partnermanager/partners
role: partner
restMethod: post
Expand All @@ -12,7 +12,7 @@ createPartnerSelfRegistration:
"organizationName": "$PARTNERID$",
"partnerId": "$PARTNERID$",
"partnerType": "Auth_Partner",
"policyGroup": "$ID:DefinePolicyGroup_All_Valid_Smoke_sid_name$",
"policyGroup": "$ID:DefinePolicyGroup_MOSIPID_All_Valid_Smoke_sid_name$",
"requesttime": "$TIMESTAMP$"
}'
output: ' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
definePolicy:
InjiCertify_DefinePolicy_All_Valid_Smoke_sid:
InjiCertify_DefinePolicy_MOSIPID_All_Valid_Smoke_sid:
endPoint: /v1/policymanager/policies
role: partner
restMethod: post
Expand All @@ -8,7 +8,7 @@ definePolicy:
input: '{
"desc": "$POLICYDESC$",
"name": "$POLICYNAME$",
"policyGroupName": "$ID:DefinePolicyGroup_All_Valid_Smoke_sid_name$",
"policyGroupName": "$ID:DefinePolicyGroup_MOSIPID_All_Valid_Smoke_sid_name$",
"policyType": "Auth",
"version": "1.0",
"requesttime": "$TIMESTAMP$"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
definePolicyGroup:
InjiCertify_DefinePolicyGroup_All_Valid_Smoke_sid:
InjiCertify_DefinePolicyGroup_MOSIPID_All_Valid_Smoke_sid:
endPoint: /v1/policymanager/policies/group/new
role: partner
restMethod: post
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
createPublishPolicy:
InjiCertify_PublishPolicy_All_Valid_Smoke:
InjiCertify_PublishPolicy_MOSIPID_All_Valid_Smoke:
endPoint: /v1/policymanager/policies/{policyId}/group/{policygroupId}/publish
role: partner
restMethod: post
inputTemplate: injicertify/PmsIntegration/PublishPolicy/publishPolicy
outputTemplate: injicertify/PmsIntegration/PublishPolicy/publishPolicyResult
input: '{
"policygroupId": "$ID:DefinePolicyGroup_All_Valid_Smoke_sid_id$",
"policyId": "$ID:DefinePolicy_All_Valid_Smoke_sid_id$",
"policygroupId": "$ID:DefinePolicyGroup_MOSIPID_All_Valid_Smoke_sid_id$",
"policyId": "$ID:DefinePolicy_MOSIPID_All_Valid_Smoke_sid_id$",
"requesttime": "$TIMESTAMP$"
}'
output: '{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RequestAPIKeyForAuthPartner:
InjiCertify_SubmitPartnerApiKeyRequest_Rejection_All_Valid_Smoke_sid:
endPoint: /v1/partnermanager/partners/$ID:PartnerSelfRegistration_All_Valid_Smoke_sid_partnerId$/policy/map
InjiCertify_SubmitPartnerApiKeyRequest_Rejection_MOSIPID_All_Valid_Smoke_sid:
endPoint: /v1/partnermanager/partners/$ID:PartnerSelfRegistration_MOSIPID_All_Valid_Smoke_sid_partnerId$/policy/map
role: partner
restMethod: post
inputTemplate: injicertify/PmsIntegration/RequestAPIKey/requestApiKey
outputTemplate: injicertify/PmsIntegration/RequestAPIKey/requestAPIKeyResult
input: '{
"policyName": "$ID:DefinePolicy_All_Valid_Smoke_sid_name$",
"policyName": "$ID:DefinePolicy_MOSIPID_All_Valid_Smoke_sid_name$",
"useCaseDescription": "Need to submit the payment",
"requesttime": "$TIMESTAMP$"
}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
uploadPartnerCert:
Injicertify_UploadPartnerCert_All_Valid_Smoke:
Injicertify_UploadPartnerCert_MOSIPID_All_Valid_Smoke:
endPoint: /v1/partnermanager/partners/certificate/upload
role: partner
checkErrorsOnlyInResponse: true
Expand All @@ -8,7 +8,7 @@ uploadPartnerCert:
outputTemplate: injicertify/PmsIntegration/UploadCert/uploadCertResult
input: '{
"certificateData": "$PARTNERCERT$",
"partnerId": "$ID:PartnerSelfRegistration_All_Valid_Smoke_sid_partnerId$",
"partnerId": "$ID:PartnerSelfRegistration_MOSIPID_All_Valid_Smoke_sid_partnerId$",
"requesttime": "$TIMESTAMP$"
}'
output: ' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
uploadCACert:
Injicertify_UploadCACertificate_All_Valid_Smoke:
Injicertify_UploadCACertificate_MOSIPID_All_Valid_Smoke:
endPoint: /v1/partnermanager/partners/certificate/ca/upload
role: partner
restMethod: post
inputTemplate: injicertify/PmsIntegration/UploadCertificate/uploadCertificate
outputTemplate: injicertify/PmsIntegration/UploadCertificate/uploadCertificateResult
input: '{
"partnerId": "$ID:PartnerSelfRegistration_All_Valid_Smoke_sid_partnerId$",
"partnerId": "$ID:PartnerSelfRegistration_MOSIPID_All_Valid_Smoke_sid_partnerId$",
"certificateData": "$CACERT$",
"requesttime": "$TIMESTAMP$"
}'
output: ' {
"status": "Upload Success."
}'
Injicertify_UploadCInterCertificate_All_Valid_Smoke:
Injicertify_UploadCInterCertificate_MOSIPID_All_Valid_Smoke:
endPoint: /v1/partnermanager/partners/certificate/ca/upload
role: partner
restMethod: post
inputTemplate: injicertify/PmsIntegration/UploadCertificate/uploadCertificate
outputTemplate: injicertify/PmsIntegration/UploadCertificate/uploadCertificateResult
input: '{
"partnerId": "$ID:PartnerSelfRegistration_All_Valid_Smoke_sid_partnerId$",
"partnerId": "$ID:PartnerSelfRegistration_MOSIPID_All_Valid_Smoke_sid_partnerId$",
"certificateData": "$INTERCERT$",
"requesttime": "$TIMESTAMP$"
}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AuthenticateUserVCI:
InjiCertify_ESignet_AuthenticateUserVCI_uin_Otp_Valid_Smoke:
InjiCertify_ESignet_AuthenticateUserVCI_MOSIPID_uin_Otp_Valid_Smoke:
endPoint: $ESIGNETMOSIPIDBASEURL$/v1/esignet/authorization/authenticate
role: resident
restMethod: post
Expand All @@ -8,17 +8,17 @@ AuthenticateUserVCI:
inputTemplate: injicertify/VCIMosipID/AuthenticateUserVCI/AuthenticateUserVCI
outputTemplate: injicertify/VCIMosipID/AuthenticateUserVCI/AuthenticateUserVCIResult
input: '{
"encodedHash": "$ID:ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid_encodedResp$",
"encodedHash": "$ID:ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid_encodedResp$",
"requestTime": "$TIMESTAMP$",
"transactionId": "$ID:ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid_transactionId$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_uin_smoke_Pos_UIN$",
"transactionId": "$ID:ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid_transactionId$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_MOSIPID_uin_smoke_Pos_UIN$",
"authFactorType" : "OTP",
"challenge" : "$ID:AddIdentity_Valid_Params_VCI_uin_smoke_Pos_EMAIL$",
"challenge" : "$ID:AddIdentity_Valid_Params_VCI_MOSIPID_uin_smoke_Pos_EMAIL$",
"sendOtp":{
"encodedHash": "$ID:ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid_encodedResp$",
"encodedHash": "$ID:ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid_encodedResp$",
"requestTime": "$TIMESTAMP$",
"transactionId": "$ID:ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid_transactionId$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_uin_smoke_Pos_UIN$",
"transactionId": "$ID:ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid_transactionId$",
"individualId": "$ID:AddIdentity_Valid_Params_VCI_MOSIPID_uin_smoke_Pos_UIN$",
"otpChannels": [{channel: "email"},{channel: "phone"}],
"sendOtpReqTemplate": "injicertify/SendOtp/SendOtp",
"sendOtpEndPoint": "$ESIGNETMOSIPIDBASEURL$/v1/esignet/authorization/send-otp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AuthorizationCodeVCI:
InjiCertify_ESignet_AuthorizationCode_VCI_uin_All_Valid_Smoke_sid:
InjiCertify_ESignet_AuthorizationCode_VCI_MOSIPID_uin_All_Valid_Smoke_sid:
endPoint: $ESIGNETMOSIPIDBASEURL$/v1/esignet/authorization/auth-code
role: resident
restMethod: post
Expand All @@ -8,9 +8,9 @@ AuthorizationCodeVCI:
inputTemplate: injicertify/VCIMosipID/AuthorizationCodeVCI/AuthorizationCodeVCI
outputTemplate: injicertify/VCIMosipID/AuthorizationCodeVCI/AuthorizationCodeVCIResult
input: '{
"encodedHash": "$ID:ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid_encodedResp$",
"encodedHash": "$ID:ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid_encodedResp$",
"requestTime": "$TIMESTAMP$",
"transactionId": "$ID:ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid_transactionId$"
"transactionId": "$ID:ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid_transactionId$"
}'
output: '{
}'
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ GenerateTokenVCI:
outputTemplate: injicertify/VCIMosipID/GenerateTokenVCI/GenerateTokenVCIResult
input: '{
"grant_type": "authorization_code",
"code": "$ID:ESignet_AuthorizationCode_VCI_uin_All_Valid_Smoke_sid_code$",
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"code": "$ID:ESignet_AuthorizationCode_VCI_MOSIPID_uin_All_Valid_Smoke_sid_code$",
"client_id": "$ID:CreateOIDCClient_MOSIPID_all_Valid_Smoke_sid_clientId$",
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": "$CLIENT_ASSERTION_JWT$",
"redirect_uri": "$IDPREDIRECTURI$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GetCredentialMosipID:
inputTemplate: injicertify/VCIMosipID/GetCredentialMosipID/GetCredentialMosipID
outputTemplate: injicertify/VCIMosipID/GetCredentialMosipID/GetCredentialMosipIDResult
input: '{
"client_id": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"client_id": "$ID:CreateOIDCClient_MOSIPID_all_Valid_Smoke_sid_clientId$",
"idpAccessToken": "$ID:ESignet_GenerateTokenVCIMOSIPID_uin_Valid_Smoke_sid_access_token$",
"format": "ldp_vc",
"type": [{types: "VerifiableCredential"}, {types: "MOSIPVerifiableCredential"}],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OAuthDetailsRequestVCI:
InjiCertify_ESignet_OAuthDetailsRequest_VCI_uin_all_Valid_Smoke_sid:
InjiCertify_ESignet_OAuthDetailsRequest_VCI_MOSIPID_uin_all_Valid_Smoke_sid:
endPoint: $ESIGNETMOSIPIDBASEURL$/v1/esignet/authorization/v2/oauth-details
role: resident
restMethod: post
Expand All @@ -8,7 +8,7 @@ OAuthDetailsRequestVCI:
outputTemplate: injicertify/VCIMosipID/OAuthDetailsRequestVCI/OAuthDetailsRequestVCIResult
input: '{
"requestTime": "$TIMESTAMP$",
"clientId": "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"clientId": "$ID:CreateOIDCClient_MOSIPID_all_Valid_Smoke_sid_clientId$",
"scope": "mosip_identity_vc_ldp",
"responseType": "code",
"redirectUri": "$IDPREDIRECTURI$",
Expand Down
Loading

0 comments on commit 17583e7

Please sign in to comment.