Skip to content

Commit

Permalink
test for #485
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed May 1, 2018
1 parent b8699f3 commit c9eaa1c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
34 changes: 34 additions & 0 deletions tests/isolated/green_ssl_pythonhttpsverify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
__test__ = False

if __name__ == '__main__':
import os
assert os.environ.get('PYTHONHTTPSVERIFY', '') == '0'

import eventlet
from eventlet.green import socket, ssl, httplib
import tests
sock = ssl.wrap_socket(
socket.socket(),
tests.private_key_file,
tests.certificate_file,
server_side=True,
)
sock.bind(('localhost', 0))
sock.listen(2)

@eventlet.spawn
def https_server():
client, _ = sock.accept()
client.read()
client.sendall(b'HTTP/1.0 204 OK BUT NO THANKS\r\n\r\n')
eventlet.sleep(0.1)
client.shutdown(socket.SHUT_RDWR)

sa = sock.getsockname()
conn = httplib.HTTPSConnection(sa[0], sa[1], timeout=0.5)
conn.request('GET', '/')
r = conn.getresponse()
r.read()
assert r.status == '204 OK BUT NO THANKS'

print('pass')
7 changes: 5 additions & 2 deletions tests/ssl_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import contextlib
import socket
import warnings

import eventlet
Expand Down Expand Up @@ -303,3 +301,8 @@ def accept(listener):
server_to_client.close()

listener.close()


def test_pythonhttpsverify():
# https://github.com/eventlet/eventlet/pull/485
tests.run_isolated('green_ssl_pythonhttpsverify.py', env={'PYTHONHTTPSVERIFY': '0'})

0 comments on commit c9eaa1c

Please sign in to comment.