OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 | 6 |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
9 QUnit.module('XmppErrorCache'); | 9 QUnit.module('XmppErrorCache'); |
10 | 10 |
11 /** | 11 /** |
12 * @param {string} stanza | 12 * @param {string} stanza |
13 * @param {string} expected | 13 * @param {string} expected |
14 * @param {QUnit.Assert} assert | 14 * @param {QUnit.Assert} assert |
15 */ | 15 */ |
16 function runStanzaTest(stanza, expected, assert) { | 16 function runStanzaTest(stanza, expected, assert) { |
17 var monitor = new remoting.XmppErrorCache(); | 17 var monitor = new remoting.XmppErrorCache(); |
18 var parser = new DOMParser(); | 18 var parser = new DOMParser(); |
19 var xml = parser.parseFromString(stanza, 'text/xml'); | 19 var xml = parser.parseFromString(stanza, 'text/xml'); |
20 monitor.processStanza(xml.firstElementChild); | 20 monitor.processStanza(xml.firstElementChild); |
21 var error = monitor.getFirstError(); | 21 var errorStanza = monitor.getFirstErrorStanza(); |
22 assert.equal(error.raw_stanza, expected); | 22 assert.equal(errorStanza, expected); |
23 } | 23 } |
24 | 24 |
25 QUnit.test('should strip PII from session-initiate.', function(assert) { | 25 QUnit.test('should strip PII from session-initiate.', function(assert) { |
26 var input = | 26 var input = |
27 '<iq xmlns="jabber:client" to="foo@google.com/chromotingE5A" ' + | 27 '<iq xmlns="jabber:client" to="foo@google.com/chromotingE5A" ' + |
28 'type="error" id="12747556118995360108" ' + | 28 'type="error" id="12747556118995360108" ' + |
29 'from="123@chromoting.gserviceaccount.com/chromoting21B21C01">' + | 29 'from="123@chromoting.gserviceaccount.com/chromoting21B21C01">' + |
30 '<jingle xmlns="urn:xmpp:jingle:1" sid="3953621430175055977" ' + | 30 '<jingle xmlns="urn:xmpp:jingle:1" sid="3953621430175055977" ' + |
31 'action="session-initiate" ' + | 31 'action="session-initiate" ' + |
32 'initiator="foo@google.com/chromotingE5A">' + | 32 'initiator="foo@google.com/chromotingE5A">' + |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 '</content>' + | 86 '</content>' + |
87 '</jingle>' + | 87 '</jingle>' + |
88 '<error code="503" type="cancel">' + | 88 '<error code="503" type="cancel">' + |
89 '<service-unavailable xmlns="urn:ietf:xml:ns:xmpp-stanzas"/>' + | 89 '<service-unavailable xmlns="urn:ietf:xml:ns:xmpp-stanzas"/>' + |
90 '</error>' + | 90 '</error>' + |
91 '</iq>'; | 91 '</iq>'; |
92 runStanzaTest(input, expected, assert); | 92 runStanzaTest(input, expected, assert); |
93 }); | 93 }); |
94 | 94 |
95 })(); | 95 })(); |
OLD | NEW |