Skip to content

Commit 2fc8da0

Browse files
mtrezzadplewis
authored andcommitted
Add support to get parse config with master key (#907)
* added support for options in Parse.Config.get * added integration tests for parse config * Point parse-server to parse-community/parse-server@ac40bf6 * Fix docs
1 parent 074f651 commit 2fc8da0

File tree

3 files changed

+987
-940
lines changed

3 files changed

+987
-940
lines changed

integration/test/ParseConfigTest.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
const clear = require('./clear');
5+
const Parse = require('../../node');
6+
7+
function testConfig() {
8+
const data = {
9+
params: { internal: 'i', public: 'p' },
10+
masterKeyOnly: { internal: true },
11+
};
12+
return Parse.CoreManager.getRESTController().request(
13+
'PUT',
14+
'config',
15+
data,
16+
{ useMasterKey: true }
17+
);
18+
}
19+
20+
describe('Parse Config', () => {
21+
beforeEach((done) => {
22+
Parse.initialize('integration', null, 'notsosecret');
23+
Parse.CoreManager.set('SERVER_URL', 'http://localhost:1337/parse');
24+
Parse.Storage._clear();
25+
clear().then(() => {
26+
done();
27+
});
28+
});
29+
30+
it('can create a config', async () => {
31+
const config = await Parse.Config.save({
32+
str: 'hello',
33+
num: 42
34+
});
35+
assert.equal(config.get('str'), 'hello');
36+
assert.equal(config.get('num'), 42);
37+
});
38+
39+
it('can get a config', async () => {
40+
await Parse.Config.save({
41+
str: 'hello',
42+
num: 42
43+
});
44+
const config = await Parse.Config.get();
45+
assert.equal(config.get('str'), 'hello');
46+
assert.equal(config.get('num'), 42);
47+
});
48+
49+
it('can get internal config parameter with masterkey', async () => {
50+
await testConfig();
51+
52+
const config = await Parse.Config.get({ useMasterKey: true });
53+
assert.equal(config.get('internal'), 'i');
54+
assert.equal(config.get('public'), 'p');
55+
});
56+
57+
it('cannot get internal config parameter without masterkey', async () => {
58+
await testConfig();
59+
60+
const config = await Parse.Config.get();
61+
assert.equal(config.get('internal'), undefined);
62+
assert.equal(config.get('public'), 'p');
63+
});
64+
});

0 commit comments

Comments
 (0)