Allow cert/key data to be shared by push/feedback
This commit is contained in:
parent
0557237fa7
commit
95ad3e8c04
|
@ -7,25 +7,28 @@ var AuthenticationSchemeSchema = {
|
|||
credential: Object // Scheme-specific credentials
|
||||
};
|
||||
|
||||
// See https://github.com/argon/node-apn/blob/master/doc/apn.markdown
|
||||
var APNSSettingSchema = {
|
||||
production: Boolean, // production or development mode
|
||||
certData: String, // The certificate data
|
||||
keyData: String, // The key data
|
||||
|
||||
pushOptions: {type: {
|
||||
gateway: String,
|
||||
cert: String,
|
||||
key: String
|
||||
gateway: {type: String, default: 'gateway.sandbox.push.apple.com'},
|
||||
port: {type: Number, default: 2195}
|
||||
}},
|
||||
|
||||
feedbackOptions: {type: {
|
||||
gateway: String,
|
||||
cert: String,
|
||||
key: String,
|
||||
gateway: {type: String, default: 'feedback.sandbox.push.apple.com'},
|
||||
port: {type: Number, default: 2196},
|
||||
batchFeedback: Boolean,
|
||||
interval: Number
|
||||
}}
|
||||
};
|
||||
|
||||
var GcmSettingsSchema = {
|
||||
serverApiKey: String
|
||||
}
|
||||
serverApiKey: String
|
||||
};
|
||||
|
||||
// Push notification settings
|
||||
var PushNotificationSettingSchema = {
|
||||
|
|
|
@ -6,7 +6,8 @@ describe('Application', function () {
|
|||
var registeredApp = null;
|
||||
|
||||
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;
|
||||
assert.equal(app.owner, 'rfeng');
|
||||
assert.equal(app.name, 'MyApp1');
|
||||
|
@ -22,8 +23,57 @@ describe('Application', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Create a new application', function (done) {
|
||||
Application.create({owner: 'rfeng', name: 'MyAppWithPush',
|
||||
description: 'My push mobile application',
|
||||
pushSettings: {
|
||||
apns: {
|
||||
production: false,
|
||||
certData: 'cert',
|
||||
keyData: 'key',
|
||||
pushOptions: {
|
||||
},
|
||||
feedbackOptions: {
|
||||
interval: 300,
|
||||
batchFeedback: true
|
||||
}
|
||||
},
|
||||
gcm: {
|
||||
serverApiKey: 'serverKey'
|
||||
}
|
||||
}},
|
||||
function (err, result) {
|
||||
var app = result;
|
||||
assert.equal(app.owner, 'rfeng');
|
||||
assert.equal(app.name, 'MyAppWithPush');
|
||||
assert.equal(app.description, 'My push mobile application');
|
||||
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) {
|
||||
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;
|
||||
assert.equal(app.owner, 'rfeng');
|
||||
assert.equal(app.name, 'MyApp2');
|
||||
|
@ -66,28 +116,32 @@ describe('Application', function () {
|
|||
});
|
||||
|
||||
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');
|
||||
done(err, result);
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
done(err, result);
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
done(err, result);
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
done(err, result);
|
||||
});
|
||||
|
@ -95,14 +149,16 @@ describe('Application', function () {
|
|||
|
||||
|
||||
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');
|
||||
done(err, result);
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
done(err, result);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue