fix: handle undefined SITE_ACCESS_IPS restore, add build403Html('') test
This commit is contained in:
@@ -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' })
|
||||
|
||||
Reference in New Issue
Block a user