Merge branch 'master' into flovilmart.dynamicConfigMount
This commit is contained in:
@@ -2209,4 +2209,41 @@ describe('Parse.Query testing', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('query with two OR subqueries (regression test #1259)', done => {
|
||||
let relatedObject = new Parse.Object('Class2');
|
||||
relatedObject.save().then(relatedObject => {
|
||||
let anObject = new Parse.Object('Class1');
|
||||
let relation = anObject.relation('relation');
|
||||
relation.add(relatedObject);
|
||||
return anObject.save();
|
||||
}).then(anObject => {
|
||||
let q1 = anObject.relation('relation').query();
|
||||
q1.doesNotExist('nonExistantKey1');
|
||||
let q2 = anObject.relation('relation').query();
|
||||
q2.doesNotExist('nonExistantKey2');
|
||||
let orQuery = Parse.Query.or(q1, q2).find().then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
expect(results[0].objectId).toEqual(q1.objectId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('objectId containedIn with multiple large array', done => {
|
||||
let obj = new Parse.Object('MyClass');
|
||||
obj.save().then(obj => {
|
||||
let longListOfStrings = [];
|
||||
for (let i = 0; i < 130; i++) {
|
||||
longListOfStrings.push(i.toString());
|
||||
}
|
||||
longListOfStrings.push(obj.id);
|
||||
let q = new Parse.Query('MyClass');
|
||||
q.containedIn('objectId', longListOfStrings);
|
||||
q.containedIn('objectId', longListOfStrings);
|
||||
return q.find();
|
||||
}).then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -248,46 +248,50 @@ describe('Parse.Relation testing', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("queries on relation fields with multiple ins", (done) => {
|
||||
var ChildObject = Parse.Object.extend("ChildObject");
|
||||
var childObjects = [];
|
||||
for (var i = 0; i < 10; i++) {
|
||||
it("queries on relation fields with multiple containedIn (regression test for #1271)", (done) => {
|
||||
let ChildObject = Parse.Object.extend("ChildObject");
|
||||
let childObjects = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
childObjects.push(new ChildObject({x: i}));
|
||||
}
|
||||
|
||||
Parse.Object.saveAll(childObjects).then(() => {
|
||||
var ParentObject = Parse.Object.extend("ParentObject");
|
||||
var parent = new ParentObject();
|
||||
let ParentObject = Parse.Object.extend("ParentObject");
|
||||
let parent = new ParentObject();
|
||||
parent.set("x", 4);
|
||||
var relation = parent.relation("child");
|
||||
relation.add(childObjects[0]);
|
||||
relation.add(childObjects[1]);
|
||||
relation.add(childObjects[2]);
|
||||
var parent2 = new ParentObject();
|
||||
let parent1Children = parent.relation("child");
|
||||
parent1Children.add(childObjects[0]);
|
||||
parent1Children.add(childObjects[1]);
|
||||
parent1Children.add(childObjects[2]);
|
||||
let parent2 = new ParentObject();
|
||||
parent2.set("x", 3);
|
||||
var relation2 = parent2.relation("child");
|
||||
relation2.add(childObjects[4]);
|
||||
relation2.add(childObjects[5]);
|
||||
relation2.add(childObjects[6]);
|
||||
let parent2Children = parent2.relation("child");
|
||||
parent2Children.add(childObjects[4]);
|
||||
parent2Children.add(childObjects[5]);
|
||||
parent2Children.add(childObjects[6]);
|
||||
|
||||
var otherChild2 = parent2.relation("otherChild");
|
||||
otherChild2.add(childObjects[0]);
|
||||
otherChild2.add(childObjects[1]);
|
||||
otherChild2.add(childObjects[2]);
|
||||
let parent2OtherChildren = parent2.relation("otherChild");
|
||||
parent2OtherChildren.add(childObjects[0]);
|
||||
parent2OtherChildren.add(childObjects[1]);
|
||||
parent2OtherChildren.add(childObjects[2]);
|
||||
|
||||
var parents = [];
|
||||
parents.push(parent);
|
||||
parents.push(parent2);
|
||||
return Parse.Object.saveAll(parents);
|
||||
return Parse.Object.saveAll([parent, parent2]);
|
||||
}).then(() => {
|
||||
var query = new Parse.Query(ParentObject);
|
||||
var objects = [];
|
||||
objects.push(childObjects[0]);
|
||||
query.containedIn("child", objects);
|
||||
query.containedIn("otherChild", [childObjects[0]]);
|
||||
return query.find();
|
||||
}).then((list) => {
|
||||
equal(list.length, 2, "There should be 2 results");
|
||||
let objectsWithChild0InBothChildren = new Parse.Query(ParentObject);
|
||||
objectsWithChild0InBothChildren.containedIn("child", [childObjects[0]]);
|
||||
objectsWithChild0InBothChildren.containedIn("otherChild", [childObjects[0]]);
|
||||
return objectsWithChild0InBothChildren.find();
|
||||
}).then(objectsWithChild0InBothChildren => {
|
||||
//No parent has child 0 in both it's "child" and "otherChild" field;
|
||||
expect(objectsWithChild0InBothChildren.length).toEqual(0);
|
||||
}).then(() => {
|
||||
let objectsWithChild4andOtherChild1 = new Parse.Query(ParentObject);
|
||||
objectsWithChild4andOtherChild1.containedIn("child", [childObjects[4]]);
|
||||
objectsWithChild4andOtherChild1.containedIn("otherChild", [childObjects[1]]);
|
||||
return objectsWithChild4andOtherChild1.find();
|
||||
}).then(objects => {
|
||||
// parent2 has child 4 and otherChild 1
|
||||
expect(objects.length).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -981,7 +981,7 @@ describe('schemas', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should not be able to add a field', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1010,7 +1010,7 @@ describe('schemas', () => {
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should not be able to add a field', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1038,7 +1038,7 @@ describe('schemas', () => {
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid userId (>10 chars)', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1056,7 +1056,7 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid userId (<10 chars)', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1074,7 +1074,7 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid userId (invalid char)', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1092,7 +1092,7 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid * (spaces)', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1110,7 +1110,7 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid * (spaces)', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1128,7 +1128,7 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid value', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1146,7 +1146,7 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should throw with invalid value', done => {
|
||||
request.post({
|
||||
url: 'http://localhost:8378/1/schemas/AClass',
|
||||
@@ -1164,10 +1164,10 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
function setPermissionsOnClass(className, permissions, doPut) {
|
||||
let op = request.post;
|
||||
if (doPut)
|
||||
if (doPut)
|
||||
{
|
||||
op = request.put;
|
||||
}
|
||||
@@ -1190,18 +1190,18 @@ describe('schemas', () => {
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
it('validate CLP 1', done => {
|
||||
let user = new Parse.User();
|
||||
user.setUsername('user');
|
||||
user.setPassword('user');
|
||||
|
||||
|
||||
let admin = new Parse.User();
|
||||
admin.setUsername('admin');
|
||||
admin.setPassword('admin');
|
||||
|
||||
|
||||
let role = new Parse.Role('admin', new Parse.ACL());
|
||||
|
||||
|
||||
setPermissionsOnClass('AClass', {
|
||||
'find': {
|
||||
'role:admin': true
|
||||
@@ -1239,18 +1239,18 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('validate CLP 2', done => {
|
||||
let user = new Parse.User();
|
||||
user.setUsername('user');
|
||||
user.setPassword('user');
|
||||
|
||||
|
||||
let admin = new Parse.User();
|
||||
admin.setUsername('admin');
|
||||
admin.setPassword('admin');
|
||||
|
||||
|
||||
let role = new Parse.Role('admin', new Parse.ACL());
|
||||
|
||||
|
||||
setPermissionsOnClass('AClass', {
|
||||
'find': {
|
||||
'role:admin': true
|
||||
@@ -1304,18 +1304,18 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('validate CLP 3', done => {
|
||||
let user = new Parse.User();
|
||||
user.setUsername('user');
|
||||
user.setPassword('user');
|
||||
|
||||
|
||||
let admin = new Parse.User();
|
||||
admin.setUsername('admin');
|
||||
admin.setPassword('admin');
|
||||
|
||||
|
||||
let role = new Parse.Role('admin', new Parse.ACL());
|
||||
|
||||
|
||||
setPermissionsOnClass('AClass', {
|
||||
'find': {
|
||||
'role:admin': true
|
||||
@@ -1362,18 +1362,18 @@ describe('schemas', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('validate CLP 4', done => {
|
||||
let user = new Parse.User();
|
||||
user.setUsername('user');
|
||||
user.setPassword('user');
|
||||
|
||||
|
||||
let admin = new Parse.User();
|
||||
admin.setUsername('admin');
|
||||
admin.setPassword('admin');
|
||||
|
||||
|
||||
let role = new Parse.Role('admin', new Parse.ACL());
|
||||
|
||||
|
||||
setPermissionsOnClass('AClass', {
|
||||
'find': {
|
||||
'role:admin': true
|
||||
@@ -1400,7 +1400,7 @@ describe('schemas', () => {
|
||||
// borked CLP should not affec security
|
||||
return setPermissionsOnClass('AClass', {
|
||||
'found': {
|
||||
'role:admin': true
|
||||
'role:admin': true
|
||||
}
|
||||
}, true).then(() => {
|
||||
fail("Should not be able to save a borked CLP");
|
||||
@@ -1430,21 +1430,21 @@ describe('schemas', () => {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('validate CLP 5', done => {
|
||||
let user = new Parse.User();
|
||||
user.setUsername('user');
|
||||
user.setPassword('user');
|
||||
|
||||
|
||||
let user2 = new Parse.User();
|
||||
user2.setUsername('user2');
|
||||
user2.setPassword('user2');
|
||||
let admin = new Parse.User();
|
||||
admin.setUsername('admin');
|
||||
admin.setPassword('admin');
|
||||
|
||||
|
||||
let role = new Parse.Role('admin', new Parse.ACL());
|
||||
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
return Parse.Object.saveAll([user, user2, admin, role], {useMasterKey: true});
|
||||
}).then(()=> {
|
||||
@@ -1495,5 +1495,21 @@ describe('schemas', () => {
|
||||
}).then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('can add field as master (issue #1257)', (done) => {
|
||||
setPermissionsOnClass('AClass', {
|
||||
'addField': {}
|
||||
}).then(() => {
|
||||
var obj = new Parse.Object('AClass');
|
||||
obj.set('key', 'value');
|
||||
return obj.save(null, {useMasterKey: true})
|
||||
}).then((obj) => {
|
||||
expect(obj.get('key')).toEqual('value');
|
||||
done();
|
||||
}, (err) => {
|
||||
fail('should not fail');
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user