Remove useless masterKey validation in PushController.sendPush.
This commit is contained in:
@@ -3,31 +3,6 @@ var PushController = require('../src/Controllers/PushController').PushController
|
|||||||
var Config = require('../src/Config');
|
var Config = require('../src/Config');
|
||||||
|
|
||||||
describe('PushController', () => {
|
describe('PushController', () => {
|
||||||
it('can check valid master key of request', (done) => {
|
|
||||||
// Make mock request
|
|
||||||
var auth = {
|
|
||||||
isMaster: true
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
PushController.validateMasterKey(auth);
|
|
||||||
}).not.toThrow();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can check invalid master key of request', (done) => {
|
|
||||||
// Make mock request
|
|
||||||
var auth = {
|
|
||||||
isMaster: false
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
PushController.validateMasterKey(auth);
|
|
||||||
}).toThrow();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('can validate device type when no device type is set', (done) => {
|
it('can validate device type when no device type is set', (done) => {
|
||||||
// Make query condition
|
// Make query condition
|
||||||
var where = {
|
var where = {
|
||||||
|
|||||||
@@ -37,24 +37,12 @@ export class PushController extends AdaptableController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether the api call has master key or not.
|
|
||||||
* @param {Object} request A request object
|
|
||||||
*/
|
|
||||||
static validateMasterKey(auth = {}) {
|
|
||||||
if (!auth.isMaster) {
|
|
||||||
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
|
||||||
'Master key is invalid, you should only use master key to send push');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendPush(body = {}, where = {}, config, auth) {
|
sendPush(body = {}, where = {}, config, auth) {
|
||||||
var pushAdapter = this.adapter;
|
var pushAdapter = this.adapter;
|
||||||
if (!pushAdapter) {
|
if (!pushAdapter) {
|
||||||
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
||||||
'Push adapter is not available');
|
'Push adapter is not available');
|
||||||
}
|
}
|
||||||
PushController.validateMasterKey(auth);
|
|
||||||
PushController.validatePushType(where, pushAdapter.getValidPushTypes());
|
PushController.validatePushType(where, pushAdapter.getValidPushTypes());
|
||||||
// Replace the expiration_time with a valid Unix epoch milliseconds time
|
// Replace the expiration_time with a valid Unix epoch milliseconds time
|
||||||
body['expiration_time'] = PushController.getExpirationTime(body);
|
body['expiration_time'] = PushController.getExpirationTime(body);
|
||||||
@@ -140,6 +128,6 @@ export class PushController extends AdaptableController {
|
|||||||
expectedAdapterType() {
|
expectedAdapterType() {
|
||||||
return PushAdapter;
|
return PushAdapter;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default PushController;
|
export default PushController;
|
||||||
|
|||||||
Reference in New Issue
Block a user