Skip to content

Commit 737c3ff

Browse files
authored
Merge 4d3bf0f into 6323368
2 parents 6323368 + 4d3bf0f commit 737c3ff

File tree

8 files changed

+113
-12
lines changed

8 files changed

+113
-12
lines changed

spec/CLI.spec.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ describe('execution', () => {
219219
}
220220
});
221221

222-
it('shoud start Parse Server', done => {
222+
it('should start Parse Server', done => {
223223
childProcess = spawn(binPath, [
224224
'--appId',
225225
'test',
@@ -241,7 +241,16 @@ describe('execution', () => {
241241
});
242242
});
243243

244-
it('shoud start Parse Server with GraphQL', done => {
244+
it('should throw without masterKey and appId', done => {
245+
childProcess = spawn(binPath, []);
246+
childProcess.stderr.on('data', data => {
247+
if (data.toString().includes('ERROR: appId and masterKey are required')) {
248+
done();
249+
}
250+
});
251+
});
252+
253+
it('should start Parse Server with GraphQL', done => {
245254
childProcess = spawn(binPath, [
246255
'--appId',
247256
'test',
@@ -267,7 +276,7 @@ describe('execution', () => {
267276
});
268277
});
269278

270-
it('shoud start Parse Server with GraphQL and Playground', done => {
279+
it('should start Parse Server with GraphQL and Playground', done => {
271280
childProcess = spawn(binPath, [
272281
'--appId',
273282
'test',
@@ -294,4 +303,28 @@ describe('execution', () => {
294303
done.fail(data.toString());
295304
});
296305
});
306+
307+
it('should redact push keys', done => {
308+
childProcess = spawn(binPath, [
309+
'--appId',
310+
'test',
311+
'--masterKey',
312+
'test',
313+
'--databaseURI',
314+
'mongodb://localhost/test',
315+
'--port',
316+
'1341',
317+
'--push',
318+
'123',
319+
]);
320+
childProcess.stdout.on('data', data => {
321+
data = data.toString();
322+
if (data.includes('**REDACTED**')) {
323+
done();
324+
}
325+
});
326+
childProcess.stderr.on('data', data => {
327+
done.fail(data.toString());
328+
});
329+
});
297330
});

spec/CloudCode.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ const mockAdapter = {
1919
};
2020

2121
describe('Cloud Code', () => {
22+
it('can cannot load invalid cloud code', async () => {
23+
await expectAsync(
24+
reconfigureServer({
25+
cloud: true,
26+
})
27+
).toBeRejectedWith("argument 'cloud' must either be a string or a function");
28+
});
29+
2230
it('can load absolute cloud code file', done => {
2331
reconfigureServer({
2432
cloud: __dirname + '/cloud/cloudCodeRelativeFile.js',
@@ -39,6 +47,18 @@ describe('Cloud Code', () => {
3947
});
4048
});
4149

50+
it('can load cloud code as a function', async () => {
51+
await reconfigureServer({
52+
cloud: () => {
53+
Parse.Cloud.define('hellofunction', () => {
54+
return 'Hello world function!';
55+
});
56+
},
57+
});
58+
const result = await Parse.Cloud.run('hellofunction');
59+
expect(result).toBe('Hello world function!');
60+
});
61+
4262
it('can create functions', done => {
4363
Parse.Cloud.define('hello', () => {
4464
return 'Hello world!';

spec/MessageQueue.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const ParseMessageQueue = require('../lib/ParseMessageQueue').ParseMessageQueue;
2+
describe('message queue', () => {
3+
it('cannot create message quue with an invalid adapter', function () {
4+
expect(() =>
5+
ParseMessageQueue.createPublisher({
6+
messageQueueAdapter: {
7+
createPublisher: 'a',
8+
createSubscriber: () => {},
9+
},
10+
})
11+
).toThrow('pubSubAdapter should have createPublisher()');
12+
13+
expect(() =>
14+
ParseMessageQueue.createSubscriber({
15+
messageQueueAdapter: {
16+
createPublisher: () => {},
17+
createSubscriber: 'a',
18+
},
19+
})
20+
).toThrow('messageQueueAdapter should have createSubscriber()');
21+
});
22+
});

spec/PagesRouter.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ describe('Pages Router', () => {
9292
expect(response.status).toBe(403);
9393
}
9494
});
95+
96+
it('can create new page', () => {
97+
const page = new Page({ id: 'testId', defaultFile: './defaultFile' });
98+
page.id = 'newId';
99+
page.defaultFile = 'newDefaultFile';
100+
expect(page._id).toBe('newId');
101+
expect(page._defaultFile).toBe('newDefaultFile');
102+
});
95103
});
96104

97105
describe('AJAX requests', () => {

spec/ParseAPI.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,13 @@ describe('miscellaneous', function () {
18271827
}
18281828
);
18291829
});
1830+
it('test TestUtils', () => {
1831+
delete process.env.TESTING;
1832+
expect(() => TestUtils.destroyAllDataPermanently()).toThrow(
1833+
'Only supported in test environment'
1834+
);
1835+
process.env.TESTING = true;
1836+
});
18301837
});
18311838

18321839
describe_only_db('mongo')('legacy _acl', () => {

spec/ParsePubSub.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,25 @@ describe('ParsePubSub', function () {
9797
expect(EventEmitterPubSub.createPublisher).not.toHaveBeenCalled();
9898
});
9999

100+
it('cannot create publisher/sub with an invalid adapter', function () {
101+
expect(() =>
102+
ParsePubSub.createPublisher({
103+
pubSubAdapter: {
104+
createPublisher: 'a',
105+
createSubscriber: () => {},
106+
},
107+
})
108+
).toThrow('pubSubAdapter should have createPublisher()');
109+
expect(() =>
110+
ParsePubSub.createSubscriber({
111+
pubSubAdapter: {
112+
createPublisher: () => {},
113+
createSubscriber: 'a',
114+
},
115+
})
116+
).toThrow('pubSubAdapter should have createSubscriber()');
117+
});
118+
100119
it('can create publisher/sub with custom function adapter', function () {
101120
const adapter = {
102121
createPublisher: jasmine.createSpy('createPublisher'),

src/cli/parse-server.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ runner({
3939
console.error('');
4040
process.exit(1);
4141
}
42-
4342
if (options['liveQuery.classNames']) {
4443
options.liveQuery = options.liveQuery || {};
4544
options.liveQuery.classNames = options['liveQuery.classNames'];
@@ -55,7 +54,6 @@ runner({
5554
options.liveQuery.redisOptions = options['liveQuery.redisOptions'];
5655
delete options['liveQuery.redisOptions'];
5756
}
58-
5957
if (options.cluster) {
6058
const numCPUs = typeof options.cluster === 'number' ? options.cluster : os.cpus().length;
6159
if (cluster.isMaster) {

src/cli/utils/runner.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ function logStartupOptions(options) {
1010
value = '***REDACTED***';
1111
}
1212
if (typeof value === 'object') {
13-
try {
14-
value = JSON.stringify(value);
15-
} catch (e) {
16-
if (value && value.constructor && value.constructor.name) {
17-
value = value.constructor.name;
18-
}
19-
}
13+
value = JSON.stringify(value);
2014
}
2115
/* eslint-disable no-console */
2216
console.log(`${key}: ${value}`);

0 commit comments

Comments
 (0)