Example #1
0
    def test_handle_stream_frame_over_max_stream_data(self):
        client = QuicConnection(is_client=True)
        server = QuicConnection(
            is_client=False,
            certificate=SERVER_CERTIFICATE,
            private_key=SERVER_PRIVATE_KEY,
        )

        # perform handshake
        client_transport, server_transport = create_transport(client, server)

        # client receives STREAM frame
        frame_type = QuicFrameType.STREAM_BASE | QuicStreamFlag.OFF
        stream_id = 1
        with self.assertRaises(QuicConnectionError) as cm:
            client._handle_stream_frame(
                tls.Epoch.ONE_RTT,
                frame_type,
                Buffer(
                    data=encode_uint_var(stream_id) +
                    encode_uint_var(client._local_max_stream_data_bidi_remote +
                                    1)),
            )
        self.assertEqual(cm.exception.error_code,
                         QuicErrorCode.FLOW_CONTROL_ERROR)
        self.assertEqual(cm.exception.frame_type, frame_type)
        self.assertEqual(cm.exception.reason_phrase, "Over stream data limit")
Example #2
0
    def test_handle_stream_frame_wrong_initiator(self):
        client = QuicConnection(is_client=True)
        server = QuicConnection(
            is_client=False,
            certificate=SERVER_CERTIFICATE,
            private_key=SERVER_PRIVATE_KEY,
        )

        # perform handshake
        client_transport, server_transport = create_transport(client, server)

        # client receives STREAM frame
        with self.assertRaises(QuicConnectionError) as cm:
            client._handle_stream_frame(tls.Epoch.ONE_RTT,
                                        QuicFrameType.STREAM_BASE,
                                        Buffer(data=b"\x00"))
        self.assertEqual(cm.exception.error_code,
                         QuicErrorCode.STREAM_STATE_ERROR)
        self.assertEqual(cm.exception.frame_type, QuicFrameType.STREAM_BASE)
        self.assertEqual(cm.exception.reason_phrase, "Wrong stream initiator")
Example #3
0
    def test_handle_stream_frame_over_max_streams(self):
        client = QuicConnection(is_client=True)
        server = QuicConnection(
            is_client=False,
            certificate=SERVER_CERTIFICATE,
            private_key=SERVER_PRIVATE_KEY,
        )

        # perform handshake
        client_transport, server_transport = create_transport(client, server)

        # client receives STREAM frame
        with self.assertRaises(QuicConnectionError) as cm:
            client._handle_stream_frame(
                tls.Epoch.ONE_RTT,
                QuicFrameType.STREAM_BASE,
                Buffer(data=encode_uint_var(client._local_max_stream_data_uni *
                                            4 + 3)),
            )
        self.assertEqual(cm.exception.error_code,
                         QuicErrorCode.STREAM_LIMIT_ERROR)
        self.assertEqual(cm.exception.frame_type, QuicFrameType.STREAM_BASE)
        self.assertEqual(cm.exception.reason_phrase, "Too many streams open")