fix: handle undefined SITE_ACCESS_IPS restore, add build403Html('') test

This commit is contained in:
Kirill
2026-05-23 11:12:00 +05:00
parent fd720572e7
commit 8001d7d32c
+10 -1
View File
@@ -24,7 +24,11 @@ describe('registerIpGate', () => {
afterEach(async () => {
await app.close()
process.env.SITE_ACCESS_IPS = originalIps
if (originalIps === undefined) {
delete process.env.SITE_ACCESS_IPS
} else {
process.env.SITE_ACCESS_IPS = originalIps
}
})
it('пропускает запрос если SITE_ACCESS_IPS не задан', async () => {
@@ -67,6 +71,11 @@ describe('registerIpGate', () => {
expect(html).not.toContain('не определён')
})
it('build403Html с пустой строкой показывает "не определён"', () => {
const html = build403Html('')
expect(html).toContain('не определён')
})
it('403-страница показывает IP по умолчанию (127.0.0.1) когда remoteAddress не указан', async () => {
process.env.SITE_ACCESS_IPS = '1.2.3.4'
const res = await app.inject({ method: 'GET', url: '/test' })