Skip to content

WIP: Force javascriptKey to be set when cloud code is present #3070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict"
'use strict';
var request = require('request');
var parseServerPackage = require('../package.json');
var MockEmailAdapterWithOptions = require('./MockEmailAdapterWithOptions');
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('server', () => {

it('can create a parse-server v2', done => {
let objId;
let server
let server;
let parseServer = ParseServer.ParseServer(Object.assign({},
defaultConfiguration, {
appId: "anOtherTestApp",
Expand All @@ -233,7 +233,7 @@ describe('server', () => {
server.close(done);
})
.catch(error => {
fail(JSON.stringify(error))
fail(JSON.stringify(error));
if (server) {
server.close(done);
} else {
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('server', () => {
it('should throw when getting invalid mount', done => {
reconfigureServer({ publicServerURL: 'blabla:/some' })
.catch(error => {
expect(error).toEqual('publicServerURL should be a valid HTTPS URL starting with https://')
expect(error).toEqual('publicServerURL should be a valid HTTPS URL starting with https://');
done();
})
});
Expand Down Expand Up @@ -317,10 +317,18 @@ describe('server', () => {
expireInactiveSessions: false
}))
.then(done);
})
});

it('fails if you try to set revokeSessionOnPasswordReset to non-boolean', done => {
reconfigureServer({ revokeSessionOnPasswordReset: 'non-bool' })
.catch(done);
});

it('fails when there is cloud code with no javascriptKey', (done) => {
reconfigureServer({
cloud: () => {},
javascriptKey: undefined
})
.catch(done);
})
});
5 changes: 4 additions & 1 deletion src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,16 @@ class ParseServer {
}

if (cloud) {
if (!javascriptKey) {
throw 'javascriptKey must be set when using cloud code';
}
addParseCloud();
if (typeof cloud === 'function') {
cloud(Parse)
} else if (typeof cloud === 'string') {
require(path.resolve(process.cwd(), cloud));
} else {
throw "argument 'cloud' must either be a string or a function";
throw 'argument \'cloud\' must either be a string or a function';
}
}
}
Expand Down