Ejemplo n.º 1
0
    def test_should_reject_too_big_message(self):
        _, message = base.generate_rejectable_message()
        headers = base._get_headers(self.logs_client.get_headers())
        try:
            self.logs_client.send_single_log(message, headers)
        except exceptions.OverLimit as urc:
            self.assertEqual(413, urc.resp.status)
            return

        self.assertTrue(False, 'API should respond with 413')
Ejemplo n.º 2
0
    def test_should_reject_too_big_message(self):
        _, message = base.generate_rejectable_message()
        headers = base._get_headers(self.logs_client.get_headers())
        data = base._get_data(message)
        # Add 'Connection: Keep-Alive' to send large message before
        # connection is closed by client. In class ClosingHttp is added
        # header 'connection:close' (which will cause closing socket before sending whole message).
        # Data are send in small TCP packages.
        # Without this header set to Keep-Alive Tempest lib will try to retry connection and finally
        # raise ProtocolError.
        headers.update({'Connection': 'Keep-Alive'})
        try:
            self.logs_client.send_single_log(data, headers)
        except exceptions.OverLimit as urc:
            self.assertEqual(413, urc.resp.status)
            return

        self.assertTrue(False, 'API should respond with 413')
    def test_should_reject_too_big_message_multiline(self):
        _, message = base.generate_rejectable_message()
        message = message.replace(' ', '\n')
        headers = base._get_headers(self.logs_clients["v3"].get_headers())
        # Add Connection: Keep-Alive to send large message before
        # connection is closed by cli. In class ClosingHttp is added
        # header connection:close (which will cause closing socket before sending whole message).
        # Data are send in small TCP packages.
        # Without this header set to Keep-Alive Tempest lib will try to retry connection and finally
        # raise ProtocolError.
        headers.update({'Connection': 'Keep-Alive'})
        for ver, cli in self.logs_clients.items():
            data = base._get_data(message, version=ver)
            try:
                cli.send_single_log(data, headers)
            except exceptions.OverLimit as urc:
                self.assertEqual(413, urc.resp.status)
                return
            except exceptions.UnexpectedContentType as uct:
                self.assertEqual(503, uct.resp.status)
                return

            self.assertTrue(False, 'API should respond with 413 or 503')