test: failing on Windows 11

Massimo Melina committed Apr 30, 2025 at 13:02 UTC 4804b4a4c3ca5c1e37ebe960f4406e7d3c85e37e
1 file changed +6 -5
tests/test.ts
+6 -5
@@ -22,7 +22,8 @@ const username = 'rejetto'
22 const password = 'password'
23 const API = '/~/api/'
24 const ROOT = 'tests/'
25 -const BASE_URL = 'http://localhost:81'
25 +const BASE_URL = 'http://[::1]:81'
26 +const BASE_URL_127 = 'http://127.0.0.1:81'
27 const UPLOAD_ROOT = '/for-admins/upload/'
28 const UPLOAD_RELATIVE = 'temp/gpl.png'
29 const UPLOAD_DEST = UPLOAD_ROOT + UPLOAD_RELATIVE
@@ -59,7 +60,7 @@ describe('basics', () => {
60 test('bad range', req('/f1/f2/alfa.txt', 416, {
61 headers: { Range: 'bytes=7-' }
62 }))
62 - test('roots', req('/f2/alfa.txt', 200, { baseUrl: BASE_URL.replace('localhost', '127.0.0.1') })) // host 127.0.0.1 is rooted in /f1
63 + test('roots', req('/f2/alfa.txt', 200, { baseUrl: BASE_URL_127 })) // host 127.0.0.1 is rooted in /f1
64 test('website', req('/f1/page/', { re:/This is a test/, mime:'text/html' }))
65 test('traversal', req('/f1/page/.%2e/.%2e/README.md', 418))
66 test('custom mime from above', req('/tests/page/index.html', { status: 200, mime:'text/plain' }))
@@ -144,10 +145,10 @@ describe('basics', () => {
145 test('delete.need account', req(UPLOAD_ROOT, 401, { method: 'delete'}))
146 test('rename.no perm', reqApi('rename', { uri: '/for-admins', dest: 'any' }, 401))
147 test('of_disabled.cantLogin', () => login('of_disabled').then(() => { throw Error('logged in') }, () => {}))
147 - test('allow_net.canLogin', () => login('rejetto')) // localhost is normally resolved as ::1
148 + test('allow_net.canLogin', () => login(username))
149 test('allow_net.cantLogin', () => {
149 - defaultBaseUrl = BASE_URL.replace('localhost', '127.0.0.1')
150 - return login('rejetto').then(() => { throw Error('logged in') }, () => {})
150 + defaultBaseUrl = BASE_URL_127 // 127.0.0.1 is not allowed for this account
151 + return login(username).then(() => { throw Error('logged in') }, () => {})
152 .finally(() => defaultBaseUrl = BASE_URL)
153 })
154