Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 2ca177c

Browse files
committed
Add basic test for force_proto
1 parent ae56862 commit 2ca177c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test_integration.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import requests
1010
import threading
1111
import time
12+
import socket
1213
import hyper
1314
import hyper.http11.connection
1415
import pytest
@@ -25,6 +26,7 @@
2526
REQUEST_CODES, REQUEST_CODES_LENGTH
2627
)
2728
from hyper.http20.exceptions import ConnectionError, StreamResetError
29+
from hyper.tls import wrap_socket
2830
from server import SocketLevelTest
2931

3032
# Turn off certificate verification for the tests.
@@ -74,6 +76,31 @@ def receive_preamble(sock):
7476
return
7577

7678

79+
class TestBasicSocketManipulation(SocketLevelTest):
80+
# These aren't HTTP/2 tests, but it doesn't hurt to leave it.
81+
h2 = True
82+
83+
def test_connection_string(self):
84+
self.set_up()
85+
evt = threading.Event()
86+
87+
def socket_handler(listener):
88+
sock = listener.accept()[0]
89+
90+
evt.wait(5)
91+
sock.close()
92+
93+
self._start_server(socket_handler)
94+
s = socket.create_connection((self.host, self.port))
95+
s, proto = wrap_socket(s, "localhost", force_proto=b"test")
96+
s.close()
97+
evt.set()
98+
99+
assert proto == b"test"
100+
101+
self.tear_down()
102+
103+
77104
class TestHyperIntegration(SocketLevelTest):
78105
# These are HTTP/2 tests.
79106
h2 = True

0 commit comments

Comments
 (0)