diff --git a/apitest-commons/README.md b/apitest-commons/README.md
index 60537aa052..5f3324c2e0 100644
--- a/apitest-commons/README.md
+++ b/apitest-commons/README.md
@@ -24,6 +24,7 @@ Ensure the following software is installed on the machine from where the automat
- **Java 21** ([download here](https://jdk.java.net/)).
- **Maven 3.9.6** or higher ([installation guide](https://maven.apache.org/install.html)).
- **Lombok** (Refer to [Lombok Project](https://projectlombok.org/))
+- **setting.xml** ([download here](https://github.com/mosip/mosip-functional-tests/blob/master/settings.xml))
---
diff --git a/apitest-commons/pom.xml b/apitest-commons/pom.xml
index 7b0ce9b3a7..9aa18f2014 100644
--- a/apitest-commons/pom.xml
+++ b/apitest-commons/pom.xml
@@ -2,7 +2,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- io.mosip.testrig.apirig.apitest.commons
+ io.mosip.testrig.apitest.commons
apitest-commons
jar
apitest-commons
@@ -36,7 +36,7 @@
UTF-8
- 1.2.1-SNAPSHOT
+ 1.3.0-beta.1
21
@@ -59,7 +59,7 @@
1.1.2-incubating
- 1.2.1-SNAPSHOT
+ 1.3.0-beta.1
0.4.7
3.0.0
2.41.2
@@ -67,7 +67,6 @@
6.11
1.13
apitest-commons-1.2.2-cleanup-SNAPSHOT-jar-with-dependencies
-
@@ -377,7 +376,7 @@
io.mosip.mock.mds
mock-mds
- 1.2.1-SNAPSHOT
+ 1.3.0-beta.1
javax.xml.bind
@@ -437,13 +436,13 @@
io.mosip.kernel
kernel-templatemanager-velocity
- 1.2.1-SNAPSHOT
+ 1.3.0-beta.1
io.mosip.kernel
kernel-keymanager-service
- 1.2.1-SNAPSHOT
+ 1.3.0-beta.1
lib
@@ -482,7 +481,7 @@
io.mosip.kernel
kernel-bom
- 1.2.1-SNAPSHOT
+ 1.3.0-beta.1
pom
import
@@ -725,4 +724,4 @@
-
\ No newline at end of file
+
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java
index b5519334fd..cde54dd4d1 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java
@@ -64,6 +64,7 @@ public class BaseTestCase {
public String regProcCookie = null;
public String regProCookie = null;
public String regAdminCookie = null;
+ public String invalidcookie = "anyRandomString";
public String registrationOfficerCookie = null;
public String regSupervisorCookie = null;
public String zonalAdminCookie = null;
@@ -137,6 +138,7 @@ public class BaseTestCase {
public static String locationCode = "";
public static String ZonelocationCode = "";
+ public static String leafZoneCode = "";
public static String hierarchyZoneCode = "";
public static String genRid = "27847" + generateRandomNumberString(10);
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/HealthChecker.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/HealthChecker.java
index 662af9fff3..8cfcafbb86 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/HealthChecker.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/HealthChecker.java
@@ -119,6 +119,7 @@ public void run() {
public static String checkActuatorNoAuth(String actuatorURL) {
Response response = null;
+ actuatorURL = GlobalMethods.addToServerEndPointMap(actuatorURL);
response = given().contentType(ContentType.JSON).get(actuatorURL);
if (response != null && response.getStatusCode() == 200) {
logger.info(response.getBody().asString());
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java
index 67e2f44d33..700e6156a4 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java
@@ -56,6 +56,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
+import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
@@ -152,7 +153,6 @@ public class AdminTestUtil extends BaseTestCase {
protected static String signupAutoGeneratedIdPropFileName = null;
protected static String fullNameForSunBirdRC = null;
protected static String dobForSunBirdRC = null;
-
public static String PASSWORD_FOR_ADDIDENTITY_AND_REGISTRATION = null;
public static String PASSWORD_TO_RESET = null;
public static final String RESOURCE_FOLDER_NAME = "MosipTemporaryTestResource";
@@ -2014,6 +2014,40 @@ protected Response postWithPathParamsBodyAndCookie(String url, String jsonInput,
return response;
}
}
+
+
+ protected Response postWithPathParamsBodyAndCookieForAutoGeneratedId(String url, String jsonInput,
+ String cookieName, String role, String testCaseName, String pathParams, String idKeyName) {
+ Response response = null;
+ String inputJson = inputJsonKeyWordHandeler(jsonInput, testCaseName);
+ url = uriKeyWordHandelerUri(url, testCaseName);
+ JSONObject req = new JSONObject(inputJson);
+ HashMap pathParamsMap = new HashMap<>();
+ String[] params = pathParams.split(",");
+ for (String param : params) {
+ if (req.has(param)) {
+ pathParamsMap.put(param, req.get(param).toString());
+ req.remove(param);
+ } else
+ logger.error(GlobalConstants.ERROR_STRING_2 + param + GlobalConstants.IN_STRING + inputJson);
+ }
+
+ token = kernelAuthLib.getTokenByRole(role);
+ logger.info(GlobalConstants.POST_REQ_URL + url);
+ GlobalMethods.reportRequest(null, inputJson, url);
+ try {
+ response = RestClient.postWithPathParamsBodyAndCookie(url, pathParamsMap, req.toString(),
+ MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, cookieName, token);
+ GlobalMethods.reportResponse(response.getHeaders().asList().toString(), url, response);
+
+ if (testCaseName.toLowerCase().contains("_sid")) {
+ writeAutoGeneratedId(response, idKeyName, testCaseName);
+ }
+ } catch (Exception e) {
+ logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
+ }
+ return response;
+ }
protected Response postWithPathParamsBodyHeaderAndCookie(String url, String jsonInput, String cookieName,
String role, String testCaseName, String pathParams) {
@@ -3292,6 +3326,15 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
// }
// jsonString = replaceKeywordWithValue(jsonString, "$PHONENUMBERFORIDENTITY$", phoneNumber);
// }
+
+ if (jsonString.contains("$NRCID$")) {
+ String nrcId = (100000 + new Random().nextInt(900000)) + "/" + (10 + new Random().nextInt(90)) + "/" + (1 + new Random().nextInt(9));
+
+ jsonString = replaceKeywordWithValue(jsonString, "$NRCID$", nrcId);
+ }
+
+
+
if (jsonString.contains("$1STLANG$"))
jsonString = replaceKeywordWithValue(jsonString, "$1STLANG$", BaseTestCase.languageList.get(0));
if (jsonString.contains("$2NDLANG$"))
@@ -3389,6 +3432,9 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
if (jsonString.contains("$USERID$"))
jsonString = replaceKeywordWithValue(jsonString, "$USERID$",
BaseTestCase.currentModule + ConfigManager.getproperty("admin_userName"));
+
+ if (jsonString.contains("$LEAF_ZONE_CODE$"))
+ jsonString = replaceKeywordWithValue(jsonString, "$LEAF_ZONE_CODE$", leafZoneCode);
if (jsonString.contains("$LOCATIONCODE$"))
jsonString = replaceKeywordWithValue(jsonString, "$LOCATIONCODE$", locationCode);
@@ -4027,21 +4073,25 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
// signJWKForMock(clientId, accessToken, oidcJWKKey4, testCaseName, tempUrl));
// }
- if (jsonString.contains(GlobalConstants.IDT_TOKEN) && jsonString.contains("$IDTINDIVIUALID$") && jsonString.contains("$IDTCHALLENGE$")) {
+ if (jsonString.contains(GlobalConstants.IDT_TOKEN)) {
+
JSONObject request = new JSONObject(jsonString);
String idtToken = request.get(GlobalConstants.IDT_TOKEN).toString();
request.remove(GlobalConstants.IDT_TOKEN);
jsonString = request.toString();
-
Map map = new HashMap<>();
map.put(GlobalConstants.TOKEN, idtToken);
JSONObject encodingToken = new JSONObject(map);
- String challenge = encodeBase64(encodingToken.toString());
- String individualId = getSubjectFromJwt(idtToken);
+ if (jsonString.contains("$IDTINDIVIUALID$")) {
+ String individualId = getSubjectFromJwt(idtToken);
+ jsonString = replaceKeywordWithValue(jsonString, "$IDTINDIVIUALID$", individualId);
+ }
- jsonString = replaceKeywordWithValue(jsonString, "$IDTINDIVIUALID$", individualId);
- jsonString = replaceKeywordWithValue(jsonString, "$IDTCHALLENGE$", challenge);
+ if (jsonString.contains("$IDTCHALLENGE$")) {
+ String challenge = encodeBase64(encodingToken.toString());
+ jsonString = replaceKeywordWithValue(jsonString, "$IDTCHALLENGE$", challenge);
+ }
}
@@ -5300,7 +5350,7 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) {
JSONObject requestJson = new JSONObject();
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
- String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String url = getSchemaURL();
Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);
@@ -5325,6 +5375,8 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) {
String phone = getValueFromAuthActuator("json-property", "phone_number");
String result = phone.replaceAll("\\[\"|\"\\]", "");
+
+
if (!isElementPresent(requiredPropsArray, result)) {
requiredPropsArray.put(result);
@@ -5384,7 +5436,15 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) {
//"tags": ":["handle"]
eachValueJsonForHandles.put("tags", handleArray);
selectedHandles.add(result);
- } else {
+ }
+
+ else if (eachRequiredProp.equals("nrcId")) {
+ eachValueJsonForHandles.put("value", "$NRCID$");
+ eachValueJsonForHandles.put("tags", handleArray);
+ selectedHandles.add("nrcId");
+ }
+
+ else {
eachValueJsonForHandles.put("value", "$FUNCTIONALID$");
eachValueJsonForHandles.put("tags", handleArray);
selectedHandles.add(eachRequiredProp);
@@ -5452,6 +5512,14 @@ else if (eachPropDataJson.has("$ref") && eachPropDataJson.get("$ref").toString()
identityJson.put(eachRequiredProp, "$EMAILVALUE$");
}
+ else if (eachRequiredProp.equals("nrcId")) {
+ String nrcID = "$NRCID$";
+ if(eachPropDataJson.has("handle")){
+ selectedHandles.add(eachRequiredProp);
+ }
+ identityJson.put(eachRequiredProp, nrcID);
+ }
+
else if (eachRequiredProp.equals("password")) {
identityJson.put(eachRequiredProp, new HashMap<>());
if (addIdentityPassword.isBlank() && addIdentitySalt.isBlank())
@@ -5512,6 +5580,18 @@ else if (eachRequiredProp.equals("password")) {
identityHbs = requestJson.toString();
return identityHbs;
}
+
+
+ public static String getSchemaURL() {
+ String schemaURL = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String schemaVersion = ConfigManager.getproperty(GlobalConstants.SCHEMA_VERSION);
+
+ if (schemaVersion != null && !schemaVersion.isEmpty()) {
+ schemaURL = schemaURL + "?schemaVersion=" + schemaVersion;
+ }
+
+ return schemaURL;
+ }
public static String updateIdentityHbs(boolean regenerateHbs) {
@@ -5522,7 +5602,7 @@ public static String updateIdentityHbs(boolean regenerateHbs) {
JSONObject requestJson = new JSONObject();
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
- String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String url = getSchemaURL();
Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);
@@ -5607,11 +5687,21 @@ public static String updateIdentityHbs(boolean regenerateHbs) {
//"tags": ":["handle"]
eachValueJsonForHandles.put("tags", handleArray);
selectedHandles.add(result);
- } else {
+ }
+
+ else if (eachRequiredProp.equals("nrcId")) {
+ eachValueJsonForHandles.put("value", "$NRCID$");
+ eachValueJsonForHandles.put("tags", handleArray);
+ selectedHandles.add("nrcId");
+ }
+
+ else {
eachValueJsonForHandles.put("value", "$FUNCTIONALID$");
eachValueJsonForHandles.put("tags", handleArray);
selectedHandles.add(eachRequiredProp);
}
+
+
eachPropDataArrayForHandles.put(eachValueJsonForHandles);
identityJson.put(eachRequiredProp, eachPropDataArrayForHandles);
@@ -5665,6 +5755,13 @@ else if (eachRequiredProp.equals(result)) {
}
identityJson.put(eachRequiredProp, "$PHONENUMBERFORIDENTITY$");
}
+ else if (eachRequiredProp.equals("nrcId")) {
+ String nrcID = "$NRCID$";
+ if(eachPropDataJson.has("handle")){
+ selectedHandles.add(eachRequiredProp);
+ }
+ identityJson.put(eachRequiredProp, nrcID);
+ }
else if (eachRequiredProp.equals("proofOfIdentity")) {
identityJson.remove("proofOfIdentity");
}
@@ -5710,7 +5807,7 @@ else if (eachRequiredProp.equals("proofOfIdentity")) {
public static String generateLatestSchemaVersion() {
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
- String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String url = getSchemaURL();
Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);
@@ -5733,7 +5830,7 @@ public static String generateHbsForUpdateDraft() {
JSONObject requestJson = new JSONObject();
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
- String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String url = getSchemaURL();
Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);
@@ -5797,6 +5894,11 @@ public static String generateHbsForUpdateDraft() {
identityJson.getJSONObject(eachRequiredProp).put("type", "DOC001");
identityJson.getJSONObject(eachRequiredProp).put("value", "fileReferenceID");
}
+
+ else if (eachRequiredProp.equals("nrcId")) {
+ String nrcID = "$NRCID$";
+ identityJson.put(eachRequiredProp, nrcID);
+ }
else if (eachRequiredProp.equals("individualBiometrics")) {
identityJson.put(eachRequiredProp, new HashMap<>());
@@ -6022,7 +6124,7 @@ public static String generateHbsForPrereg(boolean isItUpdate) {
JSONObject requestJson = new JSONObject();
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
- String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String url = getSchemaURL();
Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);
@@ -7098,8 +7200,6 @@ public static void addTestCaseDetailsToMap(String testCaseName,String uniqueIden
public static String getTestCaseUniqueIdentifier(String testCaseName) {
return testcaseIDNameMap.get(testCaseName);
}
-
-
public static String getRandomElement(List list) {
int randomIndex = secureRandom.nextInt(list.size());
return list.get(randomIndex);
@@ -7652,6 +7752,34 @@ public static void getZoneName() {
}
}
+ public static void getLeafZone() {
+
+ Response response = null;
+ JSONObject responseJson = null;
+ String url = ApplnURI + props.getProperty("leafZoneUrl") + BaseTestCase.getLanguageList().get(0);
+ String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
+
+ try {
+
+ response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
+ GlobalConstants.AUTHORIZATION, token);
+
+ responseJson = new JSONObject(response.getBody().asString());
+
+ try {
+ JSONObject responseObject = responseJson.getJSONArray("response").getJSONObject(0);
+
+ leafZoneCode = responseObject.getString("code");
+
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+
+ } catch (Exception e) {
+ logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
+ }
+ }
+
public static void getRegistrationCenterData() {
Response response = null;
@@ -7988,7 +8116,7 @@ public static JSONArray getRequiredField() {
JSONObject requestJson = new JSONObject();
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
- String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
+ String url = getSchemaURL();
Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);
@@ -8158,4 +8286,3 @@ public static boolean isValidToken(String cookie) {
}
-
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/BioDataUtility.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/BioDataUtility.java
index 1c142097e3..aff5cdf97b 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/BioDataUtility.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/BioDataUtility.java
@@ -153,15 +153,7 @@ public String constractBioIdentityRequest(String identityRequest, String bioValu
String transactionId = JsonPrecondtion.getValueFromJson(data, GlobalConstants.TRANSACTIONID);
String encryptedContent = encryptIsoBioValue(bioValue, timestamp, bioValueencryptionTemplateJson,
transactionId, isInternal);
- String encryptedBioValue = JsonPrecondtion.getValueFromJson(encryptedContent, "encryptedData");
-
-
-
- identityRequest = JsonPrecondtion.parseAndReturnJsonContent(identityRequest, BaseTestCase.ApplnURI,
- biometricsMapper + ".data.domainUri");
-
-
-
+ String encryptedBioValue = JsonPrecondtion.getValueFromJson(encryptedContent, "encryptedData");
logger.info(identityRequest);
String encryptedSessionKey = JsonPrecondtion.getValueFromJson(encryptedContent, "encryptedSessionKey");
identityRequest = JsonPrecondtion.parseAndReturnJsonContent(identityRequest, encryptedBioValue,
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java
index 27fa513cf4..f16d1592da 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java
@@ -99,6 +99,7 @@ public class GlobalConstants {
public static final String MOSIP_ESIGNET_ACCESS_TOKEN_EXPIRE_SECONDS = "mosip.esignet.access-token-expire-seconds";
public static final String ERROR_BOOK_APPOINTMENT = "Failed to fetch registration details while booking appointment";
public static final String MASTER_SCHEMA_URL = "masterSchemaURL";
+ public static final String SCHEMA_VERSION = "schemaVersion";
public static final String ID_VERSION = "idVersion";
public static final String SCHEMA_JSON = "schemaJson";
public static final String REQUIRED = "required";
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalMethods.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalMethods.java
index 4c03bea8b8..05e6125101 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalMethods.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalMethods.java
@@ -26,7 +26,7 @@ public class GlobalMethods {
public static Set serverEndpoints = new HashSet<>();
// Define the regex pattern to extract the domain and the path after the domain
- private static final String module_name = "(mimoto|partnermanager|preregistration|resident|residentmobileapp|masterdata|esignet|idgenerator|policymanager|idauthentication|idrepository|auditmanager|authmanager)";
+ private static final String module_name = "(mimoto|certify|signup|partnermanager|preregistration|resident|residentmobileapp|masterdata|esignet|idgenerator|policymanager|idauthentication|idrepository|auditmanager|authmanager|keymanager)";
private static final String regex_1 = "https://([^/]+)/(v[0-9]+)?/" + module_name + "/([^,]+)";
private static final String regex_2 = "https://([^/]+)/" + module_name + "/(v[0-9]+)/([^,]+)";
diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java
index 0aa77331d0..164d04c659 100644
--- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java
+++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java
@@ -1,8 +1,15 @@
package io.mosip.testrig.apirig.utils;
+import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import java.util.Base64.Encoder;
+import java.util.Date;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.DecodedJWT;
import org.json.simple.JSONObject;
@@ -16,6 +23,7 @@ public class KernelAuthentication extends BaseTestCase {
String folder = "kernel";
String cookie;
static String dataKey = "response";
+ static String encodeBase64 ="";
static String errorKey = "errors";
static Map tokens = new HashMap<>();
// CommonLibrary clib = new CommonLibrary();
@@ -171,9 +179,10 @@ public String getTokenByRole(String role, String tokenType) {
if (!AdminTestUtil.isValidToken(invalidBatchJobToken))
invalidBatchJobToken = kernelAuthLib.getPreRegInvalidToken();
return invalidBatchJobToken;
-
case "invalid":
return "anyRandomString";
+ case "invalidtoken":
+ return kernelAuthLib.encodeBase64("AnyRandomString-ToCreate-Jwt");
case "regAdmin":
if (!AdminTestUtil.isValidToken(regAdminCookie))
regAdminCookie = kernelAuthLib.getAuthForRegistrationAdmin();
@@ -781,5 +790,20 @@ public String getAuthForAutoUser() {
cookie = reponse.getCookie(GlobalConstants.AUTHORIZATION);
return cookie;
}
+
+ @SuppressWarnings("unchecked")
+ public String encodeBase64(String value) {
+ String secret = value;
+ // Create the token
+ String token = JWT.create()
+ .withSubject("user123")
+ .withIssuer("example.com")
+ .withClaim("role", "admin")
+ .withIssuedAt(new Date())
+ .withExpiresAt(new Date(System.currentTimeMillis() + 3600000))
+ .sign(Algorithm.HMAC256(secret));
+ System.out.println("Generated Token: " + token);
+ return token;
+ }
}
diff --git a/apitest-commons/src/main/resources/config/Kernel.properties b/apitest-commons/src/main/resources/config/Kernel.properties
index b88adfcf24..678b5d0428 100644
--- a/apitest-commons/src/main/resources/config/Kernel.properties
+++ b/apitest-commons/src/main/resources/config/Kernel.properties
@@ -220,14 +220,14 @@ ida_db_schema=ida
#------------------------ Generic properties ------------------------#
-enableDebug=yes
+enableDebug=no
preconfiguredOtp=111111
usePreConfiguredOtp=false
# supported values yes or no. Assume that by Default e-signet is deployed
eSignetDeployed=yes
partnerUrlSuffix=oYf63Lax0DY2QkYMRHnrmDqhmO3RMWQagwm0ftgLlkuin1KOND/666/576732
-reportIgnoredTestCases=no
-reportKnownIssueTestCases=no
+reportIgnoredTestCases=yes
+reportKnownIssueTestCases=yes
servicesNotDeployed=
esignetMockBaseURL=esignet-insurance.
sunBirdBaseURL=registry
@@ -269,4 +269,4 @@ authCertsPath=/home/mosip/authcerts
mosip_components_base_urls=
-#auditmanager=api-internal.released.mosip.net;idrepository=api-internal.released.mosip.net;partnermanager=api-internal.released.mosip.net;idauthentication=api-internal.released.mosip.net;policymanager=api-internal.released.mosip.net;authmanager=api-internal.released.mosip.net;resident=api-internal.released.mosip.net;preregistration=api-internal.released.mosip.net;masterdata=api-internal.released.mosip.net;idgenerator=api-internal.released.mosip.net;
\ No newline at end of file
+#auditmanager=api-internal.released.mosip.net;idrepository=api-internal.released.mosip.net;authmanager=api-internal.released.mosip.net;resident=api-internal.released.mosip.net;partnermanager=api-internal.released.mosip.net;idauthentication=api-internal.released.mosip.net;masterdata=api-internal.released.mosip.net;idgenerator=api-internal.released.mosip.net;policymanager=api-internal.released.mosip.net;preregistration=api-internal.released.mosip.net;keymanager=api-internal.released.mosip.net
diff --git a/deploy/apitestrig/install.sh b/deploy/apitestrig/install.sh
index cd6d4783af..cfaed8c31e 100755
--- a/deploy/apitestrig/install.sh
+++ b/deploy/apitestrig/install.sh
@@ -17,10 +17,10 @@ function installing_apitestrig() {
kubectl label ns $NS istio-injection=disabled --overwrite
helm repo update
- echo Copy configmaps
+ echo Copy Configmaps
./copy_cm.sh
- echo Copy secrets
+ echo Copy Secrtes
./copy_secrets.sh
echo "Delete s3, db, & apitestrig configmap if exists"
@@ -90,29 +90,80 @@ function installing_apitestrig() {
else
echo "eSignet service is not deployed. hence will be skipping esignet related test-cases..."
fi
-
- echo Installing apitestrig
- helm -n $NS install apitestrig mosip/apitestrig \
- --set crontime="0 $time * * *" \
- -f values.yaml \
- --version $CHART_VERSION \
- --set apitestrig.configmaps.s3.s3-host='http://minio.minio:9000' \
- --set apitestrig.configmaps.s3.s3-user-key='admin' \
- --set apitestrig.configmaps.s3.s3-region='' \
- --set apitestrig.configmaps.db.db-server="$DB_HOST" \
- --set apitestrig.configmaps.db.db-su-user="postgres" \
- --set apitestrig.configmaps.db.db-port="5432" \
- --set apitestrig.configmaps.apitestrig.ENV_USER="$ENV_USER" \
- --set apitestrig.configmaps.apitestrig.ENV_ENDPOINT="https://$API_INTERNAL_HOST" \
- --set apitestrig.configmaps.apitestrig.ENV_TESTLEVEL="smokeAndRegression" \
- --set apitestrig.configmaps.apitestrig.reportExpirationInDays="$reportExpirationInDays" \
- --set apitestrig.configmaps.apitestrig.slack-webhook-url="$slackWebhookUrl" \
- --set apitestrig.configmaps.apitestrig.eSignetDeployed="$eSignetDeployed" \
- --set apitestrig.configmaps.apitestrig.NS="$NS" \
- $ENABLE_INSECURE
-
- echo Installed apitestrig.
- return 0
+ read -p "Is values.yaml for apitestrig chart set correctly as part of pre-requisites? (Y/n) : " yn;
+ if [[ $yn = "Y" ]] || [[ $yn = "y" ]] ; then
+ NFS_OPTION=''
+ S3_OPTION=''
+ config_complete=false # flag to check if S3 or NFS is configured
+ while [ "$config_complete" = false ]; do
+ read -p "Do you have S3 details for storing apitestrig reports? (Y/n) : " ans
+ if [[ "$ans" == "y" || "$ans" == "Y" ]]; then
+ read -p "Please provide S3 host: " s3_host
+ if [[ -z $s3_host ]]; then
+ echo "S3 host not provided; EXITING;"
+ exit 1;
+ fi
+ read -p "Please provide S3 region: " s3_region
+ if [[ $s3_region == *[' !@#$%^&*()+']* ]]; then
+ echo "S3 region should not contain spaces or special characters; EXITING;"
+ exit 1;
+ fi
+
+ read -p "Please provide S3 access key: " s3_user_key
+ if [[ -z $s3_user_key ]]; then
+ echo "S3 access key not provided; EXITING;"
+ exit 1;
+ fi
+ S3_OPTION="--set apitestrig.configmaps.s3.s3-host=$s3_host --set apitestrig.configmaps.s3.s3-user-key=$s3_user_key --set apitestrig.configmaps.s3.s3-region=$s3_region"
+ push_reports_to_s3="yes"
+ config_complete=true
+ elif [[ "$ans" == "n" || "$ans" == "N" ]]; then
+ push_reports_to_s3="no"
+ read -p "Since S3 details are not available, do you want to use NFS directory mount for storing reports? (y/n) : " answer
+ if [[ $answer == "Y" ]] || [[ $answer == "y" ]]; then
+ read -p "Please provide NFS Server IP: " nfs_server
+ if [[ -z $nfs_server ]]; then
+ echo "NFS server not provided; EXITING."
+ exit 1;
+ fi
+ read -p "Please provide NFS directory to store reports from NFS server (e.g. /srv/nfs//apitestrig/), make sure permission is 777 for the folder: " nfs_path
+ if [[ -z $nfs_path ]]; then
+ echo "NFS Path not provided; EXITING."
+ exit 1;
+ fi
+ NFS_OPTION="--set apitestrig.volumes.reports.nfs.server=$nfs_server --set apitestrig.volumes.reports.nfs.path=$nfs_path"
+ config_complete=true
+ else
+ echo "Please rerun the script with either S3 or NFS server details."
+ exit 1;
+ fi
+ else
+ echo "Invalid input. Please respond with Y (yes) or N (no)."
+ fi
+ done
+ echo Installing apitestrig
+ helm -n $NS install apitestrig mosip/apitestrig \
+ --set crontime="0 $time * * *" \
+ -f values.yaml \
+ --version $CHART_VERSION \
+ $NFS_OPTION \
+ $S3_OPTION \
+ --set apitestrig.variables.push_reports_to_s3=$push_reports_to_s3 \
+ --set apitestrig.configmaps.db.db-server="$DB_HOST" \
+ --set apitestrig.configmaps.db.db-su-user="postgres" \
+ --set apitestrig.configmaps.db.db-port="5432" \
+ --set apitestrig.configmaps.apitestrig.ENV_USER="$ENV_USER" \
+ --set apitestrig.configmaps.apitestrig.ENV_ENDPOINT="https://$API_INTERNAL_HOST" \
+ --set apitestrig.configmaps.apitestrig.ENV_TESTLEVEL="smokeAndRegression" \
+ --set apitestrig.configmaps.apitestrig.reportExpirationInDays="$reportExpirationInDays" \
+ --set apitestrig.configmaps.apitestrig.slack-webhook-url="$slackWebhookUrl" \
+ --set apitestrig.configmaps.apitestrig.eSignetDeployed="$eSignetDeployed" \
+ --set apitestrig.configmaps.apitestrig.NS="$NS" \
+ $ENABLE_INSECURE
+
+ echo Installed apitestrig.
+ return 0
+ fi
}
# set commands for error handling.
@@ -121,4 +172,4 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errtrace # trace ERR through 'time command' and other functions
set -o pipefail # trace ERR through pipes
-installing_apitestrig # calling function
\ No newline at end of file
+installing_apitestrig # calling function
diff --git a/deploy/apitestrig/values.yaml b/deploy/apitestrig/values.yaml
index fd2bca2911..3a4e312167 100644
--- a/deploy/apitestrig/values.yaml
+++ b/deploy/apitestrig/values.yaml
@@ -53,3 +53,11 @@ modules:
repository: mosipqa/apitest-mimoto
tag: develop
pullPolicy: Always
+ injicertify:
+ enabled: false
+ image:
+ repository: mosipqa/apitest-injicertify
+ tag: develop
+ pullPolicy: Always
+ variables:
+ push_reports_to_s3: "yes"
diff --git a/helm/apitestrig/templates/cronjob.yaml b/helm/apitestrig/templates/cronjob.yaml
index cb3ce9a2cc..9a87054da8 100644
--- a/helm/apitestrig/templates/cronjob.yaml
+++ b/helm/apitestrig/templates/cronjob.yaml
@@ -60,6 +60,8 @@ spec:
value: {{ $.Values.additionalResources.javaOpts }}
- name: MODULES
value: {{ $modulename }}
+ - name: push-reports-to-s3
+ value: {{ quote $.Values.apitestrig.variables.push_reports_to_s3 }}
{{- if $.Values.extraEnvVars }}
{{- include "common.tpvalues.render" (dict "value" $.Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
@@ -91,6 +93,10 @@ spec:
mountPath: {{ $volume_value.volumeMounts.mountPath }}
{{- end }}
{{- end }}
+ {{- if eq $.Values.apitestrig.variables.push_reports_to_s3 "no" }}
+ - name: {{ $.Values.apitestrig.volumes.reports.name }}
+ mountPath: /home/mosip/testrig/report
+ {{- end }}
volumes:
{{- if $.Values.enable_insecure }}
- name: cacerts
@@ -104,5 +110,10 @@ spec:
name: {{ $volume_name }}
{{- end }}
{{- end }}
+ {{- if eq $.Values.apitestrig.variables.push_reports_to_s3 "no" }}
+ - name: {{ $.Values.apitestrig.volumes.reports.name }}
+ persistentVolumeClaim:
+ claimName: {{ $.Values.apitestrig.volumes.reports.name }}-{{ $.Release.Namespace }}-{{ $modulename }}-pvc
+ {{- end }}
{{- end }}
{{- end }}
diff --git a/helm/apitestrig/templates/pv.yaml b/helm/apitestrig/templates/pv.yaml
new file mode 100644
index 0000000000..0ae1e54727
--- /dev/null
+++ b/helm/apitestrig/templates/pv.yaml
@@ -0,0 +1,23 @@
+{{- range $modulename, $module := $.Values.modules }}
+{{- if $module.enabled }}
+{{- if eq $.Values.apitestrig.variables.push_reports_to_s3 "no" }}
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+ name: {{ $.Values.apitestrig.volumes.reports.name }}-{{ $.Release.Namespace }}-{{ $modulename }}-pvc
+ labels:
+ name: {{ $.Values.apitestrig.volumes.reports.name }}
+spec:
+ storageClassName: {{ $.Values.apitestrig.volumes.reports.storageClass }}
+ capacity:
+ storage: {{ $.Values.apitestrig.volumes.reports.size }}
+ accessModes:
+ {{- range $.Values.apitestrig.volumes.reports.accessModes }}
+ - {{ . }}
+ {{- end }}
+ nfs:
+ server: {{ $.Values.apitestrig.volumes.reports.nfs.server }}
+ path: {{ $.Values.apitestrig.volumes.reports.nfs.path }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/helm/apitestrig/templates/pvc.yaml b/helm/apitestrig/templates/pvc.yaml
new file mode 100644
index 0000000000..605375b0cd
--- /dev/null
+++ b/helm/apitestrig/templates/pvc.yaml
@@ -0,0 +1,23 @@
+{{- range $modulename, $module := $.Values.modules }}
+{{- if $module.enabled }}
+{{- if eq $.Values.apitestrig.variables.push_reports_to_s3 "no" }}
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: {{ $.Values.apitestrig.volumes.reports.name }}-{{ $.Release.Namespace }}-{{ $modulename }}-pvc
+ namespace: {{ $.Release.Namespace | quote }}
+spec:
+ storageClassName: {{ $.Values.apitestrig.volumes.reports.storageClass }}
+ accessModes:
+ {{- range $.Values.apitestrig.volumes.reports.accessModes }}
+ - {{ . }}
+ {{- end }}
+ resources:
+ requests:
+ storage: {{ $.Values.apitestrig.volumes.reports.size }}
+ selector:
+ matchLabels:
+ name: {{ $.Values.apitestrig.volumes.reports.name }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/helm/apitestrig/templates/secrets.yaml b/helm/apitestrig/templates/secrets.yaml
index 1ef8dc9893..a3b9561dcd 100644
--- a/helm/apitestrig/templates/secrets.yaml
+++ b/helm/apitestrig/templates/secrets.yaml
@@ -4,7 +4,7 @@
apiVersion: v1
kind: Secret
metadata:
- name: {{ $secret_name }}
+ name: {{ $secret_name }}-{{ $.Release.Name }}
namespace: {{ $.Release.Namespace }}
labels: {{- include "common.labels.standard" $ | nindent 8 }}
{{- if $.Values.commonLabels }}
diff --git a/helm/apitestrig/values.yaml b/helm/apitestrig/values.yaml
index 8b5beb6f8f..432f9da897 100644
--- a/helm/apitestrig/values.yaml
+++ b/helm/apitestrig/values.yaml
@@ -514,7 +514,6 @@ apitestrig:
authDemoServiceBaseURL: http://authdemo.authdemo
authDemoServicePort: 80
eSignetDeployed: yes or no
- push-reports-to-s3: 'yes'
authCertsPath: '/home/mosip/authcerts'
scripts:
fetch_docker_image_hash_ids.sh: |
@@ -534,6 +533,8 @@ apitestrig:
cd /home/${container_user}/
bash ./entrypoint.sh
secrets:
+ s3:
+ s3-user-secret: 'password'
apitestrig:
volumes:
configmaps:
@@ -541,5 +542,18 @@ apitestrig:
defaultMode: 0777
volumeMounts:
mountPath: '/home/mosip/scripts/'
-
+ reports:
+ name: apitestrig-reports
+ storageClass: nfs-client
+ accessModes:
+ - ReadWriteMany
+ size: 10Mi
+ existingClaim:
+ # Dir where config and keys are written inside container
+ mountDir: /home/mosip/testrig/report
+ nfs:
+ path: "/srv/nfs/sandbox/onboarding" # Dir within the nfs server where config repo is cloned/maintained locally.
+ server: "nfs-server" # Ip address of nfs server.
+ variables:
+ push_reports_to_s3: "yes"
enable_insecure: false
diff --git a/pom.xml b/pom.xml
index 306e1ddc56..9abbda5354 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.mosip.testrig
mosip-functional-test
- 1.2.1-SNAPSHOT
+ 1.3.1-SNAPSHOT
pom
mosip-function-test
Parent project of MOSIP Functional test
@@ -84,7 +84,7 @@
- authentication-demo-service
+ apitest-commons
@@ -283,4 +283,4 @@
-
+
\ No newline at end of file