Skip to content

Commit

Permalink
adding validations for F2F_CRI_VC_ISSUED event
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeni-lutukurthy-gds committed Oct 27, 2023
1 parent afee3f5 commit 0272dd0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 44 deletions.
4 changes: 2 additions & 2 deletions tests/helpers/common-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export function extensionToMap(value): Record<string, string> {
}

export function extensionToMap1F2fCriVcIssued(value): Record<string, string> {
const transclude = 'passport=[{documenttype=document_type}], residencepermit=resident_permit, drivingpermit=driving_permit, idcard=id_card';
const transclude =
'passport=[{documenttype=document_type}], residencepermit=resident_permit, drivingpermit=driving_permit, idcard=id_card';
const transRE = new RegExp(transclude.replace(/(.*?)/g, '(?<$1>.*)'));
return value.match(transRE).groups;
}
Expand All @@ -147,7 +148,6 @@ export function extensionToMapipvIdentityIssue(value): Record<string, string> {
const transcludes = 'hasmitigations={has_mitigations}, levelofconfidence={level_of_confidence}, cifail={ci_fail}';
const transREs = new RegExp(transcludes.replace(/\{(.*?)\}/g, '(?<$1>.*)'));
const val = value.replace('{', '').replace('}', '');
console.log(val.match(transREs).groups)
return val.match(transREs).groups;
}

Expand Down
3 changes: 1 addition & 2 deletions tests/helpers/query-constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ export const extensionsnotnullquery = (tablename: string): string => {
return query;
};

