Commit 09eb1731 authored by JC Brand's avatar JC Brand

Add code to generate and publish our bundle and update the test

updates #497
parent 6042c233
...@@ -15,7 +15,25 @@ ...@@ -15,7 +15,25 @@
}); });
}, },
'generateRegistrationId': function () { 'generateRegistrationId': function () {
return 1234; return '31415';
},
'generatePreKey': function (keyid) {
return Promise.resolve({
'keyId': keyid,
'keyPair': {
'pubKey': 1234,
'privKey': 4321
}
});
},
'generateSignedPreKey': function (identity_keypair, keyid) {
return Promise.resolve({
'keyId': keyid,
'keyPair': {
'pubKey': 1234,
'privKey': 4321
}
});
} }
} }
}; };
...@@ -35,15 +53,14 @@ ...@@ -35,15 +53,14 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
let devicelist_iq, let iq_stanza;
disco_info_iq;
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
const contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; const contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
return _.filter(_converse.connection.IQ_stanzas, function (iq) { return _.filter(_converse.connection.IQ_stanzas, function (iq) {
const node = iq.nodeTree.querySelector('iq[to="dummy@localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); const node = iq.nodeTree.querySelector('iq[to="dummy@localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
if (node) { disco_info_iq = iq; } if (node) { iq_stanza = iq.nodeTree; }
return node; return node;
}).length > 0; }).length > 0;
}, 1000).then(function () { }, 1000).then(function () {
...@@ -52,32 +69,57 @@ ...@@ -52,32 +69,57 @@
'type': 'result', 'type': 'result',
'from': 'dummy@localhost', 'from': 'dummy@localhost',
'to': 'dummy@localhost/resource', 'to': 'dummy@localhost/resource',
'id': disco_info_iq.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info'}) }).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info'})
.c('identity', { .c('identity', {
'category': 'pubsub', 'category': 'pubsub',
'type': 'pep'}); 'type': 'pep'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
return test_utils.waitUntil(() => {
return _.filter(_converse.connection.IQ_stanzas, function (iq) {
const node = iq.nodeTree.querySelector('publish[node="eu.siacs.conversations.axolotl.bundles:31415"]');
if (node) { iq_stanza = iq.nodeTree; }
return node;
}).length;
});
}).then(function () {
expect(iq_stanza.getAttributeNames().sort().join()).toBe(["from", "type", "xmlns", "id"].sort().join());
expect(iq_stanza.querySelector('prekeys').childNodes.length).toBe(100);
const signed_prekeys = iq_stanza.querySelectorAll('signedPreKeyPublic');
expect(signed_prekeys.length).toBe(1);
const signed_prekey = signed_prekeys[0];
expect(signed_prekey.getAttribute('signedPreKeyId')).toBe('0')
expect(iq_stanza.querySelectorAll('signedPreKeySignature').length).toBe(1);
expect(iq_stanza.querySelectorAll('identityKey').length).toBe(1);
const stanza = $iq({
'from': _converse.bare_jid,
'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid,
'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza));
return test_utils.waitUntil(() => { return test_utils.waitUntil(() => {
return _.filter( return _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
(iq) => { (iq) => {
const node = iq.nodeTree.querySelector('iq[to="'+_converse.bare_jid+'"] query[node="eu.siacs.conversations.axolotl.devicelist"]'); const node = iq.nodeTree.querySelector('iq[to="'+_converse.bare_jid+'"] query[node="eu.siacs.conversations.axolotl.devicelist"]');
if (node) { if (node) { iq_stanza = iq.nodeTree;}
devicelist_iq = iq;
}
return node; return node;
}).length; }).length;
}); });
}).then(function () { }).then(function () {
expect(devicelist_iq.toLocaleString()).toBe( expect(iq_stanza.outerHTML).toBe(
"<iq type='get' from='dummy@localhost' to='dummy@localhost' xmlns='jabber:client' id='"+devicelist_iq.nodeTree.getAttribute('id')+"'>"+ '<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="'+iq_stanza.getAttribute("id")+'">'+
"<query xmlns='http://jabber.org/protocol/disco#items' "+ '<query xmlns="http://jabber.org/protocol/disco#items" '+
"node='eu.siacs.conversations.axolotl.devicelist'/>"+ 'node="eu.siacs.conversations.axolotl.devicelist"/>'+
"</iq>"); '</iq>');
const stanza = $iq({ const stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': devicelist_iq.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('query', { }).c('query', {
...@@ -97,20 +139,18 @@ ...@@ -97,20 +139,18 @@
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
(iq) => { (iq) => {
const node = iq.nodeTree.querySelector('iq[to="'+contact_jid+'"] query[node="eu.siacs.conversations.axolotl.devicelist"]'); const node = iq.nodeTree.querySelector('iq[to="'+contact_jid+'"] query[node="eu.siacs.conversations.axolotl.devicelist"]');
if (node) { if (node) { iq_stanza = iq.nodeTree; }
devicelist_iq = iq;
}
return node; return node;
}).length;}); }).length;});
}).then(function () { }).then(function () {
expect(devicelist_iq.toLocaleString()).toBe( expect(iq_stanza.outerHTML).toBe(
"<iq type='get' from='dummy@localhost' to='"+contact_jid+"' xmlns='jabber:client' id='"+devicelist_iq.nodeTree.getAttribute('id')+"'>"+ '<iq type="get" from="dummy@localhost" to="'+contact_jid+'" xmlns="jabber:client" id="'+iq_stanza.getAttribute("id")+'">'+
"<query xmlns='http://jabber.org/protocol/disco#items' "+ '<query xmlns="http://jabber.org/protocol/disco#items" '+
"node='eu.siacs.conversations.axolotl.devicelist'/>"+ 'node="eu.siacs.conversations.axolotl.devicelist"/>'+
"</iq>"); '</iq>');
const stanza = $iq({ const stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': devicelist_iq.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('query', { }).c('query', {
...@@ -139,7 +179,7 @@ ...@@ -139,7 +179,7 @@
toolbar.querySelector('.toggle-omemo').click(); toolbar.querySelector('.toggle-omemo').click();
expect(view.toggleOMEMO).toHaveBeenCalled(); expect(view.toggleOMEMO).toHaveBeenCalled();
done(); done();
}); }).catch(_.partial(console.error, _));
})); }));
}); });
......
...@@ -387,6 +387,7 @@ ...@@ -387,6 +387,7 @@
this.addSpoilerButton(options); this.addSpoilerButton(options);
this.addFileUploadButton(); this.addFileUploadButton();
this.insertEmojiPicker(); this.insertEmojiPicker();
_converse.emit('renderToolbar', this);
return this; return this;
}, },
......
This diff is collapsed.
...@@ -823,14 +823,11 @@ ...@@ -823,14 +823,11 @@
return text.replace(_converse.geouri_regex, replacement); return text.replace(_converse.geouri_regex, replacement);
}; };
u.getSelectValues = function(select) { u.getSelectValues = function (select) {
var result = []; const result = [];
var options = select && select.options; const options = select && select.options;
var opt;
for (var i=0, iLen=options.length; i<iLen; i++) { for (var i=0, iLen=options.length; i<iLen; i++) {
opt = options[i]; const opt = options[i];
if (opt.selected) { if (opt.selected) {
result.push(opt.value || opt.text); result.push(opt.value || opt.text);
} }
...@@ -838,5 +835,10 @@ ...@@ -838,5 +835,10 @@
return result; return result;
}; };
u.arrayBuffer2Base64 = function (ab) {
return new window.Uint8Array(ab)
.reduce((data, byte) => data + String.fromCharCode(byte), '')
};
return u; return u;
})); }));
...@@ -47,6 +47,7 @@ var specs = [ ...@@ -47,6 +47,7 @@ var specs = [
"spec/ping", "spec/ping",
"spec/xmppstatus", "spec/xmppstatus",
"spec/mam", "spec/mam",
"spec/omemo",
"spec/controlbox", "spec/controlbox",
"spec/roster", "spec/roster",
"spec/chatbox", "spec/chatbox",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment