Skip to content

Commit 98e08fc

Browse files
committed
♻️ 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.
1 parent 10243f4 commit 98e08fc

File tree

2 files changed

+0
-119
lines changed
  • api
    • src/certification/configuration/domain/models
    • tests/certification/configuration/unit/domain/models

2 files changed

+0
-119
lines changed

api/src/certification/configuration/domain/models/Center.js

-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import Joi from 'joi';
22

3-
import { config } from '../../../../shared/config.js';
43
import { EntityValidationError } from '../../../../shared/domain/errors.js';
5-
import { _ } from '../../../../shared/infrastructure/utils/lodash-utils.js';
6-
import { CenterTypes } from './CenterTypes.js';
74

85
export class Center {
96
static #schema = Joi.object({
@@ -26,18 +23,6 @@ export class Center {
2623
this.#validate();
2724
}
2825

29-
isInWhitelist() {
30-
if (this.type !== CenterTypes.SCO) {
31-
return true;
32-
}
33-
34-
if (this.type == CenterTypes.SCO && _.isBlank(this.externalId)) {
35-
return false;
36-
}
37-
38-
return config.features.pixCertifScoBlockedAccessWhitelist.includes(this.externalId.toUpperCase());
39-
}
40-
4126
#validate() {
4227
const { error } = Center.#schema.validate(this, { allowUnknown: false });
4328
if (error) {

api/tests/certification/configuration/unit/domain/models/Center_test.js

-104
Original file line numberDiff line numberDiff line change
@@ -32,108 +32,4 @@ describe('Unit | Certification | Configuration | Domain | Models | Center', func
3232
expect(error).to.be.an.instanceOf(EntityValidationError);
3333
});
3434
});
35-
36-
context('#isInWhitelist', function () {
37-
let originalEnvValueWhitelist;
38-
39-
beforeEach(function () {
40-
originalEnvValueWhitelist = config.features.pixCertifScoBlockedAccessWhitelist;
41-
config.features.pixCertifScoBlockedAccessWhitelist = [];
42-
});
43-
44-
afterEach(function () {
45-
config.features.pixCertifScoBlockedAccessWhitelist = originalEnvValueWhitelist;
46-
});
47-
48-
it('should consider centers other than SCO as always whitelisted', function () {
49-
// given
50-
config.features.pixCertifScoBlockedAccessWhitelist = ['hello'];
51-
const center = new Center({
52-
id: 12,
53-
type: CenterTypes.PRO,
54-
externalId: 'hello',
55-
});
56-
// when
57-
const isInWhitelist = center.isInWhitelist();
58-
59-
// then
60-
expect(isInWhitelist).to.be.true;
61-
});
62-
context('when center is SCO', function () {
63-
it('should consider blank externalId as not whitelisted', function () {
64-
// given
65-
const center = new Center({
66-
id: 12,
67-
type: CenterTypes.SCO,
68-
externalId: ' ',
69-
});
70-
// when
71-
const isInWhitelist = center.isInWhitelist();
72-
73-
// then
74-
expect(isInWhitelist).to.be.false;
75-
});
76-
77-
it('should consider center without externalId as not whitelisted', function () {
78-
// given
79-
const center = new Center({
80-
id: 12,
81-
type: CenterTypes.SCO,
82-
externalId: undefined,
83-
});
84-
// when
85-
const isInWhitelist = center.isInWhitelist();
86-
87-
// then
88-
expect(isInWhitelist).to.be.false;
89-
});
90-
91-
it('should consider center in whitelist as whitelisted', function () {
92-
// given
93-
const externalId = 'WHITELISTED';
94-
config.features.pixCertifScoBlockedAccessWhitelist = [externalId];
95-
const center = new Center({
96-
id: 12,
97-
type: CenterTypes.SCO,
98-
externalId: externalId,
99-
});
100-
// when
101-
const isInWhitelist = center.isInWhitelist();
102-
103-
// then
104-
expect(isInWhitelist).to.be.true;
105-
});
106-
107-
it('should consider center NOT in whitelist as NOT whitelisted', function () {
108-
// given
109-
config.features.pixCertifScoBlockedAccessWhitelist = ['WHITELISTED'];
110-
const center = new Center({
111-
id: 12,
112-
type: CenterTypes.SCO,
113-
externalId: 'not_whitelisted',
114-
});
115-
// when
116-
const isInWhitelist = center.isInWhitelist();
117-
118-
// then
119-
expect(isInWhitelist).to.be.false;
120-
});
121-
122-
it('should not be case sensitive on externalId', function () {
123-
// given
124-
// config is already uppercased + trimmed
125-
config.features.pixCertifScoBlockedAccessWhitelist = ['WHITELISTED12'];
126-
const center = new Center({
127-
id: 12,
128-
type: CenterTypes.SCO,
129-
externalId: 'whiteLISTed12',
130-
});
131-
// when
132-
const isInWhitelist = center.isInWhitelist();
133-
134-
// then
135-
expect(isInWhitelist).to.be.true;
136-
});
137-
});
138-
});
13935
});

0 commit comments

Comments
 (0)