Skip to content

Commit 216268f

Browse files
committed
Allow Portugal in free mode country gate
1 parent 269bcb7 commit 216268f

3 files changed

Lines changed: 10 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: 'PT' }),
233+
makeReq('ok', { cfCountry: 'JP' }),
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('PT')
241+
expect(body.countryCode).toBe('JP')
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: 'PT' }),
329+
makeReq('ok', { cfCountry: 'JP' }),
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('PT')
335+
expect(body.countryCode).toBe('JP')
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: 'PT' }),
361+
makeReq('ok', { cfCountry: 'JP' }),
362362
makeDeps(sessionDeps, 'u1', {
363363
getCountryAccess: async (req) => {
364364
countryChecks++

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe('free mode country access', () => {
3333
['BE', 'BE'],
3434
['IT', 'IT'],
3535
['ES', 'ES'],
36+
['PT', 'PT'],
3637
])('allows allowlisted Cloudflare country %s', async (header, expected) => {
3738
const access = await getFreeModeCountryAccess(
3839
makeReq({
@@ -48,11 +49,11 @@ describe('free mode country access', () => {
4849

4950
test('blocks countries outside the allowlist', async () => {
5051
const access = await getFreeModeCountryAccess(
51-
makeReq({ 'cf-ipcountry': 'PT' }),
52+
makeReq({ 'cf-ipcountry': 'JP' }),
5253
noAnonymousNetwork,
5354
)
5455
expect(access.allowed).toBe(false)
55-
expect(access.countryCode).toBe('PT')
56+
expect(access.countryCode).toBe('JP')
5657
expect(access.blockReason).toBe('country_not_allowed')
5758
})
5859

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

300301
test('allowLocalhost does not bypass when cf-ipcountry is set', async () => {
301302
const access = await getFreeModeCountryAccess(
302-
makeReq({ 'cf-ipcountry': 'PT' }),
303+
makeReq({ 'cf-ipcountry': 'JP' }),
303304
{
304305
ipinfoToken: 'test-token',
305306
allowLocalhost: true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const FREE_MODE_ALLOWED_COUNTRIES = new Set([
2222
'FR',
2323
'IT',
2424
'ES',
25+
'PT',
2526
'FI',
2627
'BE',
2728
'LU',

0 commit comments

Comments
 (0)