From 255dbce728c3a4eb86342faacc91a4b59fc167e6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:33:47 -0400 Subject: [PATCH] [OTE-438] Allow users to read data if they are in FIRST_STRIKE_CLOSE_ONLY (backport #1716) (#1725) Co-authored-by: Christopher-Li --- .../lib/compliance-and-geo-check.test.ts | 20 +++++++++++++++++++ .../src/lib/compliance-and-geo-check.ts | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/indexer/services/comlink/__tests__/lib/compliance-and-geo-check.test.ts b/indexer/services/comlink/__tests__/lib/compliance-and-geo-check.test.ts index d154d32c9a..3dfb5ee95f 100644 --- a/indexer/services/comlink/__tests__/lib/compliance-and-geo-check.test.ts +++ b/indexer/services/comlink/__tests__/lib/compliance-and-geo-check.test.ts @@ -189,6 +189,26 @@ describe('compliance-check', () => { }); }); + it.each([ + ['query', `/v4/check-compliance-query?address=${testConstants.defaultAddress}`], + ['param', `/v4/check-compliance-param/${testConstants.defaultAddress}`], + ])('does not return 403 if address in request is in FIRST_STRIKE_CLOSE_ONLY and from restricted country (%s)', async ( + _name: string, + path: string, + ) => { + isRestrictedCountrySpy.mockReturnValueOnce(true); + await ComplianceStatusTable.create({ + ...testConstants.compliantStatusData, + status: ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY, + }); + await sendRequestToApp({ + type: RequestMethod.GET, + path, + expressApp: complianceCheckApp, + expectedStatus: 200, + }); + }); + it.each([ ['query', `/v4/check-compliance-query?address=${testConstants.defaultAddress}`], ['param', `/v4/check-compliance-param/${testConstants.defaultAddress}`], diff --git a/indexer/services/comlink/src/lib/compliance-and-geo-check.ts b/indexer/services/comlink/src/lib/compliance-and-geo-check.ts index bee0a96900..983fb1b872 100644 --- a/indexer/services/comlink/src/lib/compliance-and-geo-check.ts +++ b/indexer/services/comlink/src/lib/compliance-and-geo-check.ts @@ -47,7 +47,9 @@ export async function complianceAndGeoCheck( { readReplica: true }, ); if (updatedStatus.length > 0) { - if (updatedStatus[0].status === ComplianceStatus.CLOSE_ONLY) { + if (updatedStatus[0].status === ComplianceStatus.CLOSE_ONLY || + updatedStatus[0].status === ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY + ) { return next(); } else if (updatedStatus[0].status === ComplianceStatus.BLOCKED) { return create4xxResponse(