From d1e3fa6a2b96344636b0f891b36142526baa26df Mon Sep 17 00:00:00 2001
From: Jiri Popelka <jpopelka@redhat.com>
Date: Tue, 22 Jun 2021 18:09:21 +0200
Subject: [PATCH 1/2] Apply patch
python-httpretty-fakesock_getpeercert_noconnect.patch
patch_name: python-httpretty-fakesock_getpeercert_noconnect.patch
patch_id: 1
description: |-
Avoid unnecessary remote access requirement (note: test only actually
does a remote connection after PR #313)
---
tests/unit/test_core.py | 49 +++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/tests/unit/test_core.py b/tests/unit/test_core.py
index 80c4a86..dd59248 100644
--- a/tests/unit/test_core.py
+++ b/tests/unit/test_core.py
@@ -191,28 +191,35 @@ def test_fake_ssl_socket_proxies_its_ow_socket():
@freeze_time("2013-10-04 04:20:00")
def test_fakesock_socket_getpeercert():
("fakesock.socket#getpeercert should return a hardcoded fake certificate")
- # Given a fake socket instance
- socket = fakesock.socket()
- # And that it's bound to some host
- socket._host = 'somewhere.com'
-
- # When I retrieve the peer certificate
- certificate = socket.getpeercert()
-
- # Then it should return a hardcoded value
- certificate.should.equal({
- u'notAfter': 'Sep 29 04:20:00 GMT',
- u'subject': (
- ((u'organizationName', u'*.somewhere.com'),),
- ((u'organizationalUnitName', u'Domain Control Validated'),),
- ((u'commonName', u'*.somewhere.com'),)),
- u'subjectAltName': (
- (u'DNS', u'*.somewhere.com'),
- (u'DNS', u'somewhere.com'),
- (u'DNS', u'*')
- )
- })
+ # Don't bother with an actual remote roundtrip
+ httpretty.allow_net_connect = False
+
+ try:
+ # Given a fake socket instance
+ socket = fakesock.socket()
+
+ # And that it's bound to some host
+ socket._host = 'somewhere.com'
+
+ # When I retrieve the peer certificate
+ certificate = socket.getpeercert()
+
+ # Then it should return a hardcoded value
+ certificate.should.equal({
+ u'notAfter': 'Sep 29 04:20:00 GMT',
+ u'subject': (
+ ((u'organizationName', u'*.somewhere.com'),),
+ ((u'organizationalUnitName', u'Domain Control Validated'),),
+ ((u'commonName', u'*.somewhere.com'),)),
+ u'subjectAltName': (
+ (u'DNS', u'*.somewhere.com'),
+ (u'DNS', u'somewhere.com'),
+ (u'DNS', u'*')
+ )
+ })
+ finally:
+ httpretty.allow_net_connect = True
def test_fakesock_socket_ssl():
--
2.31.1