Merge pull request #1067 from ParsePlatform/nlutsenko.testing_routes
Unbreak and make specific testing routes work.
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
// testing-routes.js
|
||||
import cache from './cache';
|
||||
|
||||
import * as middlewares from './middlewares';
|
||||
import { ParseServer } from './index';
|
||||
import { Parse } from 'parse/node';
|
||||
var express = require('express'),
|
||||
middlewares = require('./middlewares'),
|
||||
cryptoUtils = require('./cryptoUtils');
|
||||
cryptoUtils = require('./cryptoUtils');
|
||||
|
||||
var router = express.Router();
|
||||
|
||||
// creates a unique app in the cache, with a collection prefix
|
||||
function createApp(req, res) {
|
||||
var appId = cryptoUtils.randomHexString(32);
|
||||
// TODO: (nlutsenko) This doesn't work and should die, since there are no controllers on this configuration.
|
||||
cache.apps.set(appId, {
|
||||
'collectionPrefix': appId + '_',
|
||||
'masterKey': 'master'
|
||||
|
||||
ParseServer({
|
||||
appId: appId,
|
||||
masterKey: 'master',
|
||||
serverURL: Parse.serverURL,
|
||||
collectionPrefix: appId
|
||||
});
|
||||
var keys = {
|
||||
'application_id': appId,
|
||||
'client_key': 'unused',
|
||||
'windows_key': 'unused',
|
||||
'client_key' : 'unused',
|
||||
'windows_key' : 'unused',
|
||||
'javascript_key': 'unused',
|
||||
'webhook_key': 'unused',
|
||||
'rest_api_key': 'unused',
|
||||
'master_key': 'master'
|
||||
'webhook_key' : 'unused',
|
||||
'rest_api_key' : 'unused',
|
||||
'master_key' : 'master'
|
||||
};
|
||||
res.status(200).send(keys);
|
||||
}
|
||||
@@ -30,7 +33,7 @@ function createApp(req, res) {
|
||||
// deletes all collections with the collectionPrefix of the app
|
||||
function clearApp(req, res) {
|
||||
if (!req.auth.isMaster) {
|
||||
return res.status(401).send({"error": "unauthorized"});
|
||||
return res.status(401).send({ "error": "unauthorized" });
|
||||
}
|
||||
return req.config.database.deleteEverything().then(() => {
|
||||
res.status(200).send({});
|
||||
@@ -40,7 +43,7 @@ function clearApp(req, res) {
|
||||
// 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 res.status(401).send({ "error": "unauthorized" });
|
||||
}
|
||||
return req.config.database.deleteEverything().then(() => {
|
||||
cache.apps.remove(req.config.applicationId);
|
||||
@@ -53,21 +56,14 @@ 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_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);
|
||||
router.post('/rest_drop_app', middlewares.handleParseHeaders, dropApp);
|
||||
router.post('/rest_configure_app', middlewares.handleParseHeaders, notImplementedYet);
|
||||
|
||||
module.exports = {
|
||||
router: router
|
||||
|
||||
Reference in New Issue
Block a user