fix: enforce gallery access and consolidate gallery workflows (#1357)
Harden gallery authentication and authorization, consolidate gallery workflows, and prevent token-bearing URLs from leaking through nginx request error logs.
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
// Supertest 6 binds an IPv6 wildcard listener but hardcodes an IPv4 URL.
|
||||
// macOS can allocate that IPv6 port while a different IPv4 service owns it.
|
||||
// Address the listener's actual family so a test cannot reach that service.
|
||||
jest.mock('supertest/lib/test', () => {
|
||||
const Test = jest.requireActual('supertest/lib/test');
|
||||
const serverAddress = Test.prototype.serverAddress;
|
||||
Test.prototype.serverAddress = function(app, path) {
|
||||
const url = serverAddress.call(this, app, path);
|
||||
return app.address()?.family === 'IPv6'
|
||||
? url.replace('://127.0.0.1:', '://[::1]:')
|
||||
: url;
|
||||
};
|
||||
return Test;
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.JWT_SECRET = 'test-secret';
|
||||
@@ -8,3 +23,11 @@ beforeAll(() => {
|
||||
process.env.STORAGE_PATH = '/storage';
|
||||
}
|
||||
});
|
||||
|
||||
// Dispose resources loaded by this suite using the application's draining
|
||||
// shutdown. Individual fixtures still own temporary files and other DB pools.
|
||||
afterAll(async () => {
|
||||
await require('./src/services/serviceShutdown').stopServices();
|
||||
const loadedDb = require.cache[require.resolve('./src/database/db')];
|
||||
if (typeof loadedDb?.exports.db?.destroy === 'function') await loadedDb.exports.db.destroy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user