Skip to content

Commit

Permalink
Merge pull request #1098 from Sohandey/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Sohandey authored Oct 3, 2023
2 parents 6606dc8 + d27bfba commit de968b0
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,13 +45,50 @@ 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";

String token = kernelAuthLib.getTokenByRole("partner");

HashMap<String, String> requestBody = new HashMap<>();

requestBody.put("policyName", policyName2);
requestBody.put("useCaseDescription", "mapping Partner to policyName");

HashMap<String, Object> 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<String, String> requestBody = new HashMap<>();

requestBody.put("policyName", policyName);
requestBody.put("useCaseDescription", "mapping Partner to policyName");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<String, String> 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<String, Object> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"authResponse": {
"body": {
"response": {
"kycStatus": {{kycStatus}}
}
}
}
}
Loading

0 comments on commit de968b0

Please sign in to comment.