Skip to content

Commit baf14c0

Browse files
authored
fix: cacheByQueryString option (#360)
2 parents dda546c + ab03b4b commit baf14c0

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

lib/utils/generateManifest/generateManifest.utils.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ function jsToJson(inputConfig) {
110110
? 'all'
111111
: cache.cacheByQueryString.option;
112112
if (
113-
cache.cacheByQueryString.option === 'allowlist' ||
114-
cache.cacheByQueryString.option === 'blocklist'
113+
cache.cacheByQueryString.option === 'whitelist' ||
114+
cache.cacheByQueryString.option === 'blacklist'
115115
) {
116116
cacheSetting.query_string_fields =
117117
cache.cacheByQueryString.list || [];
@@ -126,8 +126,8 @@ function jsToJson(inputConfig) {
126126
? 'all'
127127
: cache.cacheByCookie.option;
128128
if (
129-
cache.cacheByCookie.option === 'allowlist' ||
130-
cache.cacheByCookie.option === 'blocklist'
129+
cache.cacheByCookie.option === 'whitelist' ||
130+
cache.cacheByCookie.option === 'blacklist'
131131
) {
132132
cacheSetting.cookie_names = cache.cacheByCookie.list || [];
133133
} else {

lib/utils/generateManifest/generateManifest.utils.test.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -1289,13 +1289,13 @@ describe('Utils - generateManifest', () => {
12891289
);
12901290
});
12911291

1292-
it('should correctly process cacheByQueryString with option "allowlist" and list', () => {
1292+
it('should correctly process cacheByQueryString with option "whitelist" and list', () => {
12931293
const azionConfig = {
12941294
cache: [
12951295
{
12961296
name: 'testCache',
12971297
cacheByQueryString: {
1298-
option: 'allowlist',
1298+
option: 'whitelist',
12991299
list: ['param1', 'param2'],
13001300
},
13011301
},
@@ -1308,19 +1308,19 @@ describe('Utils - generateManifest', () => {
13081308
const result = jsToJson(azionConfig);
13091309
expect(result.cache[0]).toEqual(
13101310
expect.objectContaining({
1311-
cache_by_query_string: 'allowlist',
1311+
cache_by_query_string: 'whitelist',
13121312
query_string_fields: ['param1', 'param2'],
13131313
}),
13141314
);
13151315
});
13161316

1317-
it('should throw an error if cacheByQueryString option is "allowlist" or "blocklist" without list', () => {
1317+
it('should throw an error if cacheByQueryString option is "whitelist" or "blacklist" without list', () => {
13181318
const azionConfig = {
13191319
cache: [
13201320
{
13211321
name: 'testCache',
13221322
cacheByQueryString: {
1323-
option: 'allowlist',
1323+
option: 'whitelist',
13241324
},
13251325
},
13261326
],
@@ -1330,17 +1330,17 @@ describe('Utils - generateManifest', () => {
13301330
};
13311331

13321332
expect(() => jsToJson(azionConfig)).toThrow(
1333-
"The 'list' field is required when 'option' is 'allowlist' or 'blocklist'.",
1333+
"The 'list' field is required when 'option' is 'whitelist' or 'blacklist'.",
13341334
);
13351335
});
13361336

1337-
it('should correctly process cacheByQueryString with option "blocklist" and list', () => {
1337+
it('should correctly process cacheByQueryString with option "blacklist" and list', () => {
13381338
const azionConfig = {
13391339
cache: [
13401340
{
13411341
name: 'testCache',
13421342
cacheByQueryString: {
1343-
option: 'blocklist',
1343+
option: 'blacklist',
13441344
list: ['param1', 'param2'],
13451345
},
13461346
},
@@ -1353,7 +1353,7 @@ describe('Utils - generateManifest', () => {
13531353
const result = jsToJson(azionConfig);
13541354
expect(result.cache[0]).toEqual(
13551355
expect.objectContaining({
1356-
cache_by_query_string: 'blocklist',
1356+
cache_by_query_string: 'blacklist',
13571357
query_string_fields: ['param1', 'param2'],
13581358
}),
13591359
);
@@ -1406,13 +1406,13 @@ describe('Utils - generateManifest', () => {
14061406
);
14071407
});
14081408

1409-
it('should correctly process cacheByCookie with option "allowlist" and list', () => {
1409+
it('should correctly process cacheByCookie with option "whitelist" and list', () => {
14101410
const azionConfig = {
14111411
cache: [
14121412
{
14131413
name: 'testCache',
14141414
cacheByCookie: {
1415-
option: 'allowlist',
1415+
option: 'whitelist',
14161416
list: ['cookie1', 'cookie2'],
14171417
},
14181418
},
@@ -1425,19 +1425,19 @@ describe('Utils - generateManifest', () => {
14251425
const result = jsToJson(azionConfig);
14261426
expect(result.cache[0]).toEqual(
14271427
expect.objectContaining({
1428-
cache_by_cookie: 'allowlist',
1428+
cache_by_cookie: 'whitelist',
14291429
cookie_names: ['cookie1', 'cookie2'],
14301430
}),
14311431
);
14321432
});
14331433

1434-
it('should throw an error if cacheByCookie option is "allowlist" or "blocklist" without list', () => {
1434+
it('should throw an error if cacheByCookie option is "whitelist" or "blacklist" without list', () => {
14351435
const azionConfig = {
14361436
cache: [
14371437
{
14381438
name: 'testCache',
14391439
cacheByCookie: {
1440-
option: 'allowlist',
1440+
option: 'whitelist',
14411441
},
14421442
},
14431443
],
@@ -1447,17 +1447,17 @@ describe('Utils - generateManifest', () => {
14471447
};
14481448

14491449
expect(() => jsToJson(azionConfig)).toThrow(
1450-
"The 'list' field is required when 'option' is 'allowlist' or 'blocklist'.",
1450+
"The 'list' field is required when 'option' is 'whitelist' or 'blacklist'.",
14511451
);
14521452
});
14531453

1454-
it('should correctly process cacheByCookie with option "blocklist" and list', () => {
1454+
it('should correctly process cacheByCookie with option "blacklist" and list', () => {
14551455
const azionConfig = {
14561456
cache: [
14571457
{
14581458
name: 'testCache',
14591459
cacheByCookie: {
1460-
option: 'blocklist',
1460+
option: 'blacklist',
14611461
list: ['cookie1', 'cookie2'],
14621462
},
14631463
},
@@ -1470,7 +1470,7 @@ describe('Utils - generateManifest', () => {
14701470
const result = jsToJson(azionConfig);
14711471
expect(result.cache[0]).toEqual(
14721472
expect.objectContaining({
1473-
cache_by_cookie: 'blocklist',
1473+
cache_by_cookie: 'blacklist',
14741474
cookie_names: ['cookie1', 'cookie2'],
14751475
}),
14761476
);

lib/utils/generateManifest/helpers/azion.config.example.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export default {
2323
maxAgeSeconds: 1000,
2424
},
2525
cacheByQueryString: {
26-
option: 'blocklist', // ['blocklist', 'allowlist', 'varies', 'ignore]
26+
option: 'blacklist', // ['blacklist', 'whitelist', 'varies', 'ignore]
2727
list: ['order', 'user'],
2828
},
2929
cacheByCookie: {
30-
option: 'allowlist', // ['blocklist', 'allowlist', 'varies', 'ignore]
30+
option: 'whitelist', // ['blacklist', 'whitelist', 'varies', 'ignore]
3131
list: ['session', 'user'],
3232
},
3333
},

lib/utils/generateManifest/helpers/schema.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ const azionConfigSchema = {
143143
properties: {
144144
option: {
145145
type: 'string',
146-
enum: ['ignore', 'varies', 'allowlist', 'blocklist'],
146+
enum: ['ignore', 'varies', 'whitelist', 'blacklist'],
147147
errorMessage:
148-
"The 'option' field must be one of 'ignore', 'varies', 'allowlist' or 'blocklist'..",
148+
"The 'option' field must be one of 'ignore', 'varies', 'whitelist' or 'blacklist'..",
149149
},
150150
list: {
151151
type: 'array',
@@ -168,14 +168,14 @@ const azionConfigSchema = {
168168
},
169169
if: {
170170
properties: {
171-
option: { enum: ['allowlist', 'blocklist'] },
171+
option: { enum: ['whitelist', 'blacklist'] },
172172
},
173173
},
174174
then: {
175175
required: ['list'],
176176
errorMessage: {
177177
required:
178-
"The 'list' field is required when 'option' is 'allowlist' or 'blocklist'.",
178+
"The 'list' field is required when 'option' is 'whitelist' or 'blacklist'.",
179179
},
180180
},
181181
},
@@ -185,9 +185,9 @@ const azionConfigSchema = {
185185
properties: {
186186
option: {
187187
type: 'string',
188-
enum: ['ignore', 'varies', 'allowlist', 'blocklist'],
188+
enum: ['ignore', 'varies', 'whitelist', 'blacklist'],
189189
errorMessage:
190-
"The 'option' field must be one of 'ignore', 'varies', 'allowlist' or 'blocklist'.",
190+
"The 'option' field must be one of 'ignore', 'varies', 'whitelist' or 'blacklist'.",
191191
},
192192
list: {
193193
type: 'array',
@@ -210,14 +210,14 @@ const azionConfigSchema = {
210210
},
211211
if: {
212212
properties: {
213-
option: { enum: ['allowlist', 'blocklist'] },
213+
option: { enum: ['whitelist', 'blacklist'] },
214214
},
215215
},
216216
then: {
217217
required: ['list'],
218218
errorMessage: {
219219
required:
220-
"The 'list' field is required when 'option' is 'allowlist' or 'blocklist'.",
220+
"The 'list' field is required when 'option' is 'whitelist' or 'blacklist'.",
221221
},
222222
},
223223
},

0 commit comments

Comments
 (0)