aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2016-06-05 15:30:58 +0200
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2016-07-05 22:15:57 +0200
commit5fecb8c843a4d0874f96d19eb72ebdff66e2f19d (patch)
treed44af5c400fa7aaac40073b3bacb1ed35b9b3806
parent8d2042ea8ad7ce30ef8808c3c5e556adf4160cd3 (diff)
downloadmitmproxy-5fecb8c843a4d0874f96d19eb72ebdff66e2f19d.tar.gz
mitmproxy-5fecb8c843a4d0874f96d19eb72ebdff66e2f19d.tar.bz2
mitmproxy-5fecb8c843a4d0874f96d19eb72ebdff66e2f19d.zip
http2: test fatal connection termination
-rw-r--r--test/mitmproxy/test_protocol_http2.py53
1 files changed, 52 insertions, 1 deletions
diff --git a/test/mitmproxy/test_protocol_http2.py b/test/mitmproxy/test_protocol_http2.py
index 89bb16c6..2eb0b120 100644
--- a/test/mitmproxy/test_protocol_http2.py
+++ b/test/mitmproxy/test_protocol_http2.py
@@ -4,8 +4,8 @@ from __future__ import (absolute_import, print_function, division)
import pytest
import os
-import traceback
import tempfile
+import traceback
import h2
@@ -580,3 +580,54 @@ class TestMaxConcurrentStreams(_Http2TestBase, _Http2ServerBase):
for flow in self.master.state.flows:
assert flow.response.status_code == 200
assert "Stream-ID" in flow.response.body
+
+
+@requires_alpn
+class TestConnectionTerminated(_Http2TestBase, _Http2ServerBase):
+
+ @classmethod
+ def setup_class(self):
+ _Http2TestBase.setup_class()
+ _Http2ServerBase.setup_class()
+
+ @classmethod
+ def teardown_class(self):
+ _Http2TestBase.teardown_class()
+ _Http2ServerBase.teardown_class()
+
+ @classmethod
+ def handle_server_event(self, event, h2_conn, rfile, wfile):
+ if isinstance(event, h2.events.RequestReceived):
+ h2_conn.close_connection(error_code=5, last_stream_id=42, additional_data='foobar')
+ wfile.write(h2_conn.data_to_send())
+ wfile.flush()
+ return True
+
+ def test_connection_terminated(self):
+ client, h2_conn = self._setup_connection()
+
+ self._send_request(client.wfile, h2_conn, headers=[
+ (':authority', "127.0.0.1:%s" % self.server.server.address.port),
+ (':method', 'GET'),
+ (':scheme', 'https'),
+ (':path', '/'),
+ ])
+
+ done = False
+ connection_terminated_event = None
+ while not done:
+ try:
+ raw = b''.join(framereader.http2_read_raw_frame(client.rfile))
+ events = h2_conn.receive_data(raw)
+ for event in events:
+ if isinstance(event, h2.events.ConnectionTerminated):
+ connection_terminated_event = event
+ done = True
+ except:
+ break
+
+ assert len(self.master.state.flows) == 1
+ assert connection_terminated_event is not None
+ assert connection_terminated_event.error_code == 5
+ assert connection_terminated_event.last_stream_id == 42
+ assert connection_terminated_event.additional_data == 'foobar'
t-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -142,6 +142,74 @@ static struct board_info __initdata boar
 		},
 	},
 };
+
+static struct sprom_fixup __initdata dsl2751b_e1_fixups[] = {
+	{ .offset = 96, .value = 0x2046 },
+	{ .offset = 97, .value = 0xfe9d },
+	{ .offset = 98, .value = 0x1854 },
+	{ .offset = 99, .value = 0xfa59 },
+	{ .offset = 112, .value = 0x2046 },
+	{ .offset = 113, .value = 0xfe79 },
+	{ .offset = 114, .value = 0x17f5 },
+	{ .offset = 115, .value = 0xfa47 },
+	{ .offset = 161, .value = 0x2222 },
+	{ .offset = 162, .value = 0x2222 },
+	{ .offset = 169, .value = 0x2222 },
+	{ .offset = 170, .value = 0x2222 },
+	{ .offset = 171, .value = 0x5555 },
+	{ .offset = 172, .value = 0x5555 },
+	{ .offset = 173, .value = 0x4444 },
+	{ .offset = 174, .value = 0x4444 },
+	{ .offset = 175, .value = 0x5555 },
+	{ .offset = 176, .value = 0x5555 },
+};
+
+static struct board_info __initdata board_dsl_2751b_d1 = {
+	.name				= "AW5200B",
+	.expected_cpu_id		= 0x6318,
+
+	.has_pci			= 1,
+	.use_fallback_sprom		= 1,
+
+	.has_enetsw			= 1,
+
+	.has_ohci0			= 1,
+	.has_ehci0			= 1,
+	.num_usbh_ports			= 1,
+
+	.enetsw = {
+		.used_ports = {
+			[0] = {
+				.used	= 1,
+				.phy_id = 1,
+				.name	= "Port 1",
+			},
+			[1] = {
+				.used	= 1,
+				.phy_id	= 2,
+				.name	= "Port 2",
+			},
+			[2] = {
+				.used	= 1,
+				.phy_id	= 3,
+				.name	= "Port 3",
+			},
+			[3] = {
+				.used	= 1,
+				.phy_id	= 4,
+				.name	= "Port 4",
+			},
+		},
+	},
+
+	.fallback_sprom = {
+		.type 				= SPROM_BCM43217,
+		.pci_bus			= 1,
+		.pci_dev			= 0,
+		.board_fixups			= dsl2751b_e1_fixups,
+		.num_board_fixups		= ARRAY_SIZE(dsl2751b_e1_fixups),
+	},
+};
 #endif /* CONFIG_BCM63XX_CPU_6318 */
 
 /*
@@ -2039,6 +2107,7 @@ static const struct board_info __initcon
 #ifdef CONFIG_BCM63XX_CPU_6318
 	&board_96318ref,
 	&board_96318ref_p300,
+	&board_dsl_2751b_d1,
 #endif
 #ifdef CONFIG_BCM63XX_CPU_6328
 	&board_96328avng,
@@ -2132,6 +2201,7 @@ static struct of_device_id const bcm963x
 #ifdef CONFIG_BCM63XX_CPU_6318
 	{ .compatible = "brcm,bcm96318ref", .data = &board_96318ref, },
 	{ .compatible = "brcm,bcm96318ref_p300", .data = &board_96318ref_p300, },
+	{ .compatible = "d-link,dsl-275xb-d", .data = &board_dsl_2751b_d1, },
 #endif
 #ifdef CONFIG_BCM63XX_CPU_6328
 	{ .compatible = "adb,a4001n", .data = &board_A4001N, },