Skip to content

Commit

Permalink
MOSIP-30310
Browse files Browse the repository at this point in the history
Signed-off-by: Nandhukumar <[email protected]>
  • Loading branch information
nandhu-kumar committed Nov 17, 2023
2 parents fcfb60c + a778437 commit 3f2726e
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public class AdminTestUtil extends BaseTestCase {
public static final String RESOURCE_FOLDER_NAME = "MosipTemporaryTestResource";
protected static String genertedUIN = null;
protected static String generatedRid = null;
protected static String policygroupId = null;
protected static String regDeviceResponse = null;
protected static String generatedVID = null;
public static final String RANDOM_ID = "mosip" + generateRandomNumberString(2)
Expand Down Expand Up @@ -201,6 +202,9 @@ public static BioDataUtility getBioDataUtil() {
protected static final String AUTH_POLICY_BODY = "config/AuthPolicy.json";
protected static final String AUTH_POLICY_REQUEST = "config/AuthPolicy3.json";
protected static final String AUTH_POLICY_REQUEST_ATTR = "config/AuthPolicy2.json";
protected static final String AUTH_POLICY_BODY1 = "config/AuthPolicy4.json";
protected static final String AUTH_POLICY_REQUEST1 = "config/AuthPolicy5.json";
protected static final String AUTH_POLICY_REQUEST_ATTR1 = "config/AuthPolicy6.json";
protected static final String POLICY_GROUP_REQUEST = "config/policyGroup.json";
protected static final String ESIGNET_PAYLOAD = "config/esignetPayload.json";
protected static Map<String, String> keycloakRolesMap = new HashMap<>();
Expand Down Expand Up @@ -5425,7 +5429,7 @@ public static void createAndPublishPolicy() {
Response response2 = RestClient.postRequestWithCookie(url2, actualrequest, MediaType.APPLICATION_JSON,
MediaType.APPLICATION_JSON, GlobalConstants.AUTHORIZATION, token);
String responseBody2 = response2.getBody().asString();
String policygroupId = new org.json.JSONObject(responseBody2).getJSONObject(GlobalConstants.RESPONSE)
policygroupId = new org.json.JSONObject(responseBody2).getJSONObject(GlobalConstants.RESPONSE)
.getString("id");

String urlForUpdate = ApplnURI + properties.getProperty("authPolicyUrl")+"/"+policygroupId;
Expand Down Expand Up @@ -5480,19 +5484,15 @@ public static void createEditAndPublishPolicy() {

actualrequest.put(GlobalConstants.REQUEST, modifiedReq);

Response response2 = RestClient.postRequestWithCookie(url2, actualrequest, MediaType.APPLICATION_JSON,
MediaType.APPLICATION_JSON, GlobalConstants.AUTHORIZATION, token);
String responseBody2 = response2.getBody().asString();
String policygroupId = new org.json.JSONObject(responseBody2).getJSONObject(GlobalConstants.RESPONSE)
.getString("id");

String urlForUpdate = ApplnURI + properties.getProperty("authPolicyUrl")+"/"+policygroupId;
Response responseForUpdate = RestClient.postRequestWithCookie(urlForUpdate, actualrequest, MediaType.APPLICATION_JSON,
MediaType.APPLICATION_JSON, GlobalConstants.AUTHORIZATION, token);

String url = ApplnURI + properties.getProperty("authPolicyUrl");
org.json.simple.JSONObject actualrequestBody = getRequestJson(AUTH_POLICY_BODY);
org.json.simple.JSONObject actualrequest2 = getRequestJson(AUTH_POLICY_REQUEST);
org.json.simple.JSONObject actualrequestAttr = getRequestJson(AUTH_POLICY_REQUEST_ATTR);
org.json.simple.JSONObject actualrequestBody = getRequestJson(AUTH_POLICY_BODY1);
org.json.simple.JSONObject actualrequest2 = getRequestJson(AUTH_POLICY_REQUEST1);
org.json.simple.JSONObject actualrequestAttr = getRequestJson(AUTH_POLICY_REQUEST_ATTR1);

actualrequest2.put("name", policyNameForUpdate);
actualrequest2.put("policyGroupName", policyGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public static void setLogLevel() {
public static String createKCUserAndGetAPIKey() {
KeycloakUserManager.createKeyCloakUsers(partnerId, emailId, role);
String mappingKey = submittingPartnerAndGetMappingKey();
//String updatedMappingKey = submittingPartnerAndGetMappingKeyWithUpdatePolicy();
String updatedMappingKey = submittingPartnerAndGetMappingKeyWithUpdatePolicy();
approvePartnerAPIKey(mappingKey);
//approvePartnerAPIKey(updatedMappingKey);
approvePartnerAPIKey(updatedMappingKey);
//createAPIKeyForUpdatedPolicy();
return createAPIKey();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,27 @@ public static String generateAndGetPartnerKeyUrl() {

getAndUploadCertificates();
apiKey = KeyCloakUserAndAPIKeyGeneration.createKCUserAndGetAPIKey();
//updatedApiKey = KeyCloakUserAndAPIKeyGeneration.createAPIKeyForUpdatedPolicy();

mispLicKey = MispPartnerAndLicenseKeyGeneration.getAndUploadCertificatesAndGenerateMispLicKey();

if (apiKey.isEmpty() || mispLicKey.isEmpty()) {
lOGGER.error("Failed to generate API key and MISP Lic key");
return "";
}
partnerKeyUrl = mispLicKey + "/" + partnerId + "/" + apiKey;
updatedpartnerKeyUrl = mispLicKey + "/" + partnerId + "/" + updatedApiKey;


lOGGER.info("partnerKeyUrl = " + partnerKeyUrl);

return partnerKeyUrl;
}

public static String generateAndGetUpdatedPartnerKeyUrl() {
updatedApiKey = KeyCloakUserAndAPIKeyGeneration.createAPIKeyForUpdatedPolicy();
updatedpartnerKeyUrl = mispLicKey + "/" + partnerId + "/" + updatedApiKey;
return updatedpartnerKeyUrl;
}

public static String generateAndGetEkycPartnerKeyUrl() {
if (!BaseTestCase.isTargetEnvLTS()) {
// In case of 1.1.5 we don't have auto sync of certificates between Key manager cert store and IDA cert store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ public static void main(String[] arg) {
AdminTestUtil.getLocationData();

String partnerKeyURL = "";
String updatedPartnerKeyURL = "";
String ekycPartnerKeyURL = "";

if (BaseTestCase.listOfModules.contains("auth")
|| BaseTestCase.listOfModules.contains(GlobalConstants.ESIGNET)) {
PartnerRegistration.deleteCertificates();
CertificateGenerationUtil.getThumbprints();
AdminTestUtil.createAndPublishPolicy();
//AdminTestUtil.createEditAndPublishPolicy();
AdminTestUtil.createEditAndPublishPolicy();
partnerKeyURL = PartnerRegistration.generateAndGetPartnerKeyUrl();

updatedPartnerKeyURL = PartnerRegistration.generateAndGetUpdatedPartnerKeyUrl();

AdminTestUtil.createAndPublishPolicyForKyc();
ekycPartnerKeyURL = PartnerRegistration.generateAndGetEkycPartnerKeyUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
testCaseDTO.setEndPoint(
testCaseDTO.getEndPoint().replace("$KycPartnerKeyURL$", PartnerRegistration.ekycPartnerKeyUrl));
}

if (testCaseDTO.getEndPoint().contains("$UpdatedPartnerKeyURL$")) {
testCaseDTO.setEndPoint(
testCaseDTO.getEndPoint().replace("$UpdatedPartnerKeyURL$", PartnerRegistration.updatedpartnerKeyUrl));
}

if (testCaseDTO.getEndPoint().contains("$PartnerName$")) {
testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$PartnerName$", PartnerRegistration.partnerId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public void test(TestCaseDTO testCaseDTO)
testCaseDTO.setEndPoint(
testCaseDTO.getEndPoint().replace("$KycPartnerName$", PartnerRegistration.ekycPartnerId));
}

if (testCaseDTO.getEndPoint().contains("$UpdatedPartnerKeyURL$")) {
testCaseDTO.setEndPoint(
testCaseDTO.getEndPoint().replace("$UpdatedPartnerKeyURL$", PartnerRegistration.updatedpartnerKeyUrl));
}

String input = testCaseDTO.getInput();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.mosip.testrig.apirig.authentication.fw.util.OutputValidationUtil;
import io.mosip.testrig.apirig.authentication.fw.util.ReportUtil;
import io.mosip.testrig.apirig.global.utils.GlobalConstants;
import io.mosip.testrig.apirig.ida.certificate.PartnerRegistration;
import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.restassured.response.Response;
Expand Down Expand Up @@ -88,6 +89,11 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace(GlobalConstants.$PARTNERKEYURL$,
properties.getProperty("partnerKeyURL")));
}

if (testCaseDTO.getEndPoint().contains("$UpdatedPartnerKeyURL$")) {
testCaseDTO.setEndPoint(
testCaseDTO.getEndPoint().replace("$UpdatedPartnerKeyURL$", PartnerRegistration.updatedpartnerKeyUrl));
}
String otpRequest = null;
String sendOtpReqTemplate = null;
String sendOtpEndPoint = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.mosip.testrig.apirig.authentication.fw.util.OutputValidationUtil;
import io.mosip.testrig.apirig.authentication.fw.util.ReportUtil;
import io.mosip.testrig.apirig.global.utils.GlobalConstants;
import io.mosip.testrig.apirig.ida.certificate.PartnerRegistration;
import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.restassured.response.Response;
Expand Down Expand Up @@ -90,6 +91,11 @@ public void test(TestCaseDTO testCaseDTO) throws AdminTestException {
testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace(GlobalConstants.$PARTNERKEYURL$,
properties.getProperty("partnerKeyURL")));
}

if (testCaseDTO.getEndPoint().contains("$UpdatedPartnerKeyURL$")) {
testCaseDTO.setEndPoint(
testCaseDTO.getEndPoint().replace("$UpdatedPartnerKeyURL$", PartnerRegistration.updatedpartnerKeyUrl));
}
JSONObject req = new JSONObject(testCaseDTO.getInput());
String otpRequest = null;
String sendOtpReqTemplate = null;
Expand All @@ -112,7 +118,10 @@ public void test(TestCaseDTO testCaseDTO) throws AdminTestException {
sendOtpEndPoint = sendOtpEndPoint.replace(GlobalConstants.$PARTNERKEYURL$,
properties.getProperty("partnerKeyURL"));
}

if(sendOtpEndPoint.contains("$UpdatedPartnerKeyURL$"))
{
sendOtpEndPoint= sendOtpEndPoint.replace("$UpdatedPartnerKeyURL$", PartnerRegistration.updatedpartnerKeyUrl);
}
Response otpResponse = null;
if (isInternal)
otpResponse = postRequestWithCookieAuthHeaderAndSignature(ApplnURI + sendOtpEndPoint,
Expand Down
7 changes: 7 additions & 0 deletions automationtests/src/main/resources/config/AuthPolicy4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "string",
"metadata": {},
"request": {},
"requesttime": "2022-09-07T04:23:38.117Z",
"version": "string"
}
8 changes: 8 additions & 0 deletions automationtests/src/main/resources/config/AuthPolicy5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"desc":"desc mosip auth policy",
"name":"mosip auth policy 2345678",
"policyGroupName":"mosip auth policy group 2345678",
"policyType":"Auth",
"version": "1.0",
"policies": {}
}
41 changes: 41 additions & 0 deletions automationtests/src/main/resources/config/AuthPolicy6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"allowedAuthTypes": [
{
"authSubType": "IRIS",
"authType": "bio",
"mandatory": true
},
{
"authSubType": "FINGER",
"authType": "bio",
"mandatory": true
},
{
"authSubType": "FACE",
"authType": "bio",
"mandatory": true
},
{
"authSubType": "",
"authType": "otp-request",
"mandatory": false
},
{
"authSubType": "",
"authType": "kyc",
"mandatory": false
},
{
"authSubType": "",
"authType": "demo",
"mandatory": false
}
],
"kycLanguages": [
"ara",
"eng"
],
"allowedKycAttributes": [
],
"authTokenType": "partner"
}
63 changes: 62 additions & 1 deletion automationtests/src/main/resources/ida/BioAuth/BioAuth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ BioAuth:
role: resident
restMethod: post
inputTemplate: ida/BioAuth/BioAuth
outputTemplate: ida/BioAuth/BioAuthResult
outputTemplate: ida/BioAuth/error
input: '{
"bioSubType": "",
"bioType": "FACE",
Expand Down Expand Up @@ -1622,4 +1622,65 @@ BioAuth:
}'
output: '{
"authStatus": "true"
}'
auth_BioAuth_Biometric_Face_With_IRIS_as_true_anddo_bio_auth:
endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&partnerUrlSuffix=$UpdatedPartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$
role: resident
restMethod: post
inputTemplate: ida/BioAuth/BioAuth
outputTemplate: ida/BioAuth/error
input: '{
"bioSubType": "",
"bioType": "FACE",
"bioValue": "$FACE$",
"deviceCode": "bc0b6848-6d45-46d1-a9bd-b334410bf823",
"dateTime": "$DATETIME$",
"deviceProviderID": "1873299273",
"deviceServiceID": "",
"deviceServiceVersion": "SB.WIN.001",
"deviceProvider": "SYNCBYTE",
"deviceProviderId": "SYNCBYTE.LTC165",
"deviceSubType": "Single",
"make": "Logitech",
"model": "4d36e96c-e325-11ce-bfc1-08002be10318",
"serialNo": "78467171",
"type": "Face",
"transactionId": "$TRANSACTIONID$",
"timestamp": "$TIMESTAMP$"
}'
output: '{
"errors": [
{
"errorCode": "$IGNORE$"
}
],
"authStatus": false
}'
auth_BioAuth_Biometric_RightIris_With_MANDATORY_iris_in_policy:
endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&partnerUrlSuffix=$UpdatedPartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$
role: resident
restMethod: post
inputTemplate: ida/BioAuth/BioAuth
outputTemplate: ida/BioAuth/BioAuthResult
input: '{
"bioSubType": "Right",
"bioType": "Iris",
"bioValue": "$RIGHTIRIS$",
"deviceCode": "bc0b6848-6d45-46d1-a9bd-b334410bf823",
"dateTime": "$DATETIME$",
"deviceProviderID": "1873299273",
"deviceServiceID": "",
"deviceServiceVersion": "SB.WIN.001",
"deviceProvider": "SYNCBYTE",
"deviceProviderId": "SYNCBYTE.LTC165",
"deviceSubType": "Single",
"make": "Logitech",
"model": "4d36e96c-e325-11ce-bfc1-08002be10318",
"serialNo": "78467171",
"type": "Iris",
"transactionId": "$TRANSACTIONID$",
"timestamp": "$TIMESTAMP$"
}'
output: '{
"authStatus": "true"
}'
19 changes: 19 additions & 0 deletions automationtests/src/main/resources/ida/DemoAuth/DemoAuth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1252,4 +1252,23 @@ DemoAuthNew:
}'
output: '{
"authStatus": "false"
}'
auth_DemoAuth_gender_IRIS_as_true_anddo_auth_policy:
endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&transactionId=$TRANSACTIONID$&id=$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$&partnerUrlSuffix=$UpdatedPartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$
role: resident
restMethod: post
inputTemplate: ida/DemoAuth/DemoIdentityEncryptGender
outputTemplate: ida/DemoAuth/error
input: '{
"gender": [
{
"language": "$PRIMARYLANG$",
"value": "MLE"
}
],
"timestamp": "$TIMESTAMP$",
"transactionId": "$TRANSACTIONID$"
}'
output: '{
"authStatus": "false"
}'
30 changes: 30 additions & 0 deletions automationtests/src/main/resources/ida/EkycBio/EkycBio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@ EkycBio:
auth_EkycBio_Face_With_Deactivated_uin:
endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&transactionId=$TRANSACTIONID$&id=$id=$ID:AddIdentity_deactivate_UIN_smoke_sid_Pos_UIN$&isKyc=true&partnerUrlSuffix=$KycPartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$KycPartnerName$
role: resident
kycFields: ["email"]
restMethod: post
inputTemplate: ida/EkycBio/EkycBio
outputTemplate: ida/EkycBio/EkycBioResult
Expand Down Expand Up @@ -1398,4 +1399,33 @@ EkycBio:
}'
output: '{
"kycStatus": "false"
}'
auth_EkycBio_Face_With_Valid_withoutkyc_attribute_in_policy:
endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&transactionId=$TRANSACTIONID$&id=$ID:AddIdentity_Positive_EKYC_smoke_UIN$&isKyc=true&partnerUrlSuffix=$UpdatedPartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$
role: resident
kycFields: ["email"]
restMethod: post
inputTemplate: ida/EkycBio/EkycBio
outputTemplate: ida/EkycBio/error
input: '{
"bioSubType": "",
"bioType": "FACE",
"bioValue": "$FACE$",
"deviceCode": "bc0b6848-6d45-46d1-a9bd-b334410bf823",
"dateTime": "$DATETIME$",
"deviceProviderID": "1873299273",
"deviceServiceID": "",
"deviceServiceVersion": "SB.WIN.001",
"deviceProvider": "SYNCBYTE",
"deviceProviderId": "SYNCBYTE.LTC165",
"deviceSubType": "Single",
"make": "Logitech",
"model": "4d36e96c-e325-11ce-bfc1-08002be10318",
"serialNo": "78467171",
"type": "Face",
"transactionId": "$TRANSACTIONID$",
"timestamp": "$TIMESTAMP$"
}'
output: '{
"kycStatus": "false"
}'
Loading

0 comments on commit 3f2726e

Please sign in to comment.