SHA256
Обновить хранение вложений R2
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { preparePublicFile, fileMime } from '../../shine-UI/js/services/file-preparation-service.js';
|
||||
import { validatePublicPiecesRoot } from '../../shine-UI/js/services/public-pieces-root.js';
|
||||
|
||||
assert.equal(fileMime(new File(['x'], 'clip.mp4', { type: '' })), 'video/mp4');
|
||||
assert.equal(fileMime(new File(['x'], 'mystery', { type: '' })), 'application/octet-stream');
|
||||
@@ -7,7 +8,8 @@ for (const size of [1, 16384, 16385, 1048576, 1048577, 2097152]) {
|
||||
const blob = new File([new Uint8Array(size)], 'data.bin');
|
||||
const prepared = await preparePublicFile(blob);
|
||||
assert.equal(prepared.size, size);
|
||||
assert.match(prepared.pr, /^[A-Za-z0-9_-]{43}$/);
|
||||
assert.match(prepared.pr, /^[1-9A-HJ-NP-Za-km-z]{32,44}$/);
|
||||
assert.equal(validatePublicPiecesRoot(prepared.pr), true);
|
||||
assert.equal((await preparePublicFile(blob)).pr, prepared.pr);
|
||||
}
|
||||
console.log('R2 client preparation smoke tests OK');
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
const root = new URL('../../', import.meta.url);
|
||||
const migration = await readFile(new URL('SHiNE-server/shine-server-db/src/main/resources/postgres/migration_v42.sql', root), 'utf8');
|
||||
const boot = await readFile(new URL('SHiNE-server/shine-server-db/src/main/java/shine/db/DatabaseInitializer.java', root), 'utf8');
|
||||
const recorder = await readFile(new URL('SHiNE-server/src/main/java/server/files/R2UploadAuditRecorder.java', root), 'utf8');
|
||||
const publicApi = await readFile(new URL('SHiNE-server/src/main/java/server/files/R2PrepareServlet.java', root), 'utf8');
|
||||
const dmApi = await readFile(new URL('SHiNE-server/src/main/java/server/files/R2DmPrepareServlet.java', root), 'utf8');
|
||||
for (const table of ['public_file_uploads', 'dm_file_uploads']) {
|
||||
assert.ok(migration.includes(`CREATE TABLE IF NOT EXISTS ${table}`));
|
||||
assert.ok(recorder.includes(`"${table}"`));
|
||||
}
|
||||
assert.match(migration, /schema_version = 42/);
|
||||
assert.match(boot, /SCHEMA_VERSION_42 = 42/);
|
||||
assert.match(boot, /POSTGRES_MIGRATION_V42_RESOURCE/);
|
||||
assert.match(publicApi, /R2UploadAuditRecorder\.record\(req, false/);
|
||||
assert.match(dmApi, /R2UploadAuditRecorder\.record\(req, true/);
|
||||
console.log('R2 upload audit schema wiring OK');
|
||||
Reference in New Issue
Block a user