|
5 | 5 |
|
6 | 6 | from gabbletest import XmppXmlStream, exec_test, elem, acknowledge_iq |
7 | 7 | from servicetest import (EventPattern, wrap_channel, assertEquals, assertLength, |
8 | | - assertContains) |
| 8 | + assertContains, TimeoutError) |
9 | 9 | import constants as cs |
10 | 10 |
|
11 | 11 | NS_CARBONS = 'urn:xmpp:carbons:2' |
@@ -172,6 +172,25 @@ def test(q, bus, conn, stream): |
172 | 172 | assert body['content-type'] == 'text/plain', body |
173 | 173 | assert body['content'] == u'goodbye', body |
174 | 174 |
|
| 175 | + # Verify source protection |
| 176 | + msg = elem( 'message', type='chat', from_='[email protected]/agent712')( |
| 177 | + elem(NS_CARBONS, 'received')( |
| 178 | + elem(NS_FORWARD, 'forwarded')( |
| 179 | + elem( 'jabber:client', 'message', id=id, from_='[email protected]/Pidgin', type='chat')( |
| 180 | + elem('body')('Mr. Anderson!') |
| 181 | + ) |
| 182 | + ) |
| 183 | + ) |
| 184 | + ) |
| 185 | + stream.send(msg) |
| 186 | + # This is a nasty test but we need to make sure spoofed message is ignored |
| 187 | + try: |
| 188 | + q.timeout = 2 |
| 189 | + message_received = q.expect('dbus-signal', signal='MessageReceived') |
| 190 | + assert not message_received, message_received.args |
| 191 | + except TimeoutError as e: |
| 192 | + pass |
| 193 | + |
175 | 194 |
|
176 | 195 | if __name__ == '__main__': |
177 | 196 | exec_test(test, protocol=CarbonStream, params={'message-carbons':True}) |
0 commit comments