Skip to content

Commit

Permalink
Merge branch 'alpha' into fix/parse-community#2098
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Apr 1, 2024
2 parents e0c322a + ab237a2 commit fe3a1bc
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 9 deletions.
8 changes: 8 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# [5.1.0-alpha.1](https://github.com/parse-community/Parse-SDK-JS/compare/5.0.0...5.1.0-alpha.1) (2024-03-31)


### Features

* Add password validation for user with unverified email via `Parse.User.verifyPassword` using master key and option `ignoreEmailVerification: true` ([#2076](https://github.com/parse-community/Parse-SDK-JS/issues/2076)) ([b0adf7e](https://github.com/parse-community/Parse-SDK-JS/commit/b0adf7e02ab0beea2cd9b759d0f788c69d291491))
* Add support for setting `Parse.ACL` from json ([#2097](https://github.com/parse-community/Parse-SDK-JS/issues/2097)) ([72bc9ac](https://github.com/parse-community/Parse-SDK-JS/commit/72bc9ac3bfb23443a03742fe47a3b1b2713f8c96))

# [5.0.0-alpha.4](https://github.com/parse-community/Parse-SDK-JS/compare/5.0.0-alpha.3...5.0.0-alpha.4) (2024-03-23)


Expand Down
14 changes: 14 additions & 0 deletions integration/test/ParseACLTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ describe('Parse.ACL', () => {
assert(o);
});

it('can set ACL from json', async () => {
Parse.User.enableUnsafeCurrentUser();
const user = new Parse.User();
const object = new TestObject();
user.set('username', 'torn');
user.set('password', 'acl');
await user.signUp();
const acl = new Parse.ACL(user);
object.setACL(acl);
const json = object.toJSON();
await object.save(json);
assert.equal(acl.equals(object.getACL()), true);
});

it('disables public get access', async () => {
const user = new Parse.User();
const object = new TestObject();
Expand Down
43 changes: 43 additions & 0 deletions integration/test/ParseEventuallyQueueTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,49 @@ describe('Parse EventuallyQueue', () => {
assert.strictEqual(results.length, 1);
});

it('can saveEventually on object with ACL', async () => {
Parse.User.enableUnsafeCurrentUser();
const parseServer = await reconfigureServer();
const user = new Parse.User();
user.set('username', 'torn');
user.set('password', 'acl');
await user.signUp();

const acl = new Parse.ACL(user);
const object = new TestObject({ hash: 'saveSecret' });
object.setACL(acl);

await new Promise((resolve) => parseServer.server.close(resolve));

await object.saveEventually();

let length = await Parse.EventuallyQueue.length();
assert(Parse.EventuallyQueue.isPolling());
assert.strictEqual(length, 1);

await reconfigureServer({});

while (Parse.EventuallyQueue.isPolling()) {
await sleep(100);
}
assert.strictEqual(Parse.EventuallyQueue.isPolling(), false);

length = await Parse.EventuallyQueue.length();
while (length) {
await sleep(100);
}
length = await Parse.EventuallyQueue.length();
assert.strictEqual(length, 0);

const query = new Parse.Query('TestObject');
query.equalTo('hash', 'saveSecret');
let results = await query.find();
while (results.length === 0) {
results = await query.find();
}
assert.strictEqual(results.length, 1);
});

it('can destroyEventually', async () => {
const parseServer = await reconfigureServer();
const object = new TestObject({ hash: 'deleteSecret' });
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse",
"version": "5.0.0-alpha.4",
"version": "5.1.0-alpha.1",
"description": "Parse JavaScript SDK",
"homepage": "https://parseplatform.org",
"keywords": [
Expand Down
14 changes: 8 additions & 6 deletions src/ParseObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,15 +1308,17 @@ class ParseObject {
options = arg3;
}

options = options || {};
if (attrs) {
const validation = this.validate(attrs);
if (validation) {
return Promise.reject(validation);
let validationError;
options.error = (_, validation) => {
validationError = validation;
};
const success = this.set(attrs, options);
if (!success) {
return Promise.reject(validationError);
}
this.set(attrs, options);
}

options = options || {};
const saveOptions = {};
if (options.hasOwnProperty('useMasterKey')) {
saveOptions.useMasterKey = !!options.useMasterKey;
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/ParseObject-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ describe('ParseObject', () => {
expect(o.getACL()).toEqual(ACL);
});

it('encodes ACL from json', () => {
const ACL = new ParseACL({ user1: { read: true } });
const o = new ParseObject('Item');
o.set({ ACL: ACL.toJSON() });
expect(o.getACL()).toEqual(ACL);
});

it('can be rendered to JSON', () => {
let o = new ParseObject('Item');
o.set({
Expand Down

0 comments on commit fe3a1bc

Please sign in to comment.