[test] Move direct URL test to cover all specialDirs; Use storageFolderName to verify fix from d4658ce

This commit is contained in:
Sergey Konovalov
2025-06-19 12:31:59 +03:00
parent 40654b7eb2
commit 8702a1585b
4 changed files with 32 additions and 55 deletions

View File

@ -60,14 +60,7 @@ jobs:
"secretAccessKey": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
},
"persistentStorage": {
"name": "storage-az",
"region": "",
"endpoint": "http://127.0.0.1:10000/devstoreaccount1",
"bucketName": "test-container",
"storageFolderName": "files",
"cacheFolderName": "data",
"accessKeyId": "devstoreaccount1",
"secretAccessKey": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
"storageFolderName": "files/persistent"
}
}
EOF
@ -113,6 +106,4 @@ jobs:
"
- name: Run storage tests
run: |
cd ./DocService
npx jest ../tests/integration/withServerInstance/storage.tests.js --inject-globals=false --config=../tests/jest.config.js
run: npm run storage-tests

View File

@ -54,13 +54,7 @@ jobs:
"forcePathStyle": true
},
"persistentStorage": {
"name": "storage-s3",
"region": "us-east-1",
"endpoint": "http://localhost:9000",
"accessKeyId": "minioadmin",
"secretAccessKey": "minioadmin",
"bucket": "cache",
"forcePathStyle": true
"storageFolderName": "files/persistent"
}
}' >> Common/config/local.json
@ -70,6 +64,4 @@ jobs:
docker exec minio mc mb myminio/cache
- name: Run storage tests
run: |
cd ./DocService
npx jest ../tests/integration/withServerInstance/storage.tests.js --inject-globals=false --config=../tests/jest.config.js
run: npm run storage-tests

View File

@ -145,7 +145,7 @@ async function getSignedUrl(ctx, baseUrl, strPath, urlType, optFilename, opt_cre
let storage = getStorage(opt_specialDir);
let storageCfg = getStorageCfg(ctx, opt_specialDir);
let storagePath = getStoragePath(ctx, strPath, opt_specialDir);
const directUrlsEnabled = useDirectStorageUrls !== undefined ? useDirectStorageUrls : storageCfg.useDirectStorageUrls;
const directUrlsEnabled = useDirectStorageUrls ?? storageCfg.useDirectStorageUrls;
if (directUrlsEnabled && storage.getDirectSignedUrl) {
return await storage.getDirectSignedUrl(ctx, storageCfg, baseUrl, storagePath, urlType, optFilename, opt_creationDate);

View File

@ -286,6 +286,33 @@ function runTestForDir(ctx, isMultitenantMode, specialDir) {
}
expect(data.sort()).toEqual([testFileData3, testFileData4].sort());
});
test("getSignedUrl with direct URLs enabled", async () => {
let buffer = Buffer.from(testFileData1);
let res = await storage.putObject(ctx, testFile1, buffer, buffer.length, specialDirCache);
expect(res).toEqual(undefined);
let url = await storage.getSignedUrl(ctx, baseUrl, testFile1, urlType, undefined, undefined, specialDirCache, true);
let data = await request(url);
expect(data).toEqual(testFileData1);
if (cfgCacheStorage.name !== 'storage-fs') {
expect(url).toContain(cfgCacheStorage.endpoint);
expect(url).toContain(cfgCacheStorage.bucketName);
}
});
test("getSignedUrl with direct URLs disabled", async () => {
let buffer = Buffer.from(testFileData1);
let res = await storage.putObject(ctx, testFile1, buffer, buffer.length, specialDirCache);
expect(res).toEqual(undefined);
let url = await storage.getSignedUrl(ctx, baseUrl, testFile1, urlType, undefined, undefined, specialDirCache, false);
let data = await request(url);
expect(data).toEqual(testFileData1);
expect(url).toContain('md5');
expect(url).toContain('expires');
expect(url).toContain(cfgCacheStorage.storageFolderName);
});
test("deleteObject", async () => {
let list;
list = await storage.listObjects(ctx, testDir, specialDir);
@ -378,36 +405,3 @@ describe('storage mix common and forgotten dir', function () {
expect(list.sort()).toEqual([].sort());
});
});
describe('storage direct URL testing', function () {
test("getSignedUrl with direct URLs enabled", async () => {
let buffer = Buffer.from(testFileData1);
let res = await storage.putObject(ctx, testFile1, buffer, buffer.length, specialDirCache);
expect(res).toEqual(undefined);
let url = await storage.getSignedUrl(ctx, baseUrl, testFile1, urlType, undefined, undefined, specialDirCache, true);
let data = await request(url);
expect(data).toEqual(testFileData1);
if (cfgCacheStorage.name !== 'storage-fs') {
expect(url).toContain(cfgCacheStorage.endpoint);
expect(url).toContain(cfgCacheStorage.bucketName);
}
});
test("getSignedUrl with direct URLs disabled", async () => {
let buffer = Buffer.from(testFileData1);
let res = await storage.putObject(ctx, testFile1, buffer, buffer.length, specialDirCache);
expect(res).toEqual(undefined);
let url = await storage.getSignedUrl(ctx, baseUrl, testFile1, urlType, undefined, undefined, specialDirCache, false);
console.log("URL", url);
let data = await request(url);
expect(data).toEqual(testFileData1);
expect(url).toContain('md5');
expect(url).toContain('expires');
expect(url).toContain(cfgCacheStorage.storageFolderName);
});
});