diff --git a/.github/workflows/azureStorageTests.yml b/.github/workflows/azureStorageTests.yml index 28e5a285..175ebd47 100644 --- a/.github/workflows/azureStorageTests.yml +++ b/.github/workflows/azureStorageTests.yml @@ -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 \ No newline at end of file + run: npm run storage-tests \ No newline at end of file diff --git a/.github/workflows/s3storageTests.yml b/.github/workflows/s3storageTests.yml index f6f657ca..cc34f819 100644 --- a/.github/workflows/s3storageTests.yml +++ b/.github/workflows/s3storageTests.yml @@ -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 \ No newline at end of file + run: npm run storage-tests \ No newline at end of file diff --git a/Common/sources/storage/storage-base.js b/Common/sources/storage/storage-base.js index 3a016cf6..f31a2c5a 100644 --- a/Common/sources/storage/storage-base.js +++ b/Common/sources/storage/storage-base.js @@ -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); diff --git a/tests/integration/withServerInstance/storage.tests.js b/tests/integration/withServerInstance/storage.tests.js index 649ee119..04ba5dbc 100644 --- a/tests/integration/withServerInstance/storage.tests.js +++ b/tests/integration/withServerInstance/storage.tests.js @@ -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); - }); -});