export const restrictednotnullquery = (tablename: string): string => {
export const restrictednotnullquery = (tablename: string): string => {
const query = 'SELECT event_id, restricted,day FROM ' + tablename + ' where restricted is not null';
return query;
};


export const IPV_IDENTITY_ISSUED_CONFORMED =
'select event_id,event_name,has_mitigations,level_of_confidence,ci_fail FROM\n' +
' "dap_txma_reporting_db"."conformed"."fact_user_journey_event" fct LEFT JOIN "dap_txma_reporting_db"."conformed".DIM_EVENT DE ON fct.event_key = de.event_key WHERE ';
88 changes: 48 additions & 40 deletions tests/regression-tests/ipv_cri_f2f_group_data_validation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { getQueryResults } from '../helpers/db-helpers';
import { GET_EVENT_ID, extensionsnotnullquery, IPV_CRI_F2F_DATA, restrictednotnullquery } from '../helpers/query-constant';
import {
GET_EVENT_ID,
extensionsnotnullquery,
IPV_CRI_F2F_DATA,
restrictednotnullquery,
} from '../helpers/query-constant';
import { txmaProcessingWorkGroupName, txmaRawDatabaseName, txmaStageDatabaseName } from '../helpers/envHelper';
import { eventidlist, extensionToMap1F2fCriVcIssued } from '../helpers/common-helpers';

Expand All @@ -20,68 +25,71 @@ describe('IPV_CRI_F2F GROUP Test - validate data at stage layer', () => {
txmaStageDatabaseName(),
txmaProcessingWorkGroupName(),
);
let stExtensions = null
let stExtensions = null;
let query = null;
const querystring = eventidlist(eventidresults);
if (eventname === 'F2F_CRI_VC_ISSUED')
{
const query = `${restrictednotnullquery(eventname)} and event_id in (${querystring})`;
if (eventname === 'F2F_CRI_VC_ISSUED') {
query = `${restrictednotnullquery(eventname)} and event_id in (${querystring})`;
} else {
query = `${extensionsnotnullquery(eventname)} and event_id in (${querystring})`;
}
else
{
const query = `${extensionsnotnullquery(eventname)} and event_id in (${querystring})`;
}
const athenaQueryResults = await getQueryResults(query, txmaRawDatabaseName(), txmaProcessingWorkGroupName());
const athenaQueryResults = await getQueryResults(query, txmaRawDatabaseName(), txmaProcessingWorkGroupName());
for (let index = 0; index <= athenaQueryResults.length - 1; index++) {
const eventId = athenaQueryResults[index].event_id;
if (eventname === 'F2F_CRI_VC_ISSUED')
{
let extensionsData = null;
if (eventname === 'F2F_CRI_VC_ISSUED') {
stExtensions = athenaQueryResults[index].restricted;
const data = extensionToMap1F2fCriVcIssued(stExtensions);
}
else
{
} else {
stExtensions = athenaQueryResults[index].extensions.replace('{', '').replace('}', '').split('=')[1];
}

const queryStage = `${IPV_CRI_F2F_DATA(eventname)} and event_id = '${eventId}'`;
const athenaQueryResultsStage = await getQueryResults(
queryStage,
txmaStageDatabaseName(),
txmaProcessingWorkGroupName(),
);
if (eventname === 'F2F_CRI_VC_ISSUED')
{
if (data.restricted_residencepermit !== 'null' && data.restricted_residencepermit !== null && data.restricted_residencepermit !== undefined) {
const restricted_residencepermit =
athenaQueryResultsStage[0].restricted_residencepermit.replaceAll('"', '');
expect(data.restricted_residencepermit).toEqual(restricted_residencepermit);
extensionsData = extensionToMap1F2fCriVcIssued(stExtensions);
if (eventname === 'F2F_CRI_VC_ISSUED') {
if (
extensionsData.restrictedResidencePermit !== 'null' &&
extensionsData.restrictedResidencePermit !== null &&
extensionsData.restrictedResidencePermit !== undefined
) {
const restrictedResidencePermit = athenaQueryResultsStage[0].restrictedResidencePermit.replaceAll('"', '');
expect(extensionsData.restrictedResidencePermit).toEqual(restrictedResidencePermit);
}
if (data.restricted_drivingpermit !== 'null' && data.restricted_drivingpermit !== null && data.restricted_drivingpermit !== undefined) {
const restricted_drivingpermit =
athenaQueryResultsStage[0].restricted_drivingpermit.replaceAll('"', '');
expect(data.restricted_drivingpermit).toEqual(restricted_drivingpermit);
if (
extensionsData.restrictedDrivingPermit !== 'null' &&
extensionsData.restrictedDrivingPermit !== null &&
extensionsData.restrictedDrivingPermit !== undefined
) {
const restrictedDrivingPermit = athenaQueryResultsStage[0].restrictedDrivingPermit.replaceAll('"', '');
expect(extensionsData.restrictedDrivingPermit).toEqual(restrictedDrivingPermit);
}
if (data.restricted_idcard !== 'null' && data.restricted_idcard !== null && data.restricted_idcard !== undefined) {
const restricted_idcard =
athenaQueryResultsStage[0].restricted_idcard.replaceAll('"', '');
expect(data.restricted_idcard).toEqual(restricted_idcard);
if (
extensionsData.restrictedIdCard !== 'null' &&
extensionsData.restrictedIdCard !== null &&
extensionsData.restrictedIdCard !== undefined
) {
const restrictedIdCard = athenaQueryResultsStage[0].restrictedIdCard.replaceAll('"', '');
expect(extensionsData.restrictedIdCard).toEqual(restrictedIdCard);
}
if (data.restricted_passport !== 'null' && data.restricted_passport !== null && data.restricted_passport !== undefined) {
const restricted_passport =
athenaQueryResultsStage[0].restricted_passport.replaceAll('"', '');
expect(data.restricted_passport).toEqual(restricted_passport);
if (
extensionsData.restrictedPassport !== 'null' &&
extensionsData.restrictedPassport !== null &&
extensionsData.restrictedPassport !== undefined
) {
const restrictedPassport = athenaQueryResultsStage[0].restrictedPassport.replaceAll('"', '');
expect(extensionsData.restrictedPassport).toEqual(restrictedPassport);
}
}
else
{
} else {
if (stExtensions !== 'null' && stExtensions !== null && stExtensions !== undefined) {
const previousgovuksigninjourneyid =
athenaQueryResultsStage[0].extensions_previousgovuksigninjourneyid.replaceAll('"', '');
expect(stExtensions).toEqual(previousgovuksigninjourneyid);
}
}


}
},
240000,
Expand Down

0 comments on commit 0272dd0

Please sign in to comment.