From 98e08fc43ff490d631c0e365a2dfe574fa2efcc9 Mon Sep 17 00:00:00 2001 From: Steph0 Date: Tue, 3 Dec 2024 17:08:07 +0100 Subject: [PATCH] :recycle: api: remove dead code that used PIX_CERTIF_SCO_BLOCKED_ACCESS_WHITELIST * This code was used by migration scripts during V3 generalization. Scripts that are now deleted. --- .../configuration/domain/models/Center.js | 15 --- .../unit/domain/models/Center_test.js | 104 ------------------ 2 files changed, 119 deletions(-) diff --git a/api/src/certification/configuration/domain/models/Center.js b/api/src/certification/configuration/domain/models/Center.js index d18eb260ee7..59fadebf82f 100644 --- a/api/src/certification/configuration/domain/models/Center.js +++ b/api/src/certification/configuration/domain/models/Center.js @@ -1,9 +1,6 @@ import Joi from 'joi'; -import { config } from '../../../../shared/config.js'; import { EntityValidationError } from '../../../../shared/domain/errors.js'; -import { _ } from '../../../../shared/infrastructure/utils/lodash-utils.js'; -import { CenterTypes } from './CenterTypes.js'; export class Center { static #schema = Joi.object({ @@ -26,18 +23,6 @@ export class Center { this.#validate(); } - isInWhitelist() { - if (this.type !== CenterTypes.SCO) { - return true; - } - - if (this.type == CenterTypes.SCO && _.isBlank(this.externalId)) { - return false; - } - - return config.features.pixCertifScoBlockedAccessWhitelist.includes(this.externalId.toUpperCase()); - } - #validate() { const { error } = Center.#schema.validate(this, { allowUnknown: false }); if (error) { diff --git a/api/tests/certification/configuration/unit/domain/models/Center_test.js b/api/tests/certification/configuration/unit/domain/models/Center_test.js index 4d2d828412d..1820530f9b1 100644 --- a/api/tests/certification/configuration/unit/domain/models/Center_test.js +++ b/api/tests/certification/configuration/unit/domain/models/Center_test.js @@ -32,108 +32,4 @@ describe('Unit | Certification | Configuration | Domain | Models | Center', func expect(error).to.be.an.instanceOf(EntityValidationError); }); }); - - context('#isInWhitelist', function () { - let originalEnvValueWhitelist; - - beforeEach(function () { - originalEnvValueWhitelist = config.features.pixCertifScoBlockedAccessWhitelist; - config.features.pixCertifScoBlockedAccessWhitelist = []; - }); - - afterEach(function () { - config.features.pixCertifScoBlockedAccessWhitelist = originalEnvValueWhitelist; - }); - - it('should consider centers other than SCO as always whitelisted', function () { - // given - config.features.pixCertifScoBlockedAccessWhitelist = ['hello']; - const center = new Center({ - id: 12, - type: CenterTypes.PRO, - externalId: 'hello', - }); - // when - const isInWhitelist = center.isInWhitelist(); - - // then - expect(isInWhitelist).to.be.true; - }); - context('when center is SCO', function () { - it('should consider blank externalId as not whitelisted', function () { - // given - const center = new Center({ - id: 12, - type: CenterTypes.SCO, - externalId: ' ', - }); - // when - const isInWhitelist = center.isInWhitelist(); - - // then - expect(isInWhitelist).to.be.false; - }); - - it('should consider center without externalId as not whitelisted', function () { - // given - const center = new Center({ - id: 12, - type: CenterTypes.SCO, - externalId: undefined, - }); - // when - const isInWhitelist = center.isInWhitelist(); - - // then - expect(isInWhitelist).to.be.false; - }); - - it('should consider center in whitelist as whitelisted', function () { - // given - const externalId = 'WHITELISTED'; - config.features.pixCertifScoBlockedAccessWhitelist = [externalId]; - const center = new Center({ - id: 12, - type: CenterTypes.SCO, - externalId: externalId, - }); - // when - const isInWhitelist = center.isInWhitelist(); - - // then - expect(isInWhitelist).to.be.true; - }); - - it('should consider center NOT in whitelist as NOT whitelisted', function () { - // given - config.features.pixCertifScoBlockedAccessWhitelist = ['WHITELISTED']; - const center = new Center({ - id: 12, - type: CenterTypes.SCO, - externalId: 'not_whitelisted', - }); - // when - const isInWhitelist = center.isInWhitelist(); - - // then - expect(isInWhitelist).to.be.false; - }); - - it('should not be case sensitive on externalId', function () { - // given - // config is already uppercased + trimmed - config.features.pixCertifScoBlockedAccessWhitelist = ['WHITELISTED12']; - const center = new Center({ - id: 12, - type: CenterTypes.SCO, - externalId: 'whiteLISTed12', - }); - // when - const isInWhitelist = center.isInWhitelist(); - - // then - expect(isInWhitelist).to.be.true; - }); - }); - }); });