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
3 // found in the LICENSE file.
9 QUnit.module('XmppErrorCache');
12 * @param {string} stanza
13 * @param {string} expected
14 * @param {QUnit.Assert} assert
16 function runStanzaTest(stanza, expected, assert) {
17 var monitor = new remoting.XmppErrorCache();
18 var parser = new DOMParser();
19 var xml = parser.parseFromString(stanza, 'text/xml');
20 monitor.processStanza(xml.firstElementChild);
21 var error = monitor.getFirstError();
22 assert.equal(error.raw_stanza, expected);
25 QUnit.test('should strip PII from session-initiate.', function(assert) {
27 '<iq xmlns="jabber:client" to="foo@google.com/chromotingE5A" ' +
28 'type="error" id="12747556118995360108" ' +
29 'from="123@chromoting.gserviceaccount.com/chromoting21B21C01">' +
30 '<jingle xmlns="urn:xmpp:jingle:1" sid="3953621430175055977" ' +
31 'action="session-initiate" ' +
32 'initiator="foo@google.com/chromotingE5A">' +
33 '<content name="chromoting" creator="initiator">' +
34 '<description xmlns="google:remoting">' +
36 '<control transport="mux-stream" version="3"/>' +
37 '<control transport="quic-stream" version="3"/>' +
38 '<event transport="mux-stream" version="2"/>' +
39 '<event transport="quic-stream" version="2"/>' +
40 '<video transport="stream" version="2" codec="vp9"/>' +
41 '<video transport="stream" version="2" codec="vp8"/>' +
42 '<video transport="quic-stream" version="2" codec="vp9"/>' +
43 '<video transport="quic-stream" version="2" codec="vp8"/>' +
44 '<audio transport="mux-stream" version="2" codec="opus"/>' +
45 '<audio transport="quic-stream" version="2" codec="opus"/>' +
46 '<audio transport="none"/>' +
47 '<initial-resolution width="640" height="480"/>' +
48 '<authentication supported-methods="spake2_plain"/>' +
49 '<quic-config>AAADwAAAAYAA=</quic-config>' +
51 '<unknown-field-that-contains-pii unknown-attribute="pii">' +
53 '</unknown-field-that-contains-pii>' +
56 '<error code="503" type="cancel">' +
57 '<service-unavailable xmlns="urn:ietf:xml:ns:xmpp-stanzas"/>' +
61 '<iq xmlns="jabber:client" to="REDACTED" type="error" ' +
62 'id="12747556118995360108" from="REDACTED">' +
63 '<jingle xmlns="urn:xmpp:jingle:1" sid="3953621430175055977" ' +
64 'action="session-initiate" initiator="REDACTED">' +
65 '<content name="chromoting" creator="initiator">' +
66 '<description xmlns="google:remoting">' +
68 '<control transport="mux-stream" version="3"/>' +
69 '<control transport="quic-stream" version="3"/>' +
70 '<event transport="mux-stream" version="2"/>' +
71 '<event transport="quic-stream" version="2"/>' +
72 '<video transport="stream" version="2" codec="vp9"/>' +
73 '<video transport="stream" version="2" codec="vp8"/>' +
74 '<video transport="quic-stream" version="2" codec="vp9"/>' +
75 '<video transport="quic-stream" version="2" codec="vp8"/>' +
76 '<audio transport="mux-stream" version="2" codec="opus"/>' +
77 '<audio transport="quic-stream" version="2" codec="opus"/>' +
78 '<audio transport="none"/>' +
79 '<initial-resolution width="640" height="480"/>' +
80 '<authentication supported-methods="spake2_plain"/>' +
81 '<quic-config>AAADwAAAAYAA=</quic-config>' +
83 '<unknown-field-that-contains-pii unknown-attribute="REDACTED">'+
85 '</unknown-field-that-contains-pii>' +
88 '<error code="503" type="cancel">' +
89 '<service-unavailable xmlns="urn:ietf:xml:ns:xmpp-stanzas"/>' +
92 runStanzaTest(input, expected, assert);