def got_send_iq(self):
        SendFileTest.got_send_iq(self)

        # Receiver declines the file offer
        reply = domish.Element(('', 'iq'))
        reply['to'] = self.iq['from']
        reply['type'] = 'error'
        reply['id'] = self.iq['id']
        error_node = reply.addElement((None, 'error'), content='User declined to receive the file')
        error_node['type'] = '406'
        self.incoming.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

        self.channel.Close()
        self.q.expect('dbus-signal', signal='Closed')

        # stop test
        return True
    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
    def got_send_iq(self):
        SendFileTest.got_send_iq(self)

        # Receiver declines the file offer
        reply = domish.Element(('', 'iq'))
        reply['to'] = self.iq['from']
        reply['from'] = self.iq['to']
        reply['type'] = 'error'
        reply['id'] = self.iq['id']
        query = reply.addElement(('jabber:iq:oob', 'query'))
        url_node = query.addElement('url', content=self.url)
        query.addElement('desc', content=self.desc)
        error_node = reply.addElement((None, 'error'))
        error_node['code'] = '406'
        error_node['type'] = 'modify'
        not_acceptable_node = error_node.addElement(('urn:ietf:params:xml:ns:xmpp-stanzas',
            'not-acceptable'))
        self.incoming.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

        # stop test
        return True
    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'
        error.addElement((ns.STANZA, 'forbidden'))
        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 as e:
            assert e.get_dbus_name() == cs.NOT_AVAILABLE

        # stop test
        return True
    def __init__(self):
        ReceiveFileTest.__init__(self)
        SendFileTest.__init__(self)

        self._actions = [
            self.connect,
            self.announce_contact,
            self.wait_for_contact,
            self.connect_to_salut,
            # receive file
            self.setup_http_server,
            self.send_ft_offer_iq,
            self.check_new_channel,
            self.create_ft_channel,
            self.set_uri,
            self.accept_file,
            self.receive_file,
            self.close_channel,

            # now send a file. We'll reuse the same XMPP connection
            self.request_ft_channel,
            self.create_ft_channel,
            self.got_send_iq,
            self.provide_file,
            self.client_request_file,
            self.send_file,
            self.close_channel
        ]
    def __init__(self, bytestream_cls, file, address_type, access_control,
                 acces_control_param):
        SendFileTest.__init__(self, bytestream_cls, file, address_type,
                              access_control, acces_control_param)

        self._actions = [
            self.connect, self.check_ft_available, self.my_request_ft_channel
        ]
    def provide_file(self):
        SendFileTest.provide_file(self)

        # regression test: Salut used to crash at this point
        self.conn.Disconnect()
        self.q.expect('dbus-signal', signal='StatusChanged', args=[2L, 1L])

        # stop test
        return True
    def provide_file(self):
        SendFileTest.provide_file(self)

        # regression test: Salut used to crash at this point
        self.conn.Disconnect()
        self.q.expect('dbus-signal', signal='StatusChanged', args=[2L, 1L])

        # stop test
        return True
Esempio n. 9
0
    def client_request_file(self):
        # state is still Pending as remote didn't accept the transfer yet
        state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
        assert state == cs.FT_STATE_PENDING

        SendFileTest.client_request_file(self)

        # Remote accepted the transfer
        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_ACCEPTED, state
        assert reason == cs.FT_STATE_CHANGE_REASON_NONE
