From e20cce9b96237a98f37fd05f234cb3729e70db86 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 11:56:54 +1100 Subject: [PATCH 01/21] Update triggers.js --- src/triggers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/triggers.js b/src/triggers.js index b5f11435df..594eef9cb1 100644 --- a/src/triggers.js +++ b/src/triggers.js @@ -159,6 +159,7 @@ export function removeTrigger(type, className, applicationId) { export function _unregisterAll() { Object.keys(_triggerStore).forEach(appId => delete _triggerStore[appId]); + console.log(_triggerStore); } export function toJSONwithObjects(object, className) { From f91aa19ede23fc54c3d61408228c022f0c675d38 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 12:16:11 +1100 Subject: [PATCH 02/21] wip --- spec/AuthenticationAdaptersV2.spec.js | 2 +- spec/JobSchedule.spec.js | 25 +++++++++++++++++++++++++ spec/ParseLiveQueryRedis.spec.js | 2 ++ spec/ParseLiveQueryServer.spec.js | 1 + spec/RateLimit.spec.js | 2 +- spec/index.spec.js | 2 +- src/Config.js | 10 ++++++++++ src/cloud-code/Parse.Cloud.js | 16 +++++++++++----- src/middlewares.js | 3 ++- 9 files changed, 54 insertions(+), 9 deletions(-) diff --git a/spec/AuthenticationAdaptersV2.spec.js b/spec/AuthenticationAdaptersV2.spec.js index 9507691114..aaa172ea66 100644 --- a/spec/AuthenticationAdaptersV2.spec.js +++ b/spec/AuthenticationAdaptersV2.spec.js @@ -348,7 +348,7 @@ describe('Auth Adapter features', () => { it('should strip out authData if required', async () => { const spy = spyOn(modernAdapter3, 'validateOptions').and.callThrough(); const afterSpy = spyOn(modernAdapter3, 'afterFind').and.callThrough(); - await reconfigureServer({ auth: { modernAdapter3 }, silent: false }); + await reconfigureServer({ auth: { modernAdapter3 } }); const user = new Parse.User(); await user.save({ authData: { modernAdapter3: { id: 'modernAdapter3Data' } } }); await user.fetch({ sessionToken: user.getSessionToken() }); diff --git a/spec/JobSchedule.spec.js b/spec/JobSchedule.spec.js index 853eb20143..e31bbccd8c 100644 --- a/spec/JobSchedule.spec.js +++ b/spec/JobSchedule.spec.js @@ -21,6 +21,31 @@ const masterKeyOptions = { }; describe('JobSchedule', () => { + beforeEach(async () => { + const jobs = await request( + Object.assign( + { + url: Parse.serverURL + '/cloud_code/jobs', + }, + masterKeyOptions + ) + ); + if (jobs.data.length) { + await Promise.all( + jobs.data.map(({ objectId }) => + request( + Object.assign( + { + method: 'DELETE', + url: `${Parse.serverURL}/cloud_code/jobs/${objectId}`, + }, + masterKeyOptions + ) + ) + ) + ); + } + }); it('should create _JobSchedule with masterKey', done => { const jobSchedule = new Parse.Object('_JobSchedule'); jobSchedule.set({ diff --git a/spec/ParseLiveQueryRedis.spec.js b/spec/ParseLiveQueryRedis.spec.js index 3187d23cc8..deb84bafb2 100644 --- a/spec/ParseLiveQueryRedis.spec.js +++ b/spec/ParseLiveQueryRedis.spec.js @@ -6,6 +6,7 @@ if (process.env.PARSE_SERVER_TEST_CACHE === 'redis') { }); it('can connect', async () => { await reconfigureServer({ + appId: 'redis_live_query', startLiveQueryServer: true, liveQuery: { classNames: ['TestObject'], @@ -36,6 +37,7 @@ if (process.env.PARSE_SERVER_TEST_CACHE === 'redis') { it('can call connect twice', async () => { const server = await reconfigureServer({ + appId: 'redis_live_query', startLiveQueryServer: true, liveQuery: { classNames: ['TestObject'], diff --git a/spec/ParseLiveQueryServer.spec.js b/spec/ParseLiveQueryServer.spec.js index 16654cdd64..50f29d0aab 100644 --- a/spec/ParseLiveQueryServer.spec.js +++ b/spec/ParseLiveQueryServer.spec.js @@ -115,6 +115,7 @@ describe('ParseLiveQueryServer', function () { }); describe_only_db('mongo')('initialization', () => { + beforeEach(() => reconfigureServer({ appId: 'mongo_init_test' })); it('can be initialized through ParseServer without liveQueryServerOptions', async () => { const parseServer = await ParseServer.startApp({ appId: 'hello', diff --git a/spec/RateLimit.spec.js b/spec/RateLimit.spec.js index 894c8fcf82..f2c4c3312a 100644 --- a/spec/RateLimit.spec.js +++ b/spec/RateLimit.spec.js @@ -21,7 +21,7 @@ describe('rate limit', () => { }); it('can limit cloud functions with user session token', async () => { - await Parse.User.signUp('myUser', 'password'); + await Parse.User.signUp('rateLimitMyUser', 'password'); Parse.Cloud.define('test', () => 'Abc'); await reconfigureServer({ rateLimit: [ diff --git a/spec/index.spec.js b/spec/index.spec.js index 64c4b54db7..08ef16a77b 100644 --- a/spec/index.spec.js +++ b/spec/index.spec.js @@ -558,7 +558,7 @@ describe('server', () => { }); it('can get starting state', async () => { - await reconfigureServer({ appId: 'test2', silent: false }); + await reconfigureServer({ appId: 'test2' }); const parseServer = new ParseServer.ParseServer({ ...defaultConfiguration, appId: 'test2', diff --git a/src/Config.js b/src/Config.js index 2e7ef389c7..812d28c367 100644 --- a/src/Config.js +++ b/src/Config.js @@ -626,6 +626,16 @@ export class Config { return new Date(now.getTime() + this.sessionLength * 1000); } + unregisterRateLimiters() { + let i = this.rateLimits?.length; + while (i--) { + const limit = this.rateLimits[i]; + if (limit.cloud) { + this.rateLimits.splice(i, 1); + } + } + } + get invalidLinkURL() { return this.customPages.invalidLink || `${this.publicServerURL}/apps/invalid_link.html`; } diff --git a/src/cloud-code/Parse.Cloud.js b/src/cloud-code/Parse.Cloud.js index 75faf44f3d..6a5659276c 100644 --- a/src/cloud-code/Parse.Cloud.js +++ b/src/cloud-code/Parse.Cloud.js @@ -128,7 +128,8 @@ ParseCloud.define = function (functionName, handler, validationHandler) { if (validationHandler && validationHandler.rateLimit) { addRateLimit( { requestPath: `/functions/${functionName}`, ...validationHandler.rateLimit }, - Parse.applicationId + Parse.applicationId, + true ); } }; @@ -191,7 +192,8 @@ ParseCloud.beforeSave = function (parseClass, handler, validationHandler) { requestMethods: ['POST', 'PUT'], ...validationHandler.rateLimit, }, - Parse.applicationId + Parse.applicationId, + true ); } }; @@ -237,7 +239,8 @@ ParseCloud.beforeDelete = function (parseClass, handler, validationHandler) { requestMethods: 'DELETE', ...validationHandler.rateLimit, }, - Parse.applicationId + Parse.applicationId, + true ); } }; @@ -278,7 +281,8 @@ ParseCloud.beforeLogin = function (handler, validationHandler) { if (validationHandler && validationHandler.rateLimit) { addRateLimit( { requestPath: `/login`, requestMethods: 'POST', ...validationHandler.rateLimit }, - Parse.applicationId + Parse.applicationId, + true ); } }; @@ -456,7 +460,8 @@ ParseCloud.beforeFind = function (parseClass, handler, validationHandler) { requestMethods: 'GET', ...validationHandler.rateLimit, }, - Parse.applicationId + Parse.applicationId, + true ); } }; @@ -761,6 +766,7 @@ ParseCloud.afterLiveQueryEvent = function (parseClass, handler, validationHandle ParseCloud._removeAllHooks = () => { triggers._unregisterAll(); + Config.get(Parse.applicationId).unregisterRateLimiters(); }; ParseCloud.useMasterKey = () => { diff --git a/src/middlewares.js b/src/middlewares.js index 8f3915e4b6..7a5b03bdce 100644 --- a/src/middlewares.js +++ b/src/middlewares.js @@ -466,7 +466,7 @@ export function promiseEnforceMasterKeyAccess(request) { return Promise.resolve(); } -export const addRateLimit = (route, config) => { +export const addRateLimit = (route, config, cloud) => { if (typeof config === 'string') { config = Config.get(config); } @@ -545,6 +545,7 @@ export const addRateLimit = (route, config) => { }, store: redisStore.store, }), + cloud, }); Config.put(config); }; From 8e620f8605df19190aed85a09c07248d15b8b8f1 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 12:21:11 +1100 Subject: [PATCH 03/21] Update Parse.Cloud.js --- src/cloud-code/Parse.Cloud.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cloud-code/Parse.Cloud.js b/src/cloud-code/Parse.Cloud.js index 6a5659276c..5540e8d719 100644 --- a/src/cloud-code/Parse.Cloud.js +++ b/src/cloud-code/Parse.Cloud.js @@ -766,7 +766,8 @@ ParseCloud.afterLiveQueryEvent = function (parseClass, handler, validationHandle ParseCloud._removeAllHooks = () => { triggers._unregisterAll(); - Config.get(Parse.applicationId).unregisterRateLimiters(); + const config = Config.get(Parse.applicationId); + config?.unregisterRateLimiters(); }; ParseCloud.useMasterKey = () => { From 1411801e3b20e6ee6f34ce7c169ab3e170508138 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 12:37:14 +1100 Subject: [PATCH 04/21] Update middlewares.js --- src/middlewares.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middlewares.js b/src/middlewares.js index 7a5b03bdce..0dca33135e 100644 --- a/src/middlewares.js +++ b/src/middlewares.js @@ -483,9 +483,9 @@ export const addRateLimit = (route, config, cloud) => { store: null, connected: false, }; - if (route.redisrUrl) { + if (route.redisUrl) { const client = createClient({ - url: route.redisrUrl, + url: route.redisUrl, }); redisStore.connectionPromise = async () => { if (redisStore.connected) { From 1f2ba98d2eb2a2a4d25ba7c66e7913b8962868a1 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 12:50:31 +1100 Subject: [PATCH 05/21] wip --- spec/helper.js | 1 + src/triggers.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helper.js b/spec/helper.js index 445a137ac5..1a811d7d1c 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -214,6 +214,7 @@ afterEach(function (done) { done(); }; Parse.Cloud._removeAllHooks(); + Parse.CoreManager.getLiveQueryController().setDefaultLiveQueryClient(); defaults.protectedFields = { _User: { '*': ['email'] } }; databaseAdapter .getAllClasses() diff --git a/src/triggers.js b/src/triggers.js index 594eef9cb1..b5f11435df 100644 --- a/src/triggers.js +++ b/src/triggers.js @@ -159,7 +159,6 @@ export function removeTrigger(type, className, applicationId) { export function _unregisterAll() { Object.keys(_triggerStore).forEach(appId => delete _triggerStore[appId]); - console.log(_triggerStore); } export function toJSONwithObjects(object, className) { From 0fdba30190850092d755bee581f021a19f7baea4 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 13:04:36 +1100 Subject: [PATCH 06/21] Update TestUtils.js --- src/TestUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TestUtils.js b/src/TestUtils.js index 7772bcd65b..f859c00951 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -14,6 +14,7 @@ export function destroyAllDataPermanently(fast) { if (app.databaseController) { return app.databaseController.deleteEverything(fast); } else { + console.log('Could not delete: ', Object.keys(app)); return Promise.resolve(); } }) From 9f4f7b4ce26cc3589ba4e3e05d062236d7901ee7 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 13:16:21 +1100 Subject: [PATCH 07/21] Update TestUtils.js --- src/TestUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TestUtils.js b/src/TestUtils.js index f859c00951..f5731bb478 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -14,7 +14,7 @@ export function destroyAllDataPermanently(fast) { if (app.databaseController) { return app.databaseController.deleteEverything(fast); } else { - console.log('Could not delete: ', Object.keys(app)); + console.log('Could not delete: ', app.databaseAdapter); return Promise.resolve(); } }) From f4f3aa3ce6820786aecbe438d7da43792b2eedd7 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 13:21:53 +1100 Subject: [PATCH 08/21] Update TestUtils.js --- src/TestUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TestUtils.js b/src/TestUtils.js index f5731bb478..df456e073d 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -1,5 +1,5 @@ import AppCache from './cache'; - +import SchemaCache from './Adapters/Cache/SchemaCache'; /** * Destroys all data in the database * @param {boolean} fast set to true if it's ok to just drop objects and not indexes. @@ -13,8 +13,10 @@ export function destroyAllDataPermanently(fast) { const app = AppCache.get(appId); if (app.databaseController) { return app.databaseController.deleteEverything(fast); + } else if (app.databaseAdapter) { + SchemaCache.clear(); + return app.databaseAdapter.deleteAllClasses(fast); } else { - console.log('Could not delete: ', app.databaseAdapter); return Promise.resolve(); } }) From ecb76302c3ca16ca274b1553402535ccc3cb09ab Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 13:22:00 +1100 Subject: [PATCH 09/21] Update TestUtils.js --- src/TestUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TestUtils.js b/src/TestUtils.js index df456e073d..78fe1093c4 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -1,5 +1,6 @@ import AppCache from './cache'; import SchemaCache from './Adapters/Cache/SchemaCache'; + /** * Destroys all data in the database * @param {boolean} fast set to true if it's ok to just drop objects and not indexes. From a50e7f006d24842e67192781cc5077d5d35f6c2d Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 13:34:27 +1100 Subject: [PATCH 10/21] refactor --- spec/JobSchedule.spec.js | 50 ++++++++++++++++++++-------------------- spec/RateLimit.spec.js | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/spec/JobSchedule.spec.js b/spec/JobSchedule.spec.js index e31bbccd8c..b08381da84 100644 --- a/spec/JobSchedule.spec.js +++ b/spec/JobSchedule.spec.js @@ -21,31 +21,31 @@ const masterKeyOptions = { }; describe('JobSchedule', () => { - beforeEach(async () => { - const jobs = await request( - Object.assign( - { - url: Parse.serverURL + '/cloud_code/jobs', - }, - masterKeyOptions - ) - ); - if (jobs.data.length) { - await Promise.all( - jobs.data.map(({ objectId }) => - request( - Object.assign( - { - method: 'DELETE', - url: `${Parse.serverURL}/cloud_code/jobs/${objectId}`, - }, - masterKeyOptions - ) - ) - ) - ); - } - }); + // beforeEach(async () => { + // const jobs = await request( + // Object.assign( + // { + // url: Parse.serverURL + '/cloud_code/jobs', + // }, + // masterKeyOptions + // ) + // ); + // if (jobs.data.length) { + // await Promise.all( + // jobs.data.map(({ objectId }) => + // request( + // Object.assign( + // { + // method: 'DELETE', + // url: `${Parse.serverURL}/cloud_code/jobs/${objectId}`, + // }, + // masterKeyOptions + // ) + // ) + // ) + // ); + // } + // }); it('should create _JobSchedule with masterKey', done => { const jobSchedule = new Parse.Object('_JobSchedule'); jobSchedule.set({ diff --git a/spec/RateLimit.spec.js b/spec/RateLimit.spec.js index f2c4c3312a..894c8fcf82 100644 --- a/spec/RateLimit.spec.js +++ b/spec/RateLimit.spec.js @@ -21,7 +21,7 @@ describe('rate limit', () => { }); it('can limit cloud functions with user session token', async () => { - await Parse.User.signUp('rateLimitMyUser', 'password'); + await Parse.User.signUp('myUser', 'password'); Parse.Cloud.define('test', () => 'Abc'); await reconfigureServer({ rateLimit: [ From 1fbd50cf62b2a3a3d43da11519319b3789b8ece9 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 13:47:19 +1100 Subject: [PATCH 11/21] Update JobSchedule.spec.js --- spec/JobSchedule.spec.js | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/spec/JobSchedule.spec.js b/spec/JobSchedule.spec.js index b08381da84..853eb20143 100644 --- a/spec/JobSchedule.spec.js +++ b/spec/JobSchedule.spec.js @@ -21,31 +21,6 @@ const masterKeyOptions = { }; describe('JobSchedule', () => { - // beforeEach(async () => { - // const jobs = await request( - // Object.assign( - // { - // url: Parse.serverURL + '/cloud_code/jobs', - // }, - // masterKeyOptions - // ) - // ); - // if (jobs.data.length) { - // await Promise.all( - // jobs.data.map(({ objectId }) => - // request( - // Object.assign( - // { - // method: 'DELETE', - // url: `${Parse.serverURL}/cloud_code/jobs/${objectId}`, - // }, - // masterKeyOptions - // ) - // ) - // ) - // ); - // } - // }); it('should create _JobSchedule with masterKey', done => { const jobSchedule = new Parse.Object('_JobSchedule'); jobSchedule.set({ From 5449bca8f50efd3e494f75275dd35d85a0db228c Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 14:12:18 +1100 Subject: [PATCH 12/21] Update helper.js --- spec/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helper.js b/spec/helper.js index 1a811d7d1c..8e3aaaec39 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -82,7 +82,7 @@ on_db( ); let logLevel; -let silent = true; +let silent = false; if (process.env.VERBOSE) { silent = false; logLevel = 'verbose'; From be33f640cb855ac5593f9c6764541cad66927473 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 14:26:18 +1100 Subject: [PATCH 13/21] Update TestUtils.js --- src/TestUtils.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/TestUtils.js b/src/TestUtils.js index 78fe1093c4..00d48cb935 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -12,14 +12,20 @@ export function destroyAllDataPermanently(fast) { return Promise.all( Object.keys(AppCache.cache).map(appId => { const app = AppCache.get(appId); + const deletePromises = []; + if (app.cacheAdapter) { + deletePromises.push(app.cacheAdapter.clear()); + } if (app.databaseController) { - return app.databaseController.deleteEverything(fast); - } else if (app.databaseAdapter) { + deletePromises.push(app.databaseController.deleteEverything(fast)); + } + if (app.databaseAdapter) { SchemaCache.clear(); - return app.databaseAdapter.deleteAllClasses(fast); + deletePromises.push(app.databaseAdapter.deleteAllClasses(fast)); } else { - return Promise.resolve(); + console.log('could not delete', app); } + return Promise.all(deletePromises); }) ); } From 9e9617c74f10cb1a91e6cd72c2f555e448524908 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 14:37:55 +1100 Subject: [PATCH 14/21] Update TestUtils.js --- src/TestUtils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/TestUtils.js b/src/TestUtils.js index 00d48cb935..af423e6e78 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -22,10 +22,12 @@ export function destroyAllDataPermanently(fast) { if (app.databaseAdapter) { SchemaCache.clear(); deletePromises.push(app.databaseAdapter.deleteAllClasses(fast)); - } else { - console.log('could not delete', app); } - return Promise.all(deletePromises); + try { + return Promise.all(deletePromises); + } catch (e) { + /* ignore */ + } }) ); } From f7f2c227b517dc9dc79722b3b96fc27f15c7f9db Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 14:47:46 +1100 Subject: [PATCH 15/21] Update TestUtils.js --- src/TestUtils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TestUtils.js b/src/TestUtils.js index af423e6e78..01c3850f2c 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -18,8 +18,7 @@ export function destroyAllDataPermanently(fast) { } if (app.databaseController) { deletePromises.push(app.databaseController.deleteEverything(fast)); - } - if (app.databaseAdapter) { + } else if (app.databaseAdapter) { SchemaCache.clear(); deletePromises.push(app.databaseAdapter.deleteAllClasses(fast)); } From 619c56ac7499fa1ddd01cd5ed11fd0c1f1d5e530 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 15:11:54 +1100 Subject: [PATCH 16/21] log batch --- spec/helper.js | 2 +- src/ParseServerRESTController.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/helper.js b/spec/helper.js index 8e3aaaec39..1a811d7d1c 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -82,7 +82,7 @@ on_db( ); let logLevel; -let silent = false; +let silent = true; if (process.env.VERBOSE) { silent = false; logLevel = 'verbose'; diff --git a/src/ParseServerRESTController.js b/src/ParseServerRESTController.js index 12ee0a67e5..78ecbe4423 100644 --- a/src/ParseServerRESTController.js +++ b/src/ParseServerRESTController.js @@ -47,6 +47,7 @@ function ParseServerRESTController(applicationId, router) { } if (path === '/batch') { + console.log({ path }); const batch = transactionRetries => { let initialPromise = Promise.resolve(); if (data.transaction === true) { @@ -87,6 +88,7 @@ function ParseServerRESTController(applicationId, router) { } }) .catch(error => { + console.log({ error }); if ( error && error.find( @@ -94,6 +96,7 @@ function ParseServerRESTController(applicationId, router) { ) && transactionRetries > 0 ) { + console.log(transactionRetries - 1); return batch(transactionRetries - 1); } throw error; From cf18b2b60493e38ad404e363d031388bd8a3cbd9 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 15:47:34 +1100 Subject: [PATCH 17/21] wip --- spec/Idempotency.spec.js | 4 ---- spec/helper.js | 2 +- src/ParseServerRESTController.js | 3 +++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/Idempotency.spec.js b/spec/Idempotency.spec.js index a45d19343c..813923b1ff 100644 --- a/spec/Idempotency.spec.js +++ b/spec/Idempotency.spec.js @@ -45,10 +45,6 @@ describe('Idempotency', () => { }); }); - afterAll(() => { - jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; - }); - // Tests it('should enforce idempotency for cloud code function', async () => { let counter = 0; diff --git a/spec/helper.js b/spec/helper.js index 1a811d7d1c..93bac9f56b 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -11,7 +11,6 @@ if (dns.setDefaultResultOrder) { } // Sets up a Parse API server for testing. -jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; jasmine.getEnv().addReporter(new CurrentSpecReporter()); jasmine.getEnv().addReporter(new SpecReporter()); @@ -196,6 +195,7 @@ beforeAll(async () => { Parse.initialize('test', 'test', 'test'); Parse.serverURL = 'http://localhost:' + port + '/1'; + jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; }); afterEach(function (done) { diff --git a/src/ParseServerRESTController.js b/src/ParseServerRESTController.js index 78ecbe4423..45f3e00708 100644 --- a/src/ParseServerRESTController.js +++ b/src/ParseServerRESTController.js @@ -53,6 +53,7 @@ function ParseServerRESTController(applicationId, router) { if (data.transaction === true) { initialPromise = config.database.createTransactionalSession(); } + console.log('inital promise'); return initialPromise.then(() => { const promises = data.requests.map(request => { return handleRequest(request.method, request.path, request.body, options, config).then( @@ -71,8 +72,10 @@ function ParseServerRESTController(applicationId, router) { } ); }); + console.log('promises', promises); return Promise.all(promises) .then(result => { + console.log('result', result); if (data.transaction === true) { if (result.find(resultItem => typeof resultItem.error === 'object')) { return config.database.abortTransactionalSession().then(() => { From 06791d3902050f13716212d2a626ae1b63501059 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 16:08:38 +1100 Subject: [PATCH 18/21] wip --- spec/helper.js | 2 +- src/ParseServerRESTController.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/spec/helper.js b/spec/helper.js index 93bac9f56b..c4824fb63f 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -195,10 +195,10 @@ beforeAll(async () => { Parse.initialize('test', 'test', 'test'); Parse.serverURL = 'http://localhost:' + port + '/1'; - jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; }); afterEach(function (done) { + jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; const afterLogOut = async () => { if (Object.keys(openConnections).length > 0) { console.warn('There were open connections to the server left after the test finished'); diff --git a/src/ParseServerRESTController.js b/src/ParseServerRESTController.js index 45f3e00708..7e4168274a 100644 --- a/src/ParseServerRESTController.js +++ b/src/ParseServerRESTController.js @@ -53,7 +53,6 @@ function ParseServerRESTController(applicationId, router) { if (data.transaction === true) { initialPromise = config.database.createTransactionalSession(); } - console.log('inital promise'); return initialPromise.then(() => { const promises = data.requests.map(request => { return handleRequest(request.method, request.path, request.body, options, config).then( @@ -72,10 +71,8 @@ function ParseServerRESTController(applicationId, router) { } ); }); - console.log('promises', promises); return Promise.all(promises) .then(result => { - console.log('result', result); if (data.transaction === true) { if (result.find(resultItem => typeof resultItem.error === 'object')) { return config.database.abortTransactionalSession().then(() => { @@ -91,7 +88,6 @@ function ParseServerRESTController(applicationId, router) { } }) .catch(error => { - console.log({ error }); if ( error && error.find( From 9b41c08e51b19478fd247421eebb6a02526a8549 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 16:12:58 +1100 Subject: [PATCH 19/21] Update helper.js --- spec/helper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/helper.js b/spec/helper.js index c4824fb63f..6d67612510 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -11,6 +11,7 @@ if (dns.setDefaultResultOrder) { } // Sets up a Parse API server for testing. +jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; jasmine.getEnv().addReporter(new CurrentSpecReporter()); jasmine.getEnv().addReporter(new SpecReporter()); From 265bfcd5306d05fa04f50cab7b23078bcdb7d129 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 16:25:10 +1100 Subject: [PATCH 20/21] remove logs --- spec/helper.js | 5 ++++- src/ParseServerRESTController.js | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/helper.js b/spec/helper.js index 6d67612510..445de26509 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -198,8 +198,11 @@ beforeAll(async () => { Parse.serverURL = 'http://localhost:' + port + '/1'; }); -afterEach(function (done) { +beforeEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 10000; +}); + +afterEach(function (done) { const afterLogOut = async () => { if (Object.keys(openConnections).length > 0) { console.warn('There were open connections to the server left after the test finished'); diff --git a/src/ParseServerRESTController.js b/src/ParseServerRESTController.js index 7e4168274a..12ee0a67e5 100644 --- a/src/ParseServerRESTController.js +++ b/src/ParseServerRESTController.js @@ -47,7 +47,6 @@ function ParseServerRESTController(applicationId, router) { } if (path === '/batch') { - console.log({ path }); const batch = transactionRetries => { let initialPromise = Promise.resolve(); if (data.transaction === true) { @@ -95,7 +94,6 @@ function ParseServerRESTController(applicationId, router) { ) && transactionRetries > 0 ) { - console.log(transactionRetries - 1); return batch(transactionRetries - 1); } throw error; From 89d687166e75d5cbc9a597b1cc99964a07970905 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 8 Mar 2023 16:25:43 +1100 Subject: [PATCH 21/21] Update TestUtils.js --- src/TestUtils.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/TestUtils.js b/src/TestUtils.js index 01c3850f2c..3d5133556d 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -22,11 +22,7 @@ export function destroyAllDataPermanently(fast) { SchemaCache.clear(); deletePromises.push(app.databaseAdapter.deleteAllClasses(fast)); } - try { - return Promise.all(deletePromises); - } catch (e) { - /* ignore */ - } + return Promise.all(deletePromises); }) ); }