Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-36480 - Synced the develop branch #1689

Merged
merged 18 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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;
Expand Down Expand Up @@ -162,7 +163,6 @@ public class AdminTestUtil extends BaseTestCase {
String signupAutoGeneratedIdPropFileName = properties.getProperty("signupAutoGeneratedIdPropFileName");
String fullNameForSunBirdRC = properties.getProperty("fullNameForSunBirdRC");
String dobForSunBirdRC = properties.getProperty("dobForSunBirdRC");

public static String PASSWORD_FOR_ADDIDENTITY_AND_REGISTRATION = null;
public static String PASSWORD_TO_RESET = null;
public static final String RESOURCE_FOLDER_NAME = "MosipTemporaryTestResource";
Expand Down Expand Up @@ -3284,6 +3284,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$"))
Expand Down Expand Up @@ -3381,6 +3390,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);
Expand Down Expand Up @@ -5321,6 +5333,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);
Expand Down Expand Up @@ -5380,7 +5394,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);
Expand Down Expand Up @@ -5448,6 +5470,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())
Expand Down Expand Up @@ -5605,11 +5635,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);

Expand Down Expand Up @@ -5663,6 +5703,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");
}
Expand Down Expand Up @@ -5795,6 +5842,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<>());
Expand Down Expand Up @@ -7186,7 +7238,7 @@ else if (testCaseName.startsWith("Prereg_")
|| testCaseName.contains("_SpacialCharacter_PostalCode_"))
&& (globalRequiredFields != null && !globalRequiredFields.toList().contains(postalCodeArray))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}
}

// else if (BaseTestCase.currentModule.equalsIgnoreCase(GlobalConstants.ESIGNET)) {
// if ((testCaseName.startsWith("Esignet_") || testCaseName.startsWith("ESignet_"))
Expand Down Expand Up @@ -7784,6 +7836,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;
Expand Down
103 changes: 77 additions & 26 deletions deploy/apitestrig/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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/<sandbox>/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.
Expand All @@ -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
installing_apitestrig # calling function
6 changes: 6 additions & 0 deletions deploy/apitestrig/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ modules:
repository: mosipqa/apitest-mimoto
tag: develop
pullPolicy: Always
injicertify:
enabled: false
image:
repository: mosipqa/apitest-injicertify
tag: develop
pullPolicy: Always
11 changes: 11 additions & 0 deletions helm/apitestrig/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
23 changes: 23 additions & 0 deletions helm/apitestrig/templates/pv.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 23 additions & 0 deletions helm/apitestrig/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading
Loading