Esempio n. 10
0
    def client_accept_file(self):
        SendFileTest.client_accept_file(self)

        e = self.q.expect('dbus-signal', signal='InitialOffsetDefined')
        offset = e.args[0]
        assert offset == self.file.offset

        # Channel is open. We can start to send the file
        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_OPEN
        assert reason == cs.FT_STATE_CHANGE_REASON_NONE
    def client_accept_file(self):
        # state is still Pending as remote didn't accept the transfer yet
        state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, "State")
        assert state == cs.FT_STATE_PENDING

        SendFileTest.client_accept_file(self)

        # Remote accepted the transfer
        e = self.q.expect("dbus-signal", signal="FileTransferStateChanged")
        state, reason = e.args
        assert state == cs.FT_STATE_ACCEPTED, state
        assert reason == cs.FT_STATE_CHANGE_REASON_NONE
    def provide_file(self):
        SendFileTest.provide_file(self)

        e = self.q.expect("dbus-signal", signal="InitialOffsetDefined")
        offset = e.args[0]
        assert offset == self.file.offset

        # Channel is open. We can start to send the file
        e = self.q.expect("dbus-signal", signal="FileTransferStateChanged")
        state, reason = e.args
        assert state == cs.FT_STATE_OPEN
        assert reason == cs.FT_STATE_CHANGE_REASON_REQUESTED
    def client_request_file(self):
        SendFileTest.client_request_file(self)
        e = self.q.expect('dbus-signal', signal='InitialOffsetDefined')
        offset = e.args[0]
        # We don't support resume
        assert offset == 0

        # Channel is open. We can start to send the file
        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_OPEN
        assert reason == cs.FT_STATE_CHANGE_REASON_NONE
    def provide_file(self):
        SendFileTest.provide_file(self)

        # cancel the transfer before the receiver accepts it
        self.channel.Close()

        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_CANCELLED
        assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_STOPPED

        self.q.expect('dbus-signal', signal='Closed')
Esempio n. 15
0
    def provide_file(self):
        SendFileTest.provide_file(self)

        e = self.q.expect('dbus-signal', signal='InitialOffsetDefined')
        offset = e.args[0]
        # We don't support resume
        assert offset == 0

        # Channel is open. We can start to send the file
        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_OPEN
        assert reason == cs.FT_STATE_CHANGE_REASON_REQUESTED
    def __init__(self):
        ReceiveFileTest.__init__(self)
        SendFileTest.__init__(self)

        self._actions = [self.connect, self.announce_contact,self.wait_for_contact,
                self.connect_to_salut,
                # receive file
                self.setup_http_server, self.send_ft_offer_iq, self.check_new_channel,
                self.create_ft_channel, self.set_uri, self.accept_file,
                self.receive_file, self.close_channel,

                # now send a file. We'll reuse the same XMPP connection
               self.request_ft_channel, self.create_ft_channel, self.got_send_iq,
               self.provide_file, self.client_request_file, self.send_file,
               self.close_channel]
Esempio n. 17
0
    def provide_file(self):
        SendFileTest.provide_file(self)

        # cancel the transfer before the receiver accepts it
        self.channel.Close()

        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_CANCELLED
        assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_STOPPED

        self.q.expect('dbus-signal', signal='Closed')

        # XEP-0096 doesn't have a way to inform receiver we cancelled the
        # transfer...
        return True
    def provide_file(self):
        SendFileTest.provide_file(self)

        # cancel the transfer before the receiver accepts it
        self.channel.Close()

        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
        state, reason = e.args
        assert state == cs.FT_STATE_CANCELLED
        assert reason == cs.FT_STATE_CHANGE_REASON_LOCAL_STOPPED

        self.q.expect('dbus-signal', signal='Closed')

        # XEP-0096 doesn't have a way to inform receiver we cancelled the
        # transfer...
        return True
    def __init__(self, bytestream_cls, file, address_type, access_control, acces_control_param):
        SendFileTest.__init__(self, bytestream_cls, file, address_type, access_control, acces_control_param)

        self._actions = [
            self.connect,
            self.check_ft_available,
            self.announce_contact,
            self.check_ft_available,
            self.request_ft_channel,
            self.create_ft_channel,
            self.got_send_iq,
            self.client_accept_file,
            self.provide_file,
            self.send_file,
            self.close_channel,
        ]
Esempio n. 20
0
    def provide_file(self):

        # try to accept our outgoing file transfer
        try:
            self.ft_channel.AcceptFile(self.address_type,
                                       self.access_control,
                                       self.access_control_param,
                                       self.file.offset,
                                       byte_arrays=True)
        except dbus.DBusException as e:
            assert e.get_dbus_name() == cs.NOT_AVAILABLE
        else:
            assert False

        if SendFileTest.provide_file(self):
            return True

        # state is still Pending as remote didn't accept the transfer yet
        state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
        assert state == cs.FT_STATE_PENDING
 def provide_file(self):
     SendFileTest.provide_file(self)
     state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
     assert state == cs.FT_STATE_PENDING
 def __init__(self):
     SendFileTest.__init__(self, cs.SOCKET_ADDRESS_TYPE_IPV6)
Esempio n. 23
0
    def __init__(self):
        SendFileTest.__init__(self)

        self._actions = [
            self.connect, self.check_ft_available, self.my_request_ft_channel
        ]
