Пример #1
0
 def test_channel0_invalid_authentication_mechanism(self):
     connection = amqpstorm.Connection('localhost',
                                       'guest',
                                       'guest',
                                       lazy=True)
     channel = Channel0(connection)
     channel._send_start_ok_frame(
         Connection.Start(mechanisms='CRAM-MD5 SCRAM-SHA-1 SCRAM-SHA-256'))
     self.assertRaises(AMQPConnectionError, connection.check_for_errors)
Пример #2
0
    def test_channel0_send_start_ok_external(self):
        connection = FakeConnection()
        channel = Channel0(connection)
        channel._send_start_ok(Connection.Start(mechanisms=b'EXTERNAL'))

        self.assertTrue(connection.frames_out)

        channel_id, frame_out = connection.frames_out.pop()

        self.assertEqual(channel_id, 0)
        self.assertIsInstance(frame_out, Connection.StartOk)
        self.assertNotEqual(frame_out.locale, '')
        self.assertIsNotNone(frame_out.locale)
Пример #3
0
    def test_channel0_send_start_ok_frame(self):
        connection = FakeConnection()
        connection.parameters['username'] = '******'
        connection.parameters['password'] = '******'
        channel = Channel0(connection)
        channel._send_start_ok_frame(Connection.Start(mechanisms=b'PLAIN'))

        self.assertNotEqual(connection.frames_out, [])
        channel_id, frame_out = connection.frames_out.pop()
        self.assertEqual(channel_id, 0)
        self.assertIsInstance(frame_out, Connection.StartOk)
        self.assertNotEqual(frame_out.locale, '')
        self.assertIsNotNone(frame_out.locale)
Пример #4
0
    def test_channel0_start_invalid_auth_frame(self):
        connection = FakeConnection()
        connection.parameters['username'] = '******'
        connection.parameters['password'] = '******'
        channel = Channel0(connection)

        channel.on_frame(Connection.Start(mechanisms='invalid'))

        self.assertRaisesRegexp(
            AMQPConnectionError,
            'Unsupported Security Mechanism\(s\): invalid',
            connection.check_for_errors
        )
Пример #5
0
    def test_channel0_start_frame(self):
        connection = FakeConnection()
        connection.parameters['username'] = '******'
        connection.parameters['password'] = '******'
        channel = Channel0(connection)

        properties = {
            'version': 0
        }

        channel.on_frame(Connection.Start(server_properties=properties))

        self.assertEqual(channel.server_properties, properties)
        self.assertIsInstance(connection.get_last_frame(), Connection.StartOk)