mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
Merge remote-tracking branch 'origin/dev' into feat/storage-driver
# Conflicts: # server/src/db/migrations.ts # server/src/nest/journey/journey.controller.ts # server/tests/integration/leg-mode-incoming.test.ts # server/tests/unit/nest/journey.controller.test.ts # server/vitest.config.ts
This commit is contained in:
@@ -43,10 +43,17 @@ describe('incoming_leg_transport_mode migration', () => {
|
||||
//
|
||||
// >>> Appending a migration? Re-point the undo below at whatever yours
|
||||
// >>> does. That is the whole maintenance cost of this guard.
|
||||
// Trailing migrations today (a dev/feat-storage-driver merge landed two
|
||||
// in one release window, so the rewind spans both):
|
||||
// version-2 — reservation_day_positions cross-trip cleanup: undone by
|
||||
// Trailing migrations today (a dev/feat-storage-driver merge landed five
|
||||
// in one release window, so the rewind spans all of them):
|
||||
// version-5 — reservation_day_positions cross-trip cleanup: undone by
|
||||
// re-inserting a mismatched reservation/day pair.
|
||||
// version-4 — #1939 instance API key promotion: nothing to undo — the
|
||||
// seeded users are not admins and hold no keys, so the
|
||||
// replay is a no-op by its own guards.
|
||||
// version-3 — trek_photos capture metadata (#1614): column-guarded, so
|
||||
// the replay is a no-op; the from-scratch case above covers it.
|
||||
// version-2 — journey_share_tokens.newest_first: undone by dropping the
|
||||
// column and letting the replay put it back.
|
||||
// version-1 — storage slice-2 trip_files 'files/' prefix strip: undone
|
||||
// by re-inserting a prefixed row.
|
||||
const upgraded = new Database(':memory:');
|
||||
@@ -68,7 +75,15 @@ describe('incoming_leg_transport_mode migration', () => {
|
||||
insertPosition.run(reservationOnA, dayOnA, 2); // a legitimate one it must leave alone
|
||||
upgraded.prepare("INSERT INTO trip_files (trip_id, filename, original_name) VALUES (?, 'files/aaa.pdf', 'a.pdf')").run(tripA);
|
||||
|
||||
upgraded.prepare('UPDATE schema_version SET version = ?').run(version - 2);
|
||||
const hasNewestFirst = () =>
|
||||
(upgraded.prepare("SELECT name FROM pragma_table_info('journey_share_tokens')").all() as { name: string }[])
|
||||
.some(c => c.name === 'newest_first');
|
||||
|
||||
expect(hasNewestFirst()).toBe(true);
|
||||
upgraded.exec('ALTER TABLE journey_share_tokens DROP COLUMN newest_first');
|
||||
expect(hasNewestFirst()).toBe(false);
|
||||
|
||||
upgraded.prepare('UPDATE schema_version SET version = ?').run(version - 5);
|
||||
|
||||
runMigrations(upgraded);
|
||||
|
||||
@@ -76,6 +91,7 @@ describe('incoming_leg_transport_mode migration', () => {
|
||||
expect(positions).toEqual([{ day_id: Number(dayOnA) }]);
|
||||
const files = upgraded.prepare('SELECT filename FROM trip_files').all() as { filename: string }[];
|
||||
expect(files.map(r => r.filename)).toEqual(['aaa.pdf']);
|
||||
expect(hasNewestFirst()).toBe(true);
|
||||
expect(upgraded.prepare('SELECT version FROM schema_version').get()).toEqual({ version });
|
||||
upgraded.close();
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ const { testDb, dbMock, immichState } = vi.hoisted(() => {
|
||||
* the legacy one. Both must be filtered out of the picker (#1474).
|
||||
*/
|
||||
const DEFAULT_ALBUM_ASSETS = [
|
||||
{ id: 'asset-sync-1', type: 'IMAGE', fileCreatedAt: '2024-06-01T10:00:00.000Z', exifInfo: { city: 'Paris', country: 'France' } },
|
||||
{ id: 'asset-sync-1', type: 'IMAGE', fileCreatedAt: '2024-06-01T10:00:00.000Z', exifInfo: { city: 'Paris', country: 'France', latitude: 48.8584, longitude: 2.2945 } },
|
||||
{ id: 'asset-sync-2', type: 'VIDEO', fileCreatedAt: '2024-06-02T10:00:00.000Z', exifInfo: { city: 'Lyon', country: 'France' } },
|
||||
{ id: 'asset-hidden', type: 'VIDEO', fileCreatedAt: '2024-06-03T10:00:00.000Z', visibility: 'hidden' },
|
||||
{ id: 'asset-legacy-hidden', type: 'VIDEO', fileCreatedAt: '2024-06-04T10:00:00.000Z', isVisible: false },
|
||||
@@ -590,6 +590,23 @@ describe('Immich album photos', () => {
|
||||
expect(res.body.assets[1].mediaType).toBe('video');
|
||||
});
|
||||
|
||||
// #1614 — the album mapping used to drop lat/lng even though the search path
|
||||
// kept them, so a photo picked from an album could never reach a map.
|
||||
it('IMMICH-064b — album photos carry their capture coordinates, and tolerate their absence', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
setImmichCredentials(testDb, user.id, 'https://immich.example.com', 'test-api-key');
|
||||
|
||||
const res = await request(app)
|
||||
.get(`${IMMICH}/albums/album-uuid-1/photos`)
|
||||
.set('Cookie', authCookie(user.id));
|
||||
|
||||
expect(res.body.assets[0]).toMatchObject({ lat: 48.8584, lng: 2.2945 });
|
||||
// The second fixture asset has no coordinates; it must come back null, not undefined
|
||||
// or a half pair.
|
||||
expect(res.body.assets[1].lat).toBeNull();
|
||||
expect(res.body.assets[1].lng).toBeNull();
|
||||
});
|
||||
|
||||
it('IMMICH-065 — album photos are fetched via search/metadata with albumIds and withExif', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
setImmichCredentials(testDb, user.id, 'https://immich.example.com', 'test-api-key');
|
||||
|
||||
@@ -136,6 +136,35 @@ describe('API key encryption', () => {
|
||||
expect(row.openweather_api_key).toMatch(/^enc:v1:/);
|
||||
});
|
||||
|
||||
it('SEC-008 — saving keys audits the names and never the values (#1939)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
|
||||
const save = () =>
|
||||
request(app)
|
||||
.put('/api/auth/me/api-keys')
|
||||
.set('Cookie', authCookie(user.id))
|
||||
.send({ openweather_api_key: 'test-api-key-12345' });
|
||||
|
||||
const first = await save();
|
||||
expect(first.status).toBe(200);
|
||||
// changedKeys is internal: the client body is what it always was.
|
||||
expect(first.body).not.toHaveProperty('changedKeys');
|
||||
|
||||
const rows = () =>
|
||||
testDb
|
||||
.prepare("SELECT details FROM audit_log WHERE action = 'settings.api_keys_update'")
|
||||
.all() as { details: string | null }[];
|
||||
expect(rows()).toHaveLength(1);
|
||||
expect(rows()[0].details).toContain('openweather_api_key');
|
||||
expect(rows()[0].details).not.toContain('test-api-key-12345');
|
||||
|
||||
// The same value again writes no second row. This is the real test of the
|
||||
// cleartext comparison: encryption uses a random IV, so the stored blob
|
||||
// differs on every save even when the key does not.
|
||||
await save();
|
||||
expect(rows()).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('SEC-008 — GET /api/auth/me does not return plaintext API key', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
await request(app)
|
||||
|
||||
Reference in New Issue
Block a user