Esempio n. 24
0
 def announce_contact(self):
     SendFileTest.announce_contact(self, metadata=False)
Esempio n. 25
0
    def __init__(self, bytestream_cls, file, address_type, access_control, acces_control_param):
        SendFileTest.__init__(self, bytestream_cls, file, address_type, access_control, acces_control_param)

        self._actions =  [self.connect, self.check_ft_available, self.announce_contact,
            self.check_ft_available, self.request_ft_channel, self.create_ft_channel, self.got_send_iq,
            self.client_accept_file, self.provide_file, self.send_file, self.close_channel]
Esempio n. 26
0
    def close_channel(self):
        # Still no URI
        assertNoURI(self.ft_channel)

        SendFileTest.close_channel(self)
 def __init__(self):
     SendFileTest.__init__(self, cs.SOCKET_ADDRESS_TYPE_IPV4)
 def provide_file(self):
     SendFileTest.provide_file(self)
     state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
     assert state == cs.FT_STATE_PENDING
    raise SystemExit(77)

class SendFileTransferProvideImmediately(SendFileTest):
    def provide_file(self):

        # try to accept our outgoing file transfer
        try:
            self.ft_channel.AcceptFile(self.address_type,
                self.access_control, self.access_control_param, self.file.offset,
                byte_arrays=True)
        except dbus.DBusException, e:
            assert e.get_dbus_name() == cs.NOT_AVAILABLE
        else:
            assert False

        if SendFileTest.provide_file(self):
            return True

        # state is still Pending as remote didn't accept the transfer yet
        state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
        assert state == cs.FT_STATE_PENDING

    def client_accept_file(self):
        SendFileTest.client_accept_file(self)

        e = self.q.expect('dbus-signal', signal='InitialOffsetDefined')
        offset = e.args[0]
        assert offset == self.file.offset

        # Channel is open. We can start to send the file
        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
 def request_ft_channel(self):
     SendFileTest.request_ft_channel(self, False)
    def close_channel(self):
        # Still no URI
        assertNoURI(self.ft_channel)

        SendFileTest.close_channel(self)
    def __init__(self, bytestream_cls, file, address_type, access_control, acces_control_param):
        SendFileTest.__init__(self, bytestream_cls, file, address_type, access_control, acces_control_param)

        self._actions = [self.connect, self.check_ft_available, self.my_request_ft_channel]
Esempio n. 33
0
    def provide_file(self):
        SendFileTest.provide_file(self)

        # state is still Pending as remote didn't accept the transfer yet
        state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
        assert state == cs.FT_STATE_PENDING
Esempio n. 34
0
 def request_ft_channel(self):
     SendFileTest.request_ft_channel(self, False)
Esempio n. 35
0
 def announce_contact(self):
     SendFileTest.announce_contact(self, metadata=False)
Esempio n. 36
0
class SendFileTransferProvideImmediately(SendFileTest):
    def provide_file(self):

        # try to accept our outgoing file transfer
        try:
            self.ft_channel.AcceptFile(self.address_type,
                                       self.access_control,
                                       self.access_control_param,
                                       self.file.offset,
                                       byte_arrays=True)
        except dbus.DBusException, e:
            assert e.get_dbus_name() == cs.NOT_AVAILABLE
        else:
            assert False

        if SendFileTest.provide_file(self):
            return True

        # state is still Pending as remote didn't accept the transfer yet
        state = self.ft_props.Get(cs.CHANNEL_TYPE_FILE_TRANSFER, 'State')
        assert state == cs.FT_STATE_PENDING

    def client_accept_file(self):
        SendFileTest.client_accept_file(self)

        e = self.q.expect('dbus-signal', signal='InitialOffsetDefined')
        offset = e.args[0]
        assert offset == self.file.offset

        # Channel is open. We can start to send the file
        e = self.q.expect('dbus-signal', signal='FileTransferStateChanged')
Esempio n. 37
0
    def __init__(self):
        SendFileTest.__init__(self)

        self._actions =  [self.connect, self.check_ft_available, self.announce_contact, self.wait_for_contact,
            self.check_ft_available, self.request_ft_channel, self.create_ft_channel, self.got_send_iq,
            self.client_request_file, self.provide_file, self.send_file, self.close_channel]