diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 0a8c147592..39aed06206 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -24,31 +24,14 @@ const headers = { }; describe_only_db('mongo')('miscellaneous', () => { - it('test rest_create_app', function (done) { - let appId; - Parse._request('POST', 'rest_create_app') - .then(res => { - expect(typeof res.application_id).toEqual('string'); - expect(res.master_key).toEqual('master'); - appId = res.application_id; - Parse.initialize(appId, 'unused'); - const obj = new Parse.Object('TestObject'); - obj.set('foo', 'bar'); - return obj.save(); - }) - .then(() => { - const config = Config.get(appId); - return config.database.adapter.find('TestObject', { fields: {} }, {}, {}); - }) - .then(results => { - expect(results.length).toEqual(1); - expect(results[0]['foo']).toEqual('bar'); - done(); - }) - .catch(error => { - fail(JSON.stringify(error)); - done(); - }); + it('db contains document after successful save', async () => { + const obj = new Parse.Object('TestObject'); + obj.set('foo', 'bar'); + await obj.save(); + const config = Config.get(defaultConfiguration.appId); + const results = await config.database.adapter.find('TestObject', { fields: {} }, {}, {}); + expect(results.length).toEqual(1); + expect(results[0]['foo']).toEqual('bar'); }); }); diff --git a/spec/helper.js b/spec/helper.js index 5c90c76f02..ab9294e493 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -143,7 +143,6 @@ const reconfigureServer = changedConfiguration => { }); cache.clear(); parseServer = ParseServer.start(newConfiguration); - parseServer.app.use(require('./testing-routes').router); parseServer.expressApp.use('/1', err => { console.error(err); fail('should not call next'); diff --git a/spec/testing-routes.js b/spec/testing-routes.js deleted file mode 100644 index 4cf626bc66..0000000000 --- a/spec/testing-routes.js +++ /dev/null @@ -1,72 +0,0 @@ -// testing-routes.js -const AppCache = require('../lib/cache').default; -const middlewares = require('../lib/middlewares'); -const { ParseServer } = require('../lib/index'); -const { Parse } = require('parse/node'); - -const express = require('express'), - cryptoUtils = require('../lib/cryptoUtils'); - -const router = express.Router(); - -// creates a unique app in the cache, with a collection prefix -function createApp(req, res) { - const appId = cryptoUtils.randomHexString(32); - - ParseServer({ - databaseURI: 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase', - appId: appId, - masterKey: 'master', - serverURL: Parse.serverURL, - collectionPrefix: appId, - }); - const keys = { - application_id: appId, - client_key: 'unused', - windows_key: 'unused', - javascript_key: 'unused', - webhook_key: 'unused', - rest_api_key: 'unused', - master_key: 'master', - }; - res.status(200).send(keys); -} - -// deletes all collections that belong to the app -function clearApp(req, res) { - if (!req.auth.isMaster) { - return res.status(401).send({ error: 'unauthorized' }); - } - return req.config.database.deleteEverything().then(() => { - res.status(200).send({}); - }); -} - -// deletes all collections and drops the app from cache -function dropApp(req, res) { - if (!req.auth.isMaster) { - return res.status(401).send({ error: 'unauthorized' }); - } - return req.config.database.deleteEverything().then(() => { - AppCache.del(req.config.applicationId); - res.status(200).send({}); - }); -} - -// Lets just return a success response and see what happens. -function notImplementedYet(req, res) { - res.status(200).send({}); -} - -router.post('/rest_clear_app', middlewares.handleParseHeaders, clearApp); -router.post('/rest_block', middlewares.handleParseHeaders, notImplementedYet); -router.post('/rest_mock_v8_client', middlewares.handleParseHeaders, notImplementedYet); -router.post('/rest_unmock_v8_client', middlewares.handleParseHeaders, notImplementedYet); -router.post('/rest_verify_analytics', middlewares.handleParseHeaders, notImplementedYet); -router.post('/rest_create_app', createApp); -router.post('/rest_drop_app', middlewares.handleParseHeaders, dropApp); -router.post('/rest_configure_app', middlewares.handleParseHeaders, notImplementedYet); - -module.exports = { - router: router, -};