mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1225968 - Adding more messages to the push message tests, r=kitcambridge
--HG-- extra : commitid : DKvDzgHBTd7 extra : rebase_source : 953a864bb23b9b24d14957e49490fdcf1ed36818
This commit is contained in:
parent
0b2ee432a6
commit
0a36983413
@ -4,6 +4,7 @@
|
||||
'use strict';
|
||||
|
||||
const {PushDB, PushService, PushServiceWebSocket} = serviceExports;
|
||||
const {base64UrlDecode} = Cu.import('resource://gre/modules/PushCrypto.jsm', {});
|
||||
|
||||
let db;
|
||||
let userAgentID = 'f5b47f8d-771f-4ea3-b999-91c135f8766d';
|
||||
@ -16,7 +17,7 @@ function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
function putRecord(channelID, scope, publicKey, privateKey) {
|
||||
function putRecord(channelID, scope, publicKey, privateKey, authSecret) {
|
||||
return db.put({
|
||||
channelID: channelID,
|
||||
pushEndpoint: 'https://example.org/push/' + channelID,
|
||||
@ -25,8 +26,9 @@ function putRecord(channelID, scope, publicKey, privateKey) {
|
||||
lastPush: 0,
|
||||
originAttributes: '',
|
||||
quota: Infinity,
|
||||
p256dhPublicKey: publicKey,
|
||||
p256dhPublicKey: base64UrlDecode(publicKey),
|
||||
p256dhPrivateKey: privateKey,
|
||||
authenticationSecret: base64UrlDecode(authSecret),
|
||||
});
|
||||
}
|
||||
|
||||
@ -48,7 +50,8 @@ add_task(function* test_notification_ack_data_setup() {
|
||||
kty: "EC",
|
||||
x: '8J3iA1CSPBFqHrUul0At3NkosudTlQDAPO1Dn-HRCxM',
|
||||
y: '26jk0IFbqcK6-JxhHAm-rsHEwy0CyVJjtnfOcqc1tgA'
|
||||
}
|
||||
},
|
||||
'c_sGN6uCv9Hu7JOQT34jAQ'
|
||||
);
|
||||
yield putRecord(
|
||||
'subscription2',
|
||||
@ -62,7 +65,8 @@ add_task(function* test_notification_ack_data_setup() {
|
||||
kty: 'EC',
|
||||
x: '-dbJSjvIye4yXIq0RG4t9YTxrT1212MdJbaWkL38GpE',
|
||||
y: '5TZ1rK8Ldih6ljyxVwnBA-nygQHGRpEmu1jV5K8437E'
|
||||
}
|
||||
},
|
||||
't3P246Gj9vjKDHHRYaY6hw'
|
||||
);
|
||||
yield putRecord(
|
||||
'subscription3',
|
||||
@ -76,7 +80,8 @@ add_task(function* test_notification_ack_data_setup() {
|
||||
kty: 'EC',
|
||||
x: 'OFQchNJ5WtZjJsWdvvKVVMIMMs91BYyl_yBeFxbC9po',
|
||||
y: 'Ja6n3YH8TOcH8narDF6t8mKVvg2ioLW-8MH5O4dzGcI'
|
||||
}
|
||||
},
|
||||
'E0qiXGWvFSR0PS352ES1_Q'
|
||||
);
|
||||
|
||||
let setupDone;
|
||||
@ -159,27 +164,74 @@ add_task(function* test_notification_ack_data() {
|
||||
scope: 'https://example.com/page/3',
|
||||
data: 'Some message'
|
||||
}
|
||||
},
|
||||
// This message uses the newer, authenticated form based on the crypto-key
|
||||
// header field. No padding or record size changes.
|
||||
{
|
||||
channelID: 'subscription1',
|
||||
version: 'v4',
|
||||
send: {
|
||||
headers: {
|
||||
crypto_key: 'keyid=v4;dh="BHqG01j7rOfp12BEDzxWXxlCaU4cdOx2DZAwCt3QuzEsnXN9lCna9QmZCkVpXsx7sAlaEmtl_VfF1lHlFS7XWcA"',
|
||||
encryption: 'keyid="v4";salt="X5-iy5rzhm4naNmMHdSYJw"',
|
||||
},
|
||||
data: '7YlxyNlZsNX4UNknHxzTqFrcrzz58W95uXBa0iY',
|
||||
},
|
||||
receive: {
|
||||
scope: 'https://example.com/page/1',
|
||||
data: 'Some message'
|
||||
}
|
||||
},
|
||||
// A message with 17 bytes of padding and rs of 24
|
||||
{
|
||||
channelID: 'subscription2',
|
||||
version: 'v5',
|
||||
send: {
|
||||
headers: {
|
||||
crypto_key: 'keyid="v5"; dh="BJhyKIH5P30YUKn1bolj_LMnael1-KZT_aGXgD2CRspBfv9gcUhVAmpxToZrw7QQEKl9K83b3zcqNY6G_dFhEsI"',
|
||||
encryption: 'keyid=v5;salt="bLmqCy550eK1Ao41tD7orA";rs=24',
|
||||
},
|
||||
data: 'SQDlDg1ftLkM_ruZlmyB2bk9L78HYtkcbA-y4-uAxwL-G4KtOA-J-A_rJ007Vi6NUkQe9K4kSZeIBrIUpmGv',
|
||||
},
|
||||
receive: {
|
||||
scope: 'https://example.com/page/2',
|
||||
data: 'Some message'
|
||||
}
|
||||
},
|
||||
// A message without key identifiers.
|
||||
{
|
||||
channelID: 'subscription3',
|
||||
version: 'v6',
|
||||
send: {
|
||||
headers: {
|
||||
crypto_key: 'dh="BEgnDmVw9Gcn1fWA5t53Jtpsgfewk_pzsjSc_PBPpPmROWGQA2v8ESrSsQgosNXx0o-uMMhi9tDAUeks3380kd8"',
|
||||
encryption: 'salt=T9DM8bNxuMHRVTn4LzkJDQ',
|
||||
},
|
||||
data: '7KUCi0dBBJbWmsYTqEqhFrgTv4ZOo_BmQRQ_2kY',
|
||||
},
|
||||
receive: {
|
||||
scope: 'https://example.com/page/3',
|
||||
data: 'Some message'
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
let sendAndReceive = testData => {
|
||||
let messageReceived = promiseObserverNotification('push-notification', (subject, data) => {
|
||||
dump("push-notification\n");
|
||||
let notification = subject.QueryInterface(Ci.nsIPushObserverNotification);
|
||||
equal(notification.data, testData.receive.data,
|
||||
'Wrong data for notification ' + testData.version);
|
||||
'Check data for notification ' + testData.version);
|
||||
equal(data, testData.receive.scope,
|
||||
'Wrong scope for notification ' + testData.version);
|
||||
'Check scope for notification ' + testData.version);
|
||||
return true;
|
||||
});
|
||||
|
||||
let ackReceived = new Promise(resolve => ackDone = resolve)
|
||||
.then(ackData => {
|
||||
dump("push-ack\n");
|
||||
deepEqual([{
|
||||
channelID: testData.channelID,
|
||||
version: testData.version
|
||||
}], ackData, 'Wrong updates for acknowledgment ' + testData.version);
|
||||
}], ackData, 'Check updates for acknowledgment ' + testData.version);
|
||||
});
|
||||
|
||||
let msg = JSON.parse(JSON.stringify(testData.send));
|
||||
|
Loading…
Reference in New Issue
Block a user