-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from loganasherjones/no_cert_fix
Fixed bug for 1-way SSL RPC calls.
- Loading branch information
Showing
2 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
:copyright: Copyright 2016-2018 by the contributors (see AUTHORS file). | ||
:license: BSD, see LICENSE.txt for details. | ||
""" | ||
|
||
import ssl | ||
import unittest | ||
from http.client import HTTPConnection, HTTPSConnection | ||
|
||
from sphinxcontrib.confluencebuilder.publisher import ConfluenceTransport | ||
|
||
|
||
class TestConfluenceTransport(unittest.TestCase): | ||
def setUp(self): | ||
self.http_url = 'http://somehost' | ||
self.https_url = 'https://somehost' | ||
|
||
def test_make_connection_already_exists(self): | ||
transport = ConfluenceTransport(self.http_url, client_cert=None) | ||
connection = transport.make_connection('host') | ||
self.assertEqual(connection, transport.make_connection('host')) | ||
|
||
def test_make_http_connection(self): | ||
transport = ConfluenceTransport(self.http_url, client_cert=None) | ||
connection = transport.make_connection('host') | ||
self.assertIsInstance(connection, HTTPConnection) | ||
|
||
def test_make_https_connection_no_client_cert(self): | ||
transport = ConfluenceTransport(self.https_url, client_cert=None) | ||
connection = transport.make_connection('host') | ||
self.assertIsInstance(connection, HTTPSConnection) | ||
context = connection._context | ||
self.assertEqual(context.verify_mode, ssl.CERT_REQUIRED) | ||
|
||
def test_make_https_connection_disable_validation(self): | ||
transport = ConfluenceTransport(self.https_url) | ||
transport.disable_ssl_verification() | ||
connection = transport.make_connection('host') | ||
self.assertIsInstance(connection, HTTPSConnection) | ||
context = connection._context | ||
self.assertEqual(context.verify_mode, ssl.CERT_NONE) | ||
|
||
def test_make_http_connection_with_client_cert(self): | ||
transport = ConfluenceTransport(self.http_url, | ||
client_cert=("file1", None)) | ||
connection = transport.make_connection('host') | ||
self.assertIsInstance(connection, HTTPConnection) |