Skip to content

Commit 3a2fd82

Browse files
committed
Merge branch 'fixFlakyTest1' of github.com:back4app/parse-server into fixFlakyTest1
2 parents aef71fe + 5564753 commit 3a2fd82

File tree

10 files changed

+424
-217
lines changed

10 files changed

+424
-217
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
## Parse Server Changelog
2+
<!--
3+
Please make sure you add your feature at the bottom of the associated group.
4+
Groups should be ordered:
5+
- NEW (EXPERIMENTAL)
6+
- NEW
7+
- IMPROVE
8+
- FIX
9+
Thanks for contributing to Parse Server!
10+
-->
211

312
### master
413
[Full Changelog](https://github.com/parse-community/parse-server/compare/4.5.0...master)
514

615
__BREAKING CHANGES:__
716
- NEW: Added file upload restriction. File upload is now only allowed for authenticated users by default for improved security. To allow file upload also for Anonymous Users or Public, set the `fileUpload` parameter in the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html). [#7071](https://github.com/parse-community/parse-server/pull/7071). Thanks to [dblythy](https://github.com/dblythy), [Manuel Trezza](https://github.com/mtrezza).
817
___
9-
- IMPROVE: Retry transactions on MongoDB when it fails due to transient error [#7187](https://github.com/parse-community/parse-server/pull/7187). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo).
10-
- UPGRADE: Bump tests to use Mongo 4.4.4 [#7184](https://github.com/parse-community/parse-server/pull/7184). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo).
1118
- NEW (EXPERIMENTAL): Added new page router with placeholder rendering and localization of custom and feature pages such as password reset and email verification. **Caution, this is an experimental feature that may not be appropriate for production.** [#6891](https://github.com/parse-community/parse-server/issues/6891). Thanks to [Manuel Trezza](https://github.com/mtrezza).
1219
- NEW: Added convenience method `Parse.Cloud.sendEmail(...)` to send email via email adapter in Cloud Code. [#7089](https://github.com/parse-community/parse-server/pull/7089). Thanks to [dblythy](https://github.com/dblythy)
1320
- NEW: LiveQuery support for $and, $nor, $containedBy, $geoWithin, $geoIntersects queries [#7113](https://github.com/parse-community/parse-server/pull/7113). Thanks to [dplewis](https://github.com/dplewis)
1421
- NEW: Supporting patterns in LiveQuery server's config parameter `classNames` [#7131](https://github.com/parse-community/parse-server/pull/7131). Thanks to [Nes-si](https://github.com/Nes-si)
22+
- NEW: `requireAnyUserRoles` and `requireAllUserRoles` for Parse Cloud validator. [#7097](https://github.com/parse-community/parse-server/pull/7097). Thanks to [dblythy](https://github.com/dblythy)
23+
- IMPROVE: Retry transactions on MongoDB when it fails due to transient error [#7187](https://github.com/parse-community/parse-server/pull/7187). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo).
24+
- IMPROVE: Bump tests to use Mongo 4.4.4 [#7184](https://github.com/parse-community/parse-server/pull/7184). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo).
1525
- IMPROVE: Added new account lockout policy option `accountLockout.unlockOnPasswordReset` to automatically unlock account on password reset. [#7146](https://github.com/parse-community/parse-server/pull/7146). Thanks to [Manuel Trezza](https://github.com/mtrezza).
1626
- IMPROVE: Parse Server is from now on continuously tested against all recent MongoDB versions that have not reached their end-of-life support date. Added MongoDB compatibility table to Parse Server docs. [7161](https://github.com/parse-community/parse-server/pull/7161). Thanks to [Manuel Trezza](https://github.com/mtrezza).
1727
- IMPROVE: Parse Server is from now on continuously tested against all recent Node.js versions that have not reached their end-of-life support date. [7161](https://github.com/parse-community/parse-server/pull/7177). Thanks to [Manuel Trezza](https://github.com/mtrezza).

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ The full documentation for Parse Server is available in the [wiki](https://githu
4444
- [Getting Started](#getting-started)
4545
- [Running Parse Server](#running-parse-server)
4646
- [Compatibility](#compatibility)
47-
- [Node.js](#nodejs-support)
48-
- [MongoDB](#mongodb-support)
49-
- [PostgreSQL](#postgresql-support)
47+
- [Node.js](#nodejs)
48+
- [MongoDB](#mongodb)
49+
- [PostgreSQL](#postgresql)
5050
- [Locally](#locally)
5151
- [Docker Container](#docker-container)
5252
- [Saving an Object](#saving-an-object)

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"cors": "2.8.5",
3535
"deepcopy": "2.1.0",
3636
"express": "4.17.1",
37-
"follow-redirects": "1.13.1",
37+
"follow-redirects": "1.13.2",
3838
"graphql": "15.4.0",
3939
"graphql-list-fields": "2.0.2",
4040
"graphql-relay": "0.6.0",

spec/CloudCode.Validator.spec.js

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,150 @@ describe('cloud validator', () => {
878878
});
879879
});
880880

881+
it('basic validator requireAnyUserRoles', async function (done) {
882+
Parse.Cloud.define(
883+
'cloudFunction',
884+
() => {
885+
return true;
886+
},
887+
{
888+
requireUser: true,
889+
requireAnyUserRoles: ['Admin'],
890+
}
891+
);
892+
const user = await Parse.User.signUp('testuser', 'p@ssword');
893+
try {
894+
await Parse.Cloud.run('cloudFunction');
895+
fail('cloud validator should have failed.');
896+
} catch (e) {
897+
expect(e.message).toBe('Validation failed. User does not match the required roles.');
898+
}
899+
const roleACL = new Parse.ACL();
900+
roleACL.setPublicReadAccess(true);
901+
const role = new Parse.Role('Admin', roleACL);
902+
role.getUsers().add(user);
903+
await role.save({ useMasterKey: true });
904+
await Parse.Cloud.run('cloudFunction');
905+
done();
906+
});
907+
908+
it('basic validator requireAllUserRoles', async function (done) {
909+
Parse.Cloud.define(
910+
'cloudFunction',
911+
() => {
912+
return true;
913+
},
914+
{
915+
requireUser: true,
916+
requireAllUserRoles: ['Admin', 'Admin2'],
917+
}
918+
);
919+
const user = await Parse.User.signUp('testuser', 'p@ssword');
920+
try {
921+
await Parse.Cloud.run('cloudFunction');
922+
fail('cloud validator should have failed.');
923+
} catch (e) {
924+
expect(e.message).toBe('Validation failed. User does not match all the required roles.');
925+
}
926+
const roleACL = new Parse.ACL();
927+
roleACL.setPublicReadAccess(true);
928+
const role = new Parse.Role('Admin', roleACL);
929+
role.getUsers().add(user);
930+
931+
const role2 = new Parse.Role('Admin2', roleACL);
932+
role2.getUsers().add(user);
933+
await Promise.all([role.save({ useMasterKey: true }), role2.save({ useMasterKey: true })]);
934+
await Parse.Cloud.run('cloudFunction');
935+
done();
936+
});
937+
938+
it('allow requireAnyUserRoles to be a function', async function (done) {
939+
Parse.Cloud.define(
940+
'cloudFunction',
941+
() => {
942+
return true;
943+
},
944+
{
945+
requireUser: true,
946+
requireAnyUserRoles: () => {
947+
return ['Admin Func'];
948+
},
949+
}
950+
);
951+
const user = await Parse.User.signUp('testuser', 'p@ssword');
952+
try {
953+
await Parse.Cloud.run('cloudFunction');
954+
fail('cloud validator should have failed.');
955+
} catch (e) {
956+
expect(e.message).toBe('Validation failed. User does not match the required roles.');
957+
}
958+
const roleACL = new Parse.ACL();
959+
roleACL.setPublicReadAccess(true);
960+
const role = new Parse.Role('Admin Func', roleACL);
961+
role.getUsers().add(user);
962+
await role.save({ useMasterKey: true });
963+
await Parse.Cloud.run('cloudFunction');
964+
done();
965+
});
966+
967+
it('allow requireAllUserRoles to be a function', async function (done) {
968+
Parse.Cloud.define(
969+
'cloudFunction',
970+
() => {
971+
return true;
972+
},
973+
{
974+
requireUser: true,
975+
requireAllUserRoles: () => {
976+
return ['AdminA', 'AdminB'];
977+
},
978+
}
979+
);
980+
const user = await Parse.User.signUp('testuser', 'p@ssword');
981+
try {
982+
await Parse.Cloud.run('cloudFunction');
983+
fail('cloud validator should have failed.');
984+
} catch (e) {
985+
expect(e.message).toBe('Validation failed. User does not match all the required roles.');
986+
}
987+
const roleACL = new Parse.ACL();
988+
roleACL.setPublicReadAccess(true);
989+
const role = new Parse.Role('AdminA', roleACL);
990+
role.getUsers().add(user);
991+
992+
const role2 = new Parse.Role('AdminB', roleACL);
993+
role2.getUsers().add(user);
994+
await Promise.all([role.save({ useMasterKey: true }), role2.save({ useMasterKey: true })]);
995+
await Parse.Cloud.run('cloudFunction');
996+
done();
997+
});
998+
999+
it('basic requireAllUserRoles but no user', async function (done) {
1000+
Parse.Cloud.define(
1001+
'cloudFunction',
1002+
() => {
1003+
return true;
1004+
},
1005+
{
1006+
requireAllUserRoles: ['Admin'],
1007+
}
1008+
);
1009+
try {
1010+
await Parse.Cloud.run('cloudFunction');
1011+
fail('cloud validator should have failed.');
1012+
} catch (e) {
1013+
expect(e.message).toBe('Validation failed. Please login to continue.');
1014+
}
1015+
const user = await Parse.User.signUp('testuser', 'p@ssword');
1016+
const roleACL = new Parse.ACL();
1017+
roleACL.setPublicReadAccess(true);
1018+
const role = new Parse.Role('Admin', roleACL);
1019+
role.getUsers().add(user);
1020+
await role.save({ useMasterKey: true });
1021+
await Parse.Cloud.run('cloudFunction');
1022+
done();
1023+
});
1024+
8811025
it('basic beforeSave requireMaster', function (done) {
8821026
Parse.Cloud.beforeSave('BeforeSaveFail', () => {}, {
8831027
requireMaster: true,

spec/CloudCode.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,39 @@ describe('beforeSave hooks', () => {
17791779
const myObject = new MyObject();
17801780
myObject.save().then(() => done());
17811781
});
1782+
1783+
it('should respect custom object ids (#6733)', async () => {
1784+
Parse.Cloud.beforeSave('TestObject', req => {
1785+
expect(req.object.id).toEqual('test_6733');
1786+
});
1787+
1788+
await reconfigureServer({ allowCustomObjectId: true });
1789+
1790+
const req = request({
1791+
// Parse JS SDK does not currently support custom object ids (see #1097), so we do a REST request
1792+
method: 'POST',
1793+
url: 'http://localhost:8378/1/classes/TestObject',
1794+
headers: {
1795+
'X-Parse-Application-Id': 'test',
1796+
'X-Parse-REST-API-Key': 'rest',
1797+
},
1798+
body: {
1799+
objectId: 'test_6733',
1800+
foo: 'bar',
1801+
},
1802+
});
1803+
1804+
{
1805+
const res = await req;
1806+
expect(res.data.objectId).toEqual('test_6733');
1807+
}
1808+
1809+
const query = new Parse.Query('TestObject');
1810+
query.equalTo('objectId', 'test_6733');
1811+
const res = await query.find();
1812+
expect(res.length).toEqual(1);
1813+
expect(res[0].get('foo')).toEqual('bar');
1814+
});
17821815
});
17831816

17841817
describe('afterSave hooks', () => {

0 commit comments

Comments
 (0)