Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion freebuff/web/src/app/home-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const faqs = [
{
question: 'Which countries is Freebuff available in?',
answer:
'Freebuff is currently available in:\n\nUnited States, Canada, United Kingdom, Australia, New Zealand, Norway, Sweden, Netherlands, Denmark, Germany, Finland, Belgium, Luxembourg, Liechtenstein, Switzerland, Austria, Singapore, Malta, Israel, Ireland, and Iceland.',
'Freebuff is currently available in:\n\nUnited States, Canada, United Kingdom, Australia, New Zealand, Norway, Sweden, Netherlands, Denmark, Germany, France, Italy, Spain, Portugal, Finland, Belgium, Luxembourg, Liechtenstein, Switzerland, Austria, Singapore, Malta, Israel, Ireland, and Iceland.',
},
{
question: 'Are you training on my data?',
Expand Down
10 changes: 5 additions & 5 deletions web/src/app/api/v1/freebuff/session/__tests__/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ describe('POST /api/v1/freebuff/session', () => {
test('returns country_blocked without joining the queue for disallowed country', async () => {
const sessionDeps = makeSessionDeps()
const resp = await postFreebuffSession(
makeReq('ok', { cfCountry: 'FR' }),
makeReq('ok', { cfCountry: 'JP' }),
makeDeps(sessionDeps, 'u1'),
)
// 403 (not 200) so older CLIs that don't know `country_blocked` fall into
// their error-retry backoff instead of tight-polling.
expect(resp.status).toBe(403)
const body = await resp.json()
expect(body.status).toBe('country_blocked')
expect(body.countryCode).toBe('FR')
expect(body.countryCode).toBe('JP')
expect(body.countryBlockReason).toBe('country_not_allowed')
expect(sessionDeps.rows.size).toBe(0)
})
Expand Down Expand Up @@ -326,13 +326,13 @@ describe('GET /api/v1/freebuff/session', () => {
test('returns country_blocked for disallowed country on GET', async () => {
const sessionDeps = makeSessionDeps()
const resp = await getFreebuffSession(
makeReq('ok', { cfCountry: 'FR' }),
makeReq('ok', { cfCountry: 'JP' }),
makeDeps(sessionDeps, 'u1'),
)
expect(resp.status).toBe(403)
const body = await resp.json()
expect(body.status).toBe('country_blocked')
expect(body.countryCode).toBe('FR')
expect(body.countryCode).toBe('JP')
expect(body.countryBlockReason).toBe('country_not_allowed')
})

Expand All @@ -358,7 +358,7 @@ describe('GET /api/v1/freebuff/session', () => {
})
let countryChecks = 0
const resp = await getFreebuffSession(
makeReq('ok', { cfCountry: 'FR' }),
makeReq('ok', { cfCountry: 'JP' }),
makeDeps(sessionDeps, 'u1', {
getCountryAccess: async (req) => {
countryChecks++
Expand Down
11 changes: 8 additions & 3 deletions web/src/server/__tests__/free-mode-country.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ describe('free mode country access', () => {
['SG', 'SG'],
['MT', 'MT'],
['IL', 'IL'],
['FR', 'FR'],
['BE', 'BE'],
['IT', 'IT'],
['ES', 'ES'],
['PT', 'PT'],
])('allows allowlisted Cloudflare country %s', async (header, expected) => {
const access = await getFreeModeCountryAccess(
makeReq({
Expand All @@ -44,11 +49,11 @@ describe('free mode country access', () => {

test('blocks countries outside the allowlist', async () => {
const access = await getFreeModeCountryAccess(
makeReq({ 'cf-ipcountry': 'FR' }),
makeReq({ 'cf-ipcountry': 'JP' }),
noAnonymousNetwork,
)
expect(access.allowed).toBe(false)
expect(access.countryCode).toBe('FR')
expect(access.countryCode).toBe('JP')
expect(access.blockReason).toBe('country_not_allowed')
})

Expand Down Expand Up @@ -295,7 +300,7 @@ describe('free mode country access', () => {

test('allowLocalhost does not bypass when cf-ipcountry is set', async () => {
const access = await getFreeModeCountryAccess(
makeReq({ 'cf-ipcountry': 'FR' }),
makeReq({ 'cf-ipcountry': 'JP' }),
{
ipinfoToken: 'test-token',
allowLocalhost: true,
Expand Down
4 changes: 4 additions & 0 deletions web/src/server/free-mode-country.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const FREE_MODE_ALLOWED_COUNTRIES = new Set([
'NL',
'DK',
'DE',
'FR',
'IT',
'ES',
'PT',
'FI',
'BE',
'LU',
Expand Down
Loading