/usr/lib/telepathy-gabble-tests/twisted/file-transfer/test-send-file-declined.py is in telepathy-gabble-tests 0.18.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import dbus
import constants as cs
from file_transfer_helper import SendFileTest, exec_file_transfer_test
from twisted.words.xish import domish
import ns
from config import FILE_TRANSFER_ENABLED
if not FILE_TRANSFER_ENABLED:
print "NOTE: built with --disable-file-transfer"
raise SystemExit(77)
class SendFileDeclinedTest(SendFileTest):
def got_send_iq(self):
SendFileTest.got_send_iq(self)
# Receiver declines the file offer
reply = domish.Element(('jabber:client', 'iq'))
reply['to'] = 'test@localhost/Resource'
reply['from'] = self.iq['to']
reply['type'] = 'error'
reply['id'] = self.iq['id']
error = reply.addElement((None, 'error'))
error['code'] = '403'
error['type'] = 'cancel'
forbidden = error.addElement((ns.STANZA, 'forbidden'))
text = error.addElement((ns.STANZA, 'text'), content='Offer Declined')
self.stream.send(reply)
e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
state, reason = e.args
assert state == cs.FT_STATE_CANCELLED, state
assert reason == cs.FT_STATE_CHANGE_REASON_REMOTE_STOPPED
transferred = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'TransferredBytes')
# no byte has been transferred as the file was declined
assert transferred == 0
# try to provide the file, assert that this finishes the test (e.g.
# couldn't go further because of ipv6) or that it raises
# cs.NOT_AVAILABLE
try:
assert self.provide_file()
except dbus.DBusException, e:
assert e.get_dbus_name() == cs.NOT_AVAILABLE
# stop test
return True
if __name__ == '__main__':
exec_file_transfer_test(SendFileDeclinedTest)
|