Files
kami-parse-server/src/testing-routes.js
Drew 7e868b2dcc Unique indexes (#1971)
* Add unique indexing

* Add unique indexing for username/email

* WIP

* Finish unique indexes

* Notes on how to upgrade to 2.3.0 safely

* index on unique-indexes: c454180 Revert "Log objects rather than JSON stringified objects (#1922)"

* reconfigure username/email tests

* Start dealing with test shittyness

* Remove tests for files that we are removing

* most tests passing

* fix failing test

* Make specific server config for tests async

* Fix more tests

* fix more tests

* Fix another test

* fix more tests

* Fix email validation

* move some stuff around

* Destroy server to ensure all connections are gone

* Fix broken cloud code

* Save callback to variable

* no need to delete non existant cloud

* undo

* Fix all tests where connections are left open after server closes.

* Fix issues caused by missing gridstore adapter

* Update guide for 2.3.0 and fix final tests

* use strict

* don't use features that won't work in node 4

* Fix syntax error

* Fix typos

* Add duplicate finding command

* Update 2.3.0.md
2016-06-10 20:27:21 -07:00

73 lines
2.3 KiB
JavaScript

// testing-routes.js
import AppCache from './cache';
import * as middlewares from './middlewares';
import { ParseServer } from './index';
import { Parse } from 'parse/node';
var express = require('express'),
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);
ParseServer({
databaseURI: 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase',
appId: appId,
masterKey: 'master',
serverURL: Parse.serverURL,
collectionPrefix: appId
});
var 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
};