* reload the right data More passing postgres tests Handle schema updates, and $in for non array columns remove authdata from user and implement ensureUniqueness Make some tests work, detect existing classes Throw proper error for unique index violation fix findOneAndUpdate Support more types support more type Support boolean, fix _rperm/_wperm, add TODO Support string types and also simplify tests Move operator flattening into Parse Server and out of mongo adapters Move authdata transform for create into Parse Server Move authdata transforms completely in to Parse Server Fix test setup inline addSchema Inject default schema to response from DB adapter * Mark tests that don't work in Postgres * Exclude one more test * Exclude some more failing tests * Exclude more tests
167 lines
4.4 KiB
JavaScript
167 lines
4.4 KiB
JavaScript
'use strict';
|
||
|
||
let request = require('request');
|
||
|
||
describe('Parse.Push', () => {
|
||
var setup = function() {
|
||
var pushAdapter = {
|
||
send: function(body, installations) {
|
||
var badge = body.data.badge;
|
||
let promises = installations.map((installation) => {
|
||
if (installation.deviceType == "ios") {
|
||
expect(installation.badge).toEqual(badge);
|
||
expect(installation.originalBadge+1).toEqual(installation.badge);
|
||
} else {
|
||
expect(installation.badge).toBeUndefined();
|
||
}
|
||
return Promise.resolve({
|
||
err: null,
|
||
deviceType: installation.deviceType,
|
||
result: true
|
||
})
|
||
});
|
||
return Promise.all(promises);
|
||
},
|
||
getValidPushTypes: function() {
|
||
return ["ios", "android"];
|
||
}
|
||
}
|
||
|
||
return reconfigureServer({
|
||
appId: Parse.applicationId,
|
||
masterKey: Parse.masterKey,
|
||
serverURL: Parse.serverURL,
|
||
push: {
|
||
adapter: pushAdapter
|
||
}
|
||
})
|
||
.then(() => {
|
||
var installations = [];
|
||
while(installations.length != 10) {
|
||
var installation = new Parse.Object("_Installation");
|
||
installation.set("installationId", "installation_"+installations.length);
|
||
installation.set("deviceToken","device_token_"+installations.length)
|
||
installation.set("badge", installations.length);
|
||
installation.set("originalBadge", installations.length);
|
||
installation.set("deviceType", "ios");
|
||
installations.push(installation);
|
||
}
|
||
return Parse.Object.saveAll(installations);
|
||
});
|
||
}
|
||
|
||
it_exclude_dbs(['postgres'])('should properly send push', (done) => {
|
||
return setup().then(() => {
|
||
return Parse.Push.send({
|
||
where: {
|
||
deviceType: 'ios'
|
||
},
|
||
data: {
|
||
badge: 'Increment',
|
||
alert: 'Hello world!'
|
||
}
|
||
}, {useMasterKey: true})
|
||
})
|
||
.then(() => {
|
||
done();
|
||
}, (err) => {
|
||
console.error();
|
||
fail('should not fail sending push')
|
||
done();
|
||
});
|
||
});
|
||
|
||
it_exclude_dbs(['postgres'])('should properly send push with lowercaseIncrement', (done) => {
|
||
return setup().then(() => {
|
||
return Parse.Push.send({
|
||
where: {
|
||
deviceType: 'ios'
|
||
},
|
||
data: {
|
||
badge: 'increment',
|
||
alert: 'Hello world!'
|
||
}
|
||
}, {useMasterKey: true})
|
||
}).then(() => {
|
||
done();
|
||
}, (err) => {
|
||
console.error();
|
||
fail('should not fail sending push')
|
||
done();
|
||
});
|
||
});
|
||
|
||
it_exclude_dbs(['postgres'])('should not allow clients to query _PushStatus', done => {
|
||
setup()
|
||
.then(() => Parse.Push.send({
|
||
where: {
|
||
deviceType: 'ios'
|
||
},
|
||
data: {
|
||
badge: 'increment',
|
||
alert: 'Hello world!'
|
||
}
|
||
}, {useMasterKey: true}))
|
||
.then(() => {
|
||
request.get({
|
||
url: 'http://localhost:8378/1/classes/_PushStatus',
|
||
json: true,
|
||
headers: {
|
||
'X-Parse-Application-Id': 'test',
|
||
},
|
||
}, (error, response, body) => {
|
||
expect(body.error).toEqual('unauthorized');
|
||
done();
|
||
});
|
||
});
|
||
});
|
||
|
||
it_exclude_dbs(['postgres'])('should allow master key to query _PushStatus', done => {
|
||
setup()
|
||
.then(() => Parse.Push.send({
|
||
where: {
|
||
deviceType: 'ios'
|
||
},
|
||
data: {
|
||
badge: 'increment',
|
||
alert: 'Hello world!'
|
||
}
|
||
}, {useMasterKey: true}))
|
||
.then(() => {
|
||
request.get({
|
||
url: 'http://localhost:8378/1/classes/_PushStatus',
|
||
json: true,
|
||
headers: {
|
||
'X-Parse-Application-Id': 'test',
|
||
'X-Parse-Master-Key': 'test',
|
||
},
|
||
}, (error, response, body) => {
|
||
expect(body.results.length).toEqual(1);
|
||
expect(body.results[0].query).toEqual('{"deviceType":"ios"}');
|
||
expect(body.results[0].payload).toEqual('{"badge":"increment","alert":"Hello world!"}');
|
||
done();
|
||
});
|
||
});
|
||
});
|
||
|
||
it_exclude_dbs(['postgres'])('should throw error if missing push configuration', done => {
|
||
reconfigureServer({push: null})
|
||
.then(() => {
|
||
return Parse.Push.send({
|
||
where: {
|
||
deviceType: 'ios'
|
||
},
|
||
data: {
|
||
badge: 'increment',
|
||
alert: 'Hello world!'
|
||
}
|
||
}, {useMasterKey: true})
|
||
}).then((response) => {
|
||
fail('should not succeed');
|
||
}, (err) => {
|
||
expect(err.code).toEqual(Parse.Error.PUSH_MISCONFIGURED);
|
||
done();
|
||
});
|
||
});
|
||
});
|