Merge pull request #105 from strongloop/feature/push-settings
Allow cert/key data to be shared by push/feedback
This commit is contained in:
commit
3652c1584a
|
@ -7,17 +7,30 @@ var AuthenticationSchemeSchema = {
|
||||||
credential: Object // Scheme-specific credentials
|
credential: Object // Scheme-specific credentials
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// See https://github.com/argon/node-apn/blob/master/doc/apn.markdown
|
||||||
var APNSSettingSchema = {
|
var APNSSettingSchema = {
|
||||||
|
/**
|
||||||
|
* production or development mode. It denotes what default APNS servers to be
|
||||||
|
* used to send notifications
|
||||||
|
* - true (production mode)
|
||||||
|
* - push: gateway.push.apple.com:2195
|
||||||
|
* - feedback: feedback.push.apple.com:2196
|
||||||
|
* - false (development mode, the default)
|
||||||
|
* - push: gateway.sandbox.push.apple.com:2195
|
||||||
|
* - feedback: feedback.sandbox.push.apple.com:2196
|
||||||
|
*/
|
||||||
|
production: Boolean,
|
||||||
|
certData: String, // The certificate data loaded from the cert.pem file
|
||||||
|
keyData: String, // The key data loaded from the key.pem file
|
||||||
|
|
||||||
pushOptions: {type: {
|
pushOptions: {type: {
|
||||||
gateway: String,
|
gateway: String,
|
||||||
cert: String,
|
port: Number
|
||||||
key: String
|
|
||||||
}},
|
}},
|
||||||
|
|
||||||
feedbackOptions: {type: {
|
feedbackOptions: {type: {
|
||||||
gateway: String,
|
gateway: String,
|
||||||
cert: String,
|
port: Number,
|
||||||
key: String,
|
|
||||||
batchFeedback: Boolean,
|
batchFeedback: Boolean,
|
||||||
interval: Number
|
interval: Number
|
||||||
}}
|
}}
|
||||||
|
@ -25,7 +38,7 @@ var APNSSettingSchema = {
|
||||||
|
|
||||||
var GcmSettingsSchema = {
|
var GcmSettingsSchema = {
|
||||||
serverApiKey: String
|
serverApiKey: String
|
||||||
}
|
};
|
||||||
|
|
||||||
// Push notification settings
|
// Push notification settings
|
||||||
var PushNotificationSettingSchema = {
|
var PushNotificationSettingSchema = {
|
||||||
|
@ -77,7 +90,6 @@ var ApplicationSchema = {
|
||||||
modified: {type: Date, default: Date}
|
modified: {type: Date, default: Date}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application management functions
|
* Application management functions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,9 @@ describe('Application', function () {
|
||||||
var registeredApp = null;
|
var registeredApp = null;
|
||||||
|
|
||||||
it('Create a new application', function (done) {
|
it('Create a new application', function (done) {
|
||||||
Application.create({owner: 'rfeng', name: 'MyApp1', description: 'My first mobile application'}, function (err, result) {
|
Application.create({owner: 'rfeng',
|
||||||
|
name: 'MyApp1',
|
||||||
|
description: 'My first mobile application'}, function (err, result) {
|
||||||
var app = result;
|
var app = result;
|
||||||
assert.equal(app.owner, 'rfeng');
|
assert.equal(app.owner, 'rfeng');
|
||||||
assert.equal(app.name, 'MyApp1');
|
assert.equal(app.name, 'MyApp1');
|
||||||
|
@ -22,8 +24,59 @@ describe('Application', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Create a new application with push settings', function (done) {
|
||||||
|
Application.create({owner: 'rfeng',
|
||||||
|
name: 'MyAppWithPush',
|
||||||
|
description: 'My push mobile application',
|
||||||
|
pushSettings: {
|
||||||
|
apns: {
|
||||||
|
production: false,
|
||||||
|
certData: 'cert',
|
||||||
|
keyData: 'key',
|
||||||
|
pushOptions: {
|
||||||
|
gateway: 'gateway.sandbox.push.apple.com',
|
||||||
|
port: 2195
|
||||||
|
},
|
||||||
|
feedbackOptions: {
|
||||||
|
gateway: 'feedback.sandbox.push.apple.com',
|
||||||
|
port: 2196,
|
||||||
|
interval: 300,
|
||||||
|
batchFeedback: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
gcm: {
|
||||||
|
serverApiKey: 'serverKey'
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
function (err, result) {
|
||||||
|
var app = result;
|
||||||
|
assert.deepEqual(app.pushSettings.toObject(), {
|
||||||
|
apns: {
|
||||||
|
production: false,
|
||||||
|
certData: 'cert',
|
||||||
|
keyData: 'key',
|
||||||
|
pushOptions: {
|
||||||
|
gateway: 'gateway.sandbox.push.apple.com',
|
||||||
|
port: 2195
|
||||||
|
},
|
||||||
|
feedbackOptions: {
|
||||||
|
gateway: 'feedback.sandbox.push.apple.com',
|
||||||
|
port: 2196,
|
||||||
|
interval: 300,
|
||||||
|
batchFeedback: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
gcm: {
|
||||||
|
serverApiKey: 'serverKey'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done(err, result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
Application.register('rfeng', 'MyApp2', {description: 'My second mobile application'}, function (err, result) {
|
Application.register('rfeng', 'MyApp2',
|
||||||
|
{description: 'My second mobile application'}, function (err, result) {
|
||||||
var app = result;
|
var app = result;
|
||||||
assert.equal(app.owner, 'rfeng');
|
assert.equal(app.owner, 'rfeng');
|
||||||
assert.equal(app.name, 'MyApp2');
|
assert.equal(app.name, 'MyApp2');
|
||||||
|
@ -66,43 +119,48 @@ describe('Application', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Authenticate with application id & clientKey', function (done) {
|
it('Authenticate with application id & clientKey', function (done) {
|
||||||
Application.authenticate(registeredApp.id, registeredApp.clientKey, function (err, result) {
|
Application.authenticate(registeredApp.id, registeredApp.clientKey,
|
||||||
|
function (err, result) {
|
||||||
assert.equal(result, 'clientKey');
|
assert.equal(result, 'clientKey');
|
||||||
done(err, result);
|
done(err, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Authenticate with application id & javaScriptKey', function (done) {
|
it('Authenticate with application id & javaScriptKey', function (done) {
|
||||||
Application.authenticate(registeredApp.id, registeredApp.javaScriptKey, function (err, result) {
|
Application.authenticate(registeredApp.id, registeredApp.javaScriptKey,
|
||||||
|
function (err, result) {
|
||||||
assert.equal(result, 'javaScriptKey');
|
assert.equal(result, 'javaScriptKey');
|
||||||
done(err, result);
|
done(err, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Authenticate with application id & restApiKey', function (done) {
|
it('Authenticate with application id & restApiKey', function (done) {
|
||||||
Application.authenticate(registeredApp.id, registeredApp.restApiKey, function (err, result) {
|
Application.authenticate(registeredApp.id, registeredApp.restApiKey,
|
||||||
|
function (err, result) {
|
||||||
assert.equal(result, 'restApiKey');
|
assert.equal(result, 'restApiKey');
|
||||||
done(err, result);
|
done(err, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Authenticate with application id & masterKey', function (done) {
|
it('Authenticate with application id & masterKey', function (done) {
|
||||||
Application.authenticate(registeredApp.id, registeredApp.masterKey, function (err, result) {
|
Application.authenticate(registeredApp.id, registeredApp.masterKey,
|
||||||
|
function (err, result) {
|
||||||
assert.equal(result, 'masterKey');
|
assert.equal(result, 'masterKey');
|
||||||
done(err, result);
|
done(err, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Authenticate with application id & windowsKey', function (done) {
|
it('Authenticate with application id & windowsKey', function (done) {
|
||||||
Application.authenticate(registeredApp.id, registeredApp.windowsKey, function (err, result) {
|
Application.authenticate(registeredApp.id, registeredApp.windowsKey,
|
||||||
|
function (err, result) {
|
||||||
assert.equal(result, 'windowsKey');
|
assert.equal(result, 'windowsKey');
|
||||||
done(err, result);
|
done(err, result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Fail to authenticate with application id & invalid key', function (done) {
|
it('Fail to authenticate with application id & invalid key', function (done) {
|
||||||
Application.authenticate(registeredApp.id, 'invalid-key', function (err, result) {
|
Application.authenticate(registeredApp.id, 'invalid-key',
|
||||||
|
function (err, result) {
|
||||||
assert(!result);
|
assert(!result);
|
||||||
done(err, result);
|
done(err, result);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue