* chore(package): update jasmine to version 3.0.0 Closes #4547 * Fixes failing tests for jasmine 3.0 Starting 3.0, done(something) will fail * Update tests so they dont leverage var, but let and const With jasmine 3.0, the randomization engine was making the test fails because of the scope of `var` * Remove randomizer * Use same adapter for PG tests, drop table to ensure the tests dont side effect
73 lines
2.3 KiB
JavaScript
73 lines
2.3 KiB
JavaScript
// testing-routes.js
|
|
import AppCache from '../src/cache';
|
|
import * as middlewares from '../src/middlewares';
|
|
import { ParseServer } from '../src/index';
|
|
import { Parse } from 'parse/node';
|
|
|
|
const express = require('express'),
|
|
cryptoUtils = require('../src/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
|
|
};
|