From eac95016e147105b867ad7ddbe9bbbeb62261e62 Mon Sep 17 00:00:00 2001 From: Sohan Kumar Dey <72375959+Sohandey@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:45:09 +0530 Subject: [PATCH] MOSIP-29286 --- .../KeyCloakUserAndAPIKeyGeneration.java | 43 +++++ .../ida/certificate/PartnerRegistration.java | 50 +++++- .../apirig/testrunner/MosipTestRunner.java | 8 +- .../testrig/apirig/testscripts/BioAuth.java | 10 ++ .../BioAuthWithUnblockedPartners.yml | 169 ++++++++++++++++++ .../ida/BioAuthHotListLock/EkycBioResult.hbs | 9 + .../UnBlockHotlistAPIForPartnerId.yml | 15 ++ .../testNgXmlFiles/authenticationApi.xml | 8 + 8 files changed, 303 insertions(+), 9 deletions(-) create mode 100644 automationtests/src/main/resources/ida/BioAuthHotListLock/BioAuthWithUnblockedPartners.yml create mode 100644 automationtests/src/main/resources/ida/BioAuthHotListLock/EkycBioResult.hbs diff --git a/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/KeyCloakUserAndAPIKeyGeneration.java b/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/KeyCloakUserAndAPIKeyGeneration.java index 115d10aba2..5c0e14af95 100644 --- a/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/KeyCloakUserAndAPIKeyGeneration.java +++ b/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/KeyCloakUserAndAPIKeyGeneration.java @@ -20,11 +20,17 @@ public class KeyCloakUserAndAPIKeyGeneration extends AdminTestUtil { static String partnerId = PartnerRegistration.partnerId; static String emailId = PartnerRegistration.emailId; + static String emailIdForKyc = PartnerRegistration.emailIdForKyc; static String role = PartnerRegistration.partnerType; static String policyGroup = PartnerRegistration.policyGroup; static String randomAbbreviation = generateRandomAlphabeticString(4).toUpperCase(); static String policyName = AdminTestUtil.policyName; + static String policyGroup2 = AdminTestUtil.policyGroup2; + static String policyName2 = AdminTestUtil.policyName2; + + static String ekycPartnerId = PartnerRegistration.ekycPartnerId; + public static void setLogLevel() { if (ConfigManager.IsDebugEnabled()) lOGGER.setLevel(Level.ALL); @@ -39,6 +45,13 @@ public static String createKCUserAndGetAPIKey() { return createAPIKey(); } + public static String createKCUserAndGetAPIKeyForKyc() { + KeycloakUserManager.createKeyCloakUsers(ekycPartnerId, emailIdForKyc, role); + String mappingKey = submittingPartnerAndGetMappingKey(); + approvePartnerAPIKey(mappingKey); + return createAPIKey(); + } + public static String submittingPartnerAndGetMappingKey() { String url = ApplnURI + "/v1/partnermanager/partners/"+partnerId+"/policy/map"; @@ -46,6 +59,36 @@ public static String submittingPartnerAndGetMappingKey() { HashMap requestBody = new HashMap<>(); + requestBody.put("policyName", policyName2); + requestBody.put("useCaseDescription", "mapping Partner to policyName"); + + HashMap body = new HashMap<>(); + + body.put("id", GlobalConstants.STRING); + body.put(GlobalConstants.METADATA, new HashMap<>()); + body.put(GlobalConstants.REQUEST, requestBody); + body.put(GlobalConstants.REQUESTTIME, generateCurrentUTCTimeStamp()); + body.put(GlobalConstants.VERSION, GlobalConstants.STRING); + + Response response = RestClient.postRequestWithCookie(url, body, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, GlobalConstants.AUTHORIZATION, token); + lOGGER.info(response); + JSONObject responseJson = new JSONObject(response.asString()); + lOGGER.info(responseJson); + JSONObject responseValue = (JSONObject) (responseJson.get("response")); + lOGGER.info(responseValue); + String mappingKey = responseValue.getString("mappingkey"); + lOGGER.info(mappingKey); + + return mappingKey; + } + + public static String submittingPartnerAndGetMappingKeyForKyc() { + String url = ApplnURI + "/v1/partnermanager/partners/"+ekycPartnerId+"/policy/map"; + + String token = kernelAuthLib.getTokenByRole("partner"); + + HashMap requestBody = new HashMap<>(); + requestBody.put("policyName", policyName); requestBody.put("useCaseDescription", "mapping Partner to policyName"); diff --git a/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/PartnerRegistration.java b/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/PartnerRegistration.java index 599c44ccee..2def6a0e1f 100644 --- a/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/PartnerRegistration.java +++ b/automationtests/src/main/java/io/mosip/testrig/apirig/ida/certificate/PartnerRegistration.java @@ -29,6 +29,7 @@ public class PartnerRegistration extends AdminTestUtil { static String emailId = "mosip_1" + timeStamp + "@gmail.com"; static String emailId2 = "mosip_2" + timeStamp + "@gmail.com"; static String emailId3 = "mosip_3" + timeStamp + "@gmail.com"; + static String emailIdForKyc = "mosip_4" + timeStamp + "@gmail.com"; public static String organizationName = "mosip_partnerorg" + timeStamp; public static String ekycOrganizationName = "mosip_ekyc_partner" + timeStamp; public static String deviceOrganizationName = "mosip_deviceorg" + timeStamp; @@ -37,10 +38,13 @@ public class PartnerRegistration extends AdminTestUtil { public static String ekycPartnerId = ekycOrganizationName; public static String partnerType = "AUTH_PARTNER"; static String getPartnerType = "RELYING_PARTY"; - static String getEkycPartnerType = "EKYC"; + static String getEkycPartnerType = "AUTH_PARTNER"; + static String getEkycPartnerTypeForCert = "EKYC"; public static String apiKey = ""; + public static String kycApiKey = ""; public static String mispLicKey =""; public static String policyGroup = AdminTestUtil.policyGroup; + public static String policyGroupForKyc = AdminTestUtil.policyGroup2; public static void setLogLevel() { if (ConfigManager.IsDebugEnabled()) @@ -84,17 +88,19 @@ public static String generateAndGetEkycPartnerKeyUrl() { return ConfigManager.getPartnerUrlSuffix(); } - ftmGeneration(); - deviceGeneration(); + /* + * ftmGeneration(); deviceGeneration(); + */ getAndUploadEkycCertificates(); + kycApiKey = KeyCloakUserAndAPIKeyGeneration.createKCUserAndGetAPIKeyForKyc(); if (apiKey.isEmpty() || mispLicKey.isEmpty()) { lOGGER.error("Failed to generate API key and MISP Lic key"); return ""; } - ekycPartnerKeyUrl = mispLicKey + "/" + ekycPartnerId + "/" + apiKey; + ekycPartnerKeyUrl = mispLicKey + "/" + ekycPartnerId + "/" + kycApiKey; lOGGER.info("ekycPartnerKeyUrl = " + ekycPartnerKeyUrl); @@ -131,8 +137,8 @@ public static void getAndUploadEkycCertificates() { localHostUrl = getLocalHostUrl(); } - partnerGeneration(); - JSONObject certificateValue = getCertificates(ekycPartnerId, getEkycPartnerType); + partnerKycGeneration(); + JSONObject certificateValue = getCertificates(ekycPartnerId, getEkycPartnerTypeForCert); String caCertValue = certificateValue.getString("caCertificate"); lOGGER.info(caCertValue); String interCertValue = certificateValue.getString("interCertificate"); @@ -186,6 +192,38 @@ public static void partnerGeneration() { JSONObject responseValue = (JSONObject) (responseJson.get("response")); lOGGER.info(responseValue); } + + public static void partnerKycGeneration() { + String url = ApplnURI + properties.getProperty("putPartnerRegistrationUrl"); + + String token = kernelAuthLib.getTokenByRole("partner"); + + HashMap requestBody = new HashMap<>(); + + requestBody.put("address", address); + requestBody.put("contactNumber", contactNumber); + requestBody.put("emailId", emailIdForKyc); + requestBody.put("organizationName", ekycOrganizationName); + requestBody.put(GlobalConstants.PARTNERID, ekycPartnerId); + requestBody.put("partnerType", getEkycPartnerType); + requestBody.put("policyGroup", policyGroupForKyc); + + HashMap body = new HashMap<>(); + + body.put("id", GlobalConstants.STRING); + body.put(GlobalConstants.METADATA, new HashMap<>()); + body.put(GlobalConstants.REQUEST, requestBody); + body.put(GlobalConstants.REQUESTTIME, generateCurrentUTCTimeStamp()); + body.put(GlobalConstants.VERSION, "LTS"); + + Response response = RestClient.postRequestWithCookie(url, body, MediaType.APPLICATION_JSON, + MediaType.APPLICATION_JSON, GlobalConstants.AUTHORIZATION, token); + lOGGER.info(response); + JSONObject responseJson = new JSONObject(response.asString()); + lOGGER.info(responseJson); + JSONObject responseValue = (JSONObject) (responseJson.get("response")); + lOGGER.info(responseValue); + } public static JSONObject getCertificates(String partnerId, String partnerType) { if (localHostUrl == null) { diff --git a/automationtests/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java b/automationtests/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java index 2bd08987ad..5963351bdf 100644 --- a/automationtests/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java +++ b/automationtests/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java @@ -89,15 +89,17 @@ public static void main(String[] arg) { AdminTestUtil.getLocationData(); String partnerKeyURL = ""; - //String ekycPartnerKeyURL = ""; + String ekycPartnerKeyURL = ""; if (BaseTestCase.listOfModules.contains("auth") || BaseTestCase.listOfModules.contains(GlobalConstants.ESIGNET)) { PartnerRegistration.deleteCertificates(); CertificateGenerationUtil.getThumbprints(); AdminTestUtil.createAndPublishPolicy(); - //AdminTestUtil.createAndPublishPolicyForKyc(); partnerKeyURL = PartnerRegistration.generateAndGetPartnerKeyUrl(); + + + //AdminTestUtil.createAndPublishPolicyForKyc(); //ekycPartnerKeyURL = PartnerRegistration.generateAndGetEkycPartnerKeyUrl(); } @@ -123,7 +125,7 @@ public static void main(String[] arg) { } else if (BaseTestCase.listOfModules.contains("auth") || BaseTestCase.listOfModules.contains(GlobalConstants.ESIGNET)) { - if (partnerKeyURL.isEmpty()) + if (partnerKeyURL.isEmpty() || ekycPartnerKeyURL.isEmpty()) LOGGER.error("partnerKeyURL is null"); else startTestRunner(); diff --git a/automationtests/src/main/java/io/mosip/testrig/apirig/testscripts/BioAuth.java b/automationtests/src/main/java/io/mosip/testrig/apirig/testscripts/BioAuth.java index 5ab78e280f..3a078a59cd 100644 --- a/automationtests/src/main/java/io/mosip/testrig/apirig/testscripts/BioAuth.java +++ b/automationtests/src/main/java/io/mosip/testrig/apirig/testscripts/BioAuth.java @@ -105,9 +105,19 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad testCaseDTO.setEndPoint( testCaseDTO.getEndPoint().replace("$PartnerKeyURL$", PartnerRegistration.partnerKeyUrl)); } + + if (testCaseDTO.getEndPoint().contains("$KycPartnerKeyURL$")) { + testCaseDTO.setEndPoint( + testCaseDTO.getEndPoint().replace("$KycPartnerKeyURL$", PartnerRegistration.ekycPartnerKeyUrl)); + } + if (testCaseDTO.getEndPoint().contains("$PartnerName$")) { testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$PartnerName$", PartnerRegistration.partnerId)); } + + if (testCaseDTO.getEndPoint().contains("$KycPartnerName$")) { + testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$KycPartnerName$", PartnerRegistration.ekycPartnerId)); + } String request = testCaseDTO.getInput(); request = buildIdentityRequest(request); diff --git a/automationtests/src/main/resources/ida/BioAuthHotListLock/BioAuthWithUnblockedPartners.yml b/automationtests/src/main/resources/ida/BioAuthHotListLock/BioAuthWithUnblockedPartners.yml new file mode 100644 index 0000000000..aaff721b3e --- /dev/null +++ b/automationtests/src/main/resources/ida/BioAuthHotListLock/BioAuthWithUnblockedPartners.yml @@ -0,0 +1,169 @@ +BioAuth: + auth_BioAuth_Biometric_Face_With_Unblocked_Partners_Smoke_Pos: + endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&partnerUrlSuffix=$PartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$ + role: resident + restMethod: post + inputTemplate: ida/BioAuthHotListLock/BioAuth + outputTemplate: ida/BioAuthHotListLock/BioAuthResult + 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: '{ + "authStatus": "true" +}' + auth_BioAuth_Biometric_RingFinger_With__Unblocked_Partners: + endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&partnerUrlSuffix=$PartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$ + role: resident + restMethod: post + inputTemplate: ida/BioAuthHotListLock/BioAuth + outputTemplate: ida/BioAuthHotListLock/BioAuthResult + input: '{ + "bioSubType": "Left RingFinger", + "bioType": "Finger", + "bioValue": "$LEFTRINGFINGER$", + "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": "Finger", + "transactionId": "$TRANSACTIONID$", + "timestamp": "$TIMESTAMP$" + }' + output: '{ + "authStatus": "true" +}' + auth_BioAuth_Biometric_LeftIndexFingerr__Unblocked_Partners: + endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&partnerUrlSuffix=$PartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$ + role: resident + restMethod: post + inputTemplate: ida/BioAuthHotListLock/BioAuth + outputTemplate: ida/BioAuthHotListLock/BioAuthResult + input: '{ + "bioSubType": "Left IndexFinger", + "bioType": "Finger", + "bioValue": "$LEFTINDEXFINGER$", + "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": "Finger", + "transactionId": "$TRANSACTIONID$", + "timestamp": "$TIMESTAMP$" + }' + output: '{ + "authStatus": "true" +}' + auth_BioAuth_Biometric_IRIS_With__Unblocked_Partners: + endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&partnerUrlSuffix=$PartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$ + role: resident + restMethod: post + inputTemplate: ida/BioAuthHotListLock/BioAuth + outputTemplate: ida/BioAuthHotListLock/EkycBioResult + 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" +}' + auth_EkycBio_LeftMiddleFingerr__Unblocked_Partners: + endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&transactionId=$TRANSACTIONID$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&isKyc=true&partnerUrlSuffix=$PartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$ + role: resident + restMethod: post + inputTemplate: ida/BioAuthHotListLock/BioAuth + outputTemplate: ida/BioAuthHotListLock/EkycBioResult + input: '{ + "bioSubType": "Left MiddleFinger", + "bioType": "Finger", + "bioValue": "$LEFTMIDDLEFINGER$", + "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": "Finger", + "transactionId": "$TRANSACTIONID$", + "timestamp": "$TIMESTAMP$" + }' + output: '{ + "kycStatus": "true" +}' + auth_EkycBio_RIGHTIRIS_With__Unblocked_Partners: + endPoint: /v1/identity/authenticate?moduleName=$MODULENAME$&certsDir=$CERTSDIR$&transactionId=$TRANSACTIONID$&id=$ID:AddIdentity_ValidParam_smoke_Pos_UIN$&isKyc=true&partnerUrlSuffix=$PartnerKeyURL$&keyFileNameByPartnerName=true&partnerName=$PartnerName$ + role: resident + restMethod: post + inputTemplate: ida/BioAuthHotListLock/BioAuth + outputTemplate: ida/BioAuthHotListLock/EkycBioResult + 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: '{ + "kycStatus": "true" +}' \ No newline at end of file diff --git a/automationtests/src/main/resources/ida/BioAuthHotListLock/EkycBioResult.hbs b/automationtests/src/main/resources/ida/BioAuthHotListLock/EkycBioResult.hbs new file mode 100644 index 0000000000..9d51fe4b7f --- /dev/null +++ b/automationtests/src/main/resources/ida/BioAuthHotListLock/EkycBioResult.hbs @@ -0,0 +1,9 @@ +{ + "authResponse": { + "body": { + "response": { + "kycStatus": {{kycStatus}} + } + } + } +} \ No newline at end of file diff --git a/automationtests/src/main/resources/ida/UnBlockHotlistAPI/UnBlockHotlistAPIForPartnerId.yml b/automationtests/src/main/resources/ida/UnBlockHotlistAPI/UnBlockHotlistAPIForPartnerId.yml index b144357c1f..316f8b9619 100644 --- a/automationtests/src/main/resources/ida/UnBlockHotlistAPI/UnBlockHotlistAPIForPartnerId.yml +++ b/automationtests/src/main/resources/ida/UnBlockHotlistAPI/UnBlockHotlistAPIForPartnerId.yml @@ -25,6 +25,21 @@ HotlistAPI: "idType": "PARTNER_ID", "requestTime": "$TIMESTAMP$", "expiryTimestamp": "" + }' + output: '{ + "status": "UNBLOCKED" + }' + auth_HotlistAPI_All_Valid_Smoke_Unblock_MISP_KEY_sid: + endPoint: /v1/hotlist/unblock + role: hotlist + restMethod: post + inputTemplate: ida/UnBlockHotlistAPI/UnblockHotlistAPI + outputTemplate: ida/UnBlockHotlistAPI/UnblockHotlistAPIResult + input: '{ + "id": "$APIKEY$", + "idType": "PARTNER_ID", + "requestTime": "$TIMESTAMP$", + "expiryTimestamp": "" }' output: '{ "status": "UNBLOCKED" diff --git a/automationtests/testNgXmlFiles/authenticationApi.xml b/automationtests/testNgXmlFiles/authenticationApi.xml index a4430075eb..8d0572ecfc 100644 --- a/automationtests/testNgXmlFiles/authenticationApi.xml +++ b/automationtests/testNgXmlFiles/authenticationApi.xml @@ -286,4 +286,12 @@ + + + + + + +