Skip to content

Commit 269bcb7

Browse files
committed
Allow Italy and Spain in free mode country gate
1 parent 53de6f6 commit 269bcb7

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

web/src/app/api/v1/freebuff/session/__tests__/session.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ describe('POST /api/v1/freebuff/session', () => {
230230
test('returns country_blocked without joining the queue for disallowed country', async () => {
231231
const sessionDeps = makeSessionDeps()
232232
const resp = await postFreebuffSession(
233-
makeReq('ok', { cfCountry: 'ES' }),
233+
makeReq('ok', { cfCountry: 'PT' }),
234234
makeDeps(sessionDeps, 'u1'),
235235
)
236236
// 403 (not 200) so older CLIs that don't know `country_blocked` fall into
237237
// their error-retry backoff instead of tight-polling.
238238
expect(resp.status).toBe(403)
239239
const body = await resp.json()
240240
expect(body.status).toBe('country_blocked')
241-
expect(body.countryCode).toBe('ES')
241+
expect(body.countryCode).toBe('PT')
242242
expect(body.countryBlockReason).toBe('country_not_allowed')
243243
expect(sessionDeps.rows.size).toBe(0)
244244
})
@@ -326,13 +326,13 @@ describe('GET /api/v1/freebuff/session', () => {
326326
test('returns country_blocked for disallowed country on GET', async () => {
327327
const sessionDeps = makeSessionDeps()
328328
const resp = await getFreebuffSession(
329-
makeReq('ok', { cfCountry: 'ES' }),
329+
makeReq('ok', { cfCountry: 'PT' }),
330330
makeDeps(sessionDeps, 'u1'),
331331
)
332332
expect(resp.status).toBe(403)
333333
const body = await resp.json()
334334
expect(body.status).toBe('country_blocked')
335-
expect(body.countryCode).toBe('ES')
335+
expect(body.countryCode).toBe('PT')
336336
expect(body.countryBlockReason).toBe('country_not_allowed')
337337
})
338338

@@ -358,7 +358,7 @@ describe('GET /api/v1/freebuff/session', () => {
358358
})
359359
let countryChecks = 0
360360
const resp = await getFreebuffSession(
361-
makeReq('ok', { cfCountry: 'ES' }),
361+
makeReq('ok', { cfCountry: 'PT' }),
362362
makeDeps(sessionDeps, 'u1', {
363363
getCountryAccess: async (req) => {
364364
countryChecks++

web/src/server/__tests__/free-mode-country.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ describe('free mode country access', () => {
3131
['IL', 'IL'],
3232
['FR', 'FR'],
3333
['BE', 'BE'],
34+
['IT', 'IT'],
35+
['ES', 'ES'],
3436
])('allows allowlisted Cloudflare country %s', async (header, expected) => {
3537
const access = await getFreeModeCountryAccess(
3638
makeReq({
@@ -46,11 +48,11 @@ describe('free mode country access', () => {
4648

4749
test('blocks countries outside the allowlist', async () => {
4850
const access = await getFreeModeCountryAccess(
49-
makeReq({ 'cf-ipcountry': 'ES' }),
51+
makeReq({ 'cf-ipcountry': 'PT' }),
5052
noAnonymousNetwork,
5153
)
5254
expect(access.allowed).toBe(false)
53-
expect(access.countryCode).toBe('ES')
55+
expect(access.countryCode).toBe('PT')
5456
expect(access.blockReason).toBe('country_not_allowed')
5557
})
5658

@@ -297,7 +299,7 @@ describe('free mode country access', () => {
297299

298300
test('allowLocalhost does not bypass when cf-ipcountry is set', async () => {
299301
const access = await getFreeModeCountryAccess(
300-
makeReq({ 'cf-ipcountry': 'ES' }),
302+
makeReq({ 'cf-ipcountry': 'PT' }),
301303
{
302304
ipinfoToken: 'test-token',
303305
allowLocalhost: true,

web/src/server/free-mode-country.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export const FREE_MODE_ALLOWED_COUNTRIES = new Set([
2020
'DK',
2121
'DE',
2222
'FR',
23+
'IT',
24+
'ES',
2325
'FI',
2426
'BE',
2527
'LU',

0 commit comments

Comments
 (0)