Throw error when push is missing configuration (#2035)
This commit is contained in:
@@ -144,4 +144,24 @@ describe('Parse.Push', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ describe('PushController', () => {
|
|||||||
isMaster: true
|
isMaster: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushController = new PushController(pushAdapter, Parse.applicationId);
|
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
|
||||||
Parse.Object.saveAll(installations).then((installations) => {
|
Parse.Object.saveAll(installations).then((installations) => {
|
||||||
return pushController.sendPush(payload, {}, config, auth);
|
return pushController.sendPush(payload, {}, config, auth);
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
@@ -226,7 +226,7 @@ describe('PushController', () => {
|
|||||||
isMaster: true
|
isMaster: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushController = new PushController(pushAdapter, Parse.applicationId);
|
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
|
||||||
Parse.Object.saveAll(installations).then((installations) => {
|
Parse.Object.saveAll(installations).then((installations) => {
|
||||||
return pushController.sendPush(payload, {}, config, auth);
|
return pushController.sendPush(payload, {}, config, auth);
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
@@ -277,7 +277,7 @@ describe('PushController', () => {
|
|||||||
isMaster: true
|
isMaster: true
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushController = new PushController(pushAdapter, Parse.applicationId);
|
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
|
||||||
Parse.Object.saveAll(installations).then(() => {
|
Parse.Object.saveAll(installations).then(() => {
|
||||||
return pushController.sendPush(payload, {}, config, auth);
|
return pushController.sendPush(payload, {}, config, auth);
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
@@ -342,7 +342,7 @@ describe('PushController', () => {
|
|||||||
var auth = {
|
var auth = {
|
||||||
isMaster: true
|
isMaster: true
|
||||||
}
|
}
|
||||||
var pushController = new PushController(pushAdapter, Parse.applicationId);
|
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
|
||||||
pushController.sendPush(payload, where, config, auth).then(() => {
|
pushController.sendPush(payload, where, config, auth).then(() => {
|
||||||
fail('should not succeed');
|
fail('should not succeed');
|
||||||
done();
|
done();
|
||||||
@@ -388,7 +388,7 @@ describe('PushController', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var pushController = new PushController(pushAdapter, Parse.applicationId);
|
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
|
||||||
pushController.sendPush(payload, where, config, auth).then((result) => {
|
pushController.sendPush(payload, where, config, auth).then((result) => {
|
||||||
done();
|
done();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ export class PushController extends AdaptableController {
|
|||||||
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');
|
||||||
}
|
}
|
||||||
|
if (!this.options) {
|
||||||
|
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
||||||
|
'Missing push configuration');
|
||||||
|
}
|
||||||
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);
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class ParseServer {
|
|||||||
return new GridStoreAdapter(databaseURI);
|
return new GridStoreAdapter(databaseURI);
|
||||||
});
|
});
|
||||||
// Pass the push options too as it works with the default
|
// Pass the push options too as it works with the default
|
||||||
const pushControllerAdapter = loadAdapter(push && push.adapter, ParsePushAdapter, push);
|
const pushControllerAdapter = loadAdapter(push && push.adapter, ParsePushAdapter, push || {});
|
||||||
const loggerControllerAdapter = loadAdapter(loggerAdapter, FileLoggerAdapter);
|
const loggerControllerAdapter = loadAdapter(loggerAdapter, FileLoggerAdapter);
|
||||||
const emailControllerAdapter = loadAdapter(emailAdapter);
|
const emailControllerAdapter = loadAdapter(emailAdapter);
|
||||||
const cacheControllerAdapter = loadAdapter(cacheAdapter, InMemoryCacheAdapter, {appId: appId});
|
const cacheControllerAdapter = loadAdapter(cacheAdapter, InMemoryCacheAdapter, {appId: appId});
|
||||||
@@ -185,7 +185,7 @@ class ParseServer {
|
|||||||
// We pass the options and the base class for the adatper,
|
// We pass the options and the base class for the adatper,
|
||||||
// Note that passing an instance would work too
|
// Note that passing an instance would work too
|
||||||
const filesController = new FilesController(filesControllerAdapter, appId);
|
const filesController = new FilesController(filesControllerAdapter, appId);
|
||||||
const pushController = new PushController(pushControllerAdapter, appId);
|
const pushController = new PushController(pushControllerAdapter, appId, push);
|
||||||
const loggerController = new LoggerController(loggerControllerAdapter, appId);
|
const loggerController = new LoggerController(loggerControllerAdapter, appId);
|
||||||
const userController = new UserController(emailControllerAdapter, appId, { verifyUserEmails });
|
const userController = new UserController(emailControllerAdapter, appId, { verifyUserEmails });
|
||||||
const liveQueryController = new LiveQueryController(liveQuery);
|
const liveQueryController = new LiveQueryController(liveQuery);
|
||||||
|
|||||||
Reference in New Issue
Block a user