Apply patchs:
remove-broken-test.patch Description: Remove broken test This test looks like broken, and if it doesn't really raise something, it still LGTM... :) Author: Thomas Goirand <zigo@debian.org> remove-network-access-test.patch Remove network access test This test is doing network access, which isn't acceptable during build. Author: Thomas Goirand <zigo@debian.org> match-uri-without-hostname-case.patch Match URI without letter case in hostname. The URI matching should ignore the hostname letter case, so that intermediate “normalising” of the hostname does not affect whether the URI matches. Author: Ben Finney <bignose@debian.org> Co-Author: Thomas Goirand <zigo@debian.org>
This commit is contained in:
parent
1858bae006
commit
c7923684e8
|
@ -1,3 +1,9 @@
|
||||||
|
python-httpretty (1.1.4-ok2) yangtze; urgency=medium
|
||||||
|
|
||||||
|
* Apply patchs.
|
||||||
|
|
||||||
|
-- sufang <sufang@kylinos.cn> Mon, 06 Feb 2023 15:38:14 +0800
|
||||||
|
|
||||||
python-httpretty (1.1.4-ok1) yangtze; urgency=medium
|
python-httpretty (1.1.4-ok1) yangtze; urgency=medium
|
||||||
|
|
||||||
* Build for openkylin.
|
* Build for openkylin.
|
||||||
|
|
|
@ -1425,6 +1425,7 @@ class httpretty(HttpBaseClass):
|
||||||
:param hostname: a string
|
:param hostname: a string
|
||||||
:returns: an :py:class:`~httpretty.core.URLMatcher` or ``None``
|
:returns: an :py:class:`~httpretty.core.URLMatcher` or ``None``
|
||||||
"""
|
"""
|
||||||
|
hostname_lower = hostname.lower()
|
||||||
items = sorted(
|
items = sorted(
|
||||||
cls._entries.items(),
|
cls._entries.items(),
|
||||||
key=lambda matcher_entries: matcher_entries[0].priority,
|
key=lambda matcher_entries: matcher_entries[0].priority,
|
||||||
|
@ -1432,8 +1433,8 @@ class httpretty(HttpBaseClass):
|
||||||
)
|
)
|
||||||
for matcher, value in items:
|
for matcher, value in items:
|
||||||
if matcher.info is None:
|
if matcher.info is None:
|
||||||
pattern_with_port = "https://{0}:".format(hostname)
|
pattern_with_port = "https://{0}:".format(hostname_lower)
|
||||||
pattern_without_port = "https://{0}/".format(hostname)
|
pattern_without_port = "https://{0}/".format(hostname_lower)
|
||||||
hostname_pattern = (
|
hostname_pattern = (
|
||||||
hostname_re
|
hostname_re
|
||||||
.match(matcher.regex.pattern)
|
.match(matcher.regex.pattern)
|
||||||
|
@ -1443,7 +1444,7 @@ class httpretty(HttpBaseClass):
|
||||||
if re.match(hostname_pattern, pattern):
|
if re.match(hostname_pattern, pattern):
|
||||||
return matcher
|
return matcher
|
||||||
|
|
||||||
elif matcher.info.hostname == hostname:
|
elif (matcher.info.hostname.lower() == hostname_lower):
|
||||||
return matcher
|
return matcher
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -1454,6 +1455,7 @@ class httpretty(HttpBaseClass):
|
||||||
:param port: an integer
|
:param port: an integer
|
||||||
:returns: an :py:class:`~httpretty.core.URLMatcher` or ``None``
|
:returns: an :py:class:`~httpretty.core.URLMatcher` or ``None``
|
||||||
"""
|
"""
|
||||||
|
hostname_lower = hostname.lower()
|
||||||
items = sorted(
|
items = sorted(
|
||||||
cls._entries.items(),
|
cls._entries.items(),
|
||||||
key=lambda matcher_entries: matcher_entries[0].priority,
|
key=lambda matcher_entries: matcher_entries[0].priority,
|
||||||
|
@ -1466,8 +1468,8 @@ class httpretty(HttpBaseClass):
|
||||||
else:
|
else:
|
||||||
scheme = 'http://'
|
scheme = 'http://'
|
||||||
|
|
||||||
pattern_without_port = "{0}{1}/".format(scheme, hostname)
|
pattern_without_port = "{0}{1}/".format(scheme, hostname_lower)
|
||||||
pattern_with_port = "{0}{1}:{2}/".format(scheme, hostname, port)
|
pattern_with_port = "{0}{1}:{2}/".format(scheme, hostname_lower, port)
|
||||||
hostname_pattern = (
|
hostname_pattern = (
|
||||||
hostname_re
|
hostname_re
|
||||||
.match(matcher.regex.pattern)
|
.match(matcher.regex.pattern)
|
||||||
|
@ -1477,7 +1479,7 @@ class httpretty(HttpBaseClass):
|
||||||
if re.match(hostname_pattern, pattern):
|
if re.match(hostname_pattern, pattern):
|
||||||
return matcher
|
return matcher
|
||||||
|
|
||||||
elif matcher.info.hostname == hostname \
|
elif matcher.info.hostname.lower() == hostname_lower \
|
||||||
and matcher.info.port == port:
|
and matcher.info.port == port:
|
||||||
return matcher
|
return matcher
|
||||||
|
|
||||||
|
|
|
@ -188,33 +188,6 @@ def test_fake_ssl_socket_proxies_its_ow_socket():
|
||||||
socket.send.assert_called_once_with("FOO")
|
socket.send.assert_called_once_with("FOO")
|
||||||
|
|
||||||
|
|
||||||
@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'*')
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def test_fakesock_socket_ssl():
|
def test_fakesock_socket_ssl():
|
||||||
("fakesock.socket#ssl should take a socket instance and return itself")
|
("fakesock.socket#ssl should take a socket instance and return itself")
|
||||||
# Given a fake socket instance
|
# Given a fake socket instance
|
||||||
|
|
|
@ -45,24 +45,6 @@ Content-Type: %(content_type)s
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def test_httpretty_should_raise_proper_exception_on_inconsistent_length():
|
|
||||||
("HTTPretty should raise proper exception on inconsistent Content-Length / "
|
|
||||||
"registered response body")
|
|
||||||
|
|
||||||
HTTPretty.register_uri.when.called_with(
|
|
||||||
HTTPretty.GET,
|
|
||||||
"http://github.com/gabrielfalcao",
|
|
||||||
body="that's me!",
|
|
||||||
adding_headers={
|
|
||||||
'Content-Length': '999'
|
|
||||||
}
|
|
||||||
).should.have.raised(
|
|
||||||
HTTPrettyError,
|
|
||||||
'HTTPretty got inconsistent parameters. The header Content-Length you registered expects size "999" '
|
|
||||||
'but the body you registered for that has actually length "10".'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_does_not_have_last_request_by_default():
|
def test_does_not_have_last_request_by_default():
|
||||||
'HTTPretty.last_request is a dummy object by default'
|
'HTTPretty.last_request is a dummy object by default'
|
||||||
HTTPretty.reset()
|
HTTPretty.reset()
|
||||||
|
@ -405,6 +387,26 @@ def test_socktype_good_python_version():
|
||||||
HTTPretty.disable()
|
HTTPretty.disable()
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_http_address_should_ignore_hostname_case():
|
||||||
|
"HTTPretty.match_http_address should ignore case of hostname."
|
||||||
|
|
||||||
|
for (register_hostname, match_hostname) in [
|
||||||
|
('foo.example.com', 'foo.example.com'),
|
||||||
|
('FOO.example.COM', 'foo.example.com'),
|
||||||
|
('foo.EXAMPLE.com', 'foo.example.com'),
|
||||||
|
('fOo.eXaMpLe.com', 'foo.example.com'),
|
||||||
|
('foo.example.com', 'FOO.example.COM'),
|
||||||
|
('foo.example.com', 'foo.EXAMPLE.com'),
|
||||||
|
('foo.example.com', 'fOo.eXaMpLe.com'),
|
||||||
|
]:
|
||||||
|
HTTPretty.register_uri(
|
||||||
|
HTTPretty.GET,
|
||||||
|
"http://{hostname}/".format(hostname=register_hostname),
|
||||||
|
body="yay",
|
||||||
|
)
|
||||||
|
assert HTTPretty.match_http_address(match_hostname, 80)
|
||||||
|
|
||||||
|
|
||||||
def test_httpretty_should_allow_registering_regex_hostnames():
|
def test_httpretty_should_allow_registering_regex_hostnames():
|
||||||
"HTTPretty should allow registering regexes with requests"
|
"HTTPretty should allow registering regexes with requests"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue