Created
March 16, 2013 15:14
-
-
Save czardoz/5176817 to your computer and use it in GitHub Desktop.
HTTPS unittest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gevent | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
from hive.helpers.streamserver import HiveStreamServer | |
from hive.helpers.common import create_socket | |
from hive.capabilities import https | |
import unittest | |
import httplib | |
class HTTPS_Test(unittest.TestCase): | |
def test_connection(self): | |
""" Tests if the capability is up, and sending | |
HTTP 401 (Unauthorized) headers. | |
""" | |
sessions = {} | |
cap = https.https(sessions, {'enabled': 'True', 'port': 8081}) | |
socket = create_socket(("0.0.0.0", 8081)) | |
srv = HiveStreamServer(socket, cap.handle_session, | |
keyfile='dummy_key.key', | |
certfile='dummy_cert.crt' ) | |
srv.start() | |
client = httplib.HTTPSConnection('127.0.0.1', 8081) | |
client.request("GET", "/") | |
response = client.getresponse() | |
self.assertEquals(response.status, 401) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment