"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/utils/test_http.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_http.py  (salt-3002.1):test_http.py  (salt-3002.2)
""" """
:codeauthor: Nicole Thomas <nicole@saltstack.com> :codeauthor: Nicole Thomas <nicole@saltstack.com>
""" """
import socket import socket
from contextlib import closing from contextlib import closing
import salt.utils.http as http import salt.utils.http as http
from tests.support.helpers import MirrorPostHandler, Webserver, slowTest from tests.support.helpers import MirrorPostHandler, Webserver, slowTest
from tests.support.unit import TestCase from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
try:
import tornado.curl_httpclient # pylint: disable=unused-import
HAS_CURL = True
except ImportError:
HAS_CURL = False
class HTTPTestCase(TestCase): class HTTPTestCase(TestCase):
""" """
Unit TestCase for the salt.utils.http module. Unit TestCase for the salt.utils.http module.
""" """
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.post_webserver = Webserver(handler=MirrorPostHandler) cls.post_webserver = Webserver(handler=MirrorPostHandler)
cls.post_webserver.start() cls.post_webserver.start()
skipping to change at line 190 skipping to change at line 198
method="POST", method="POST",
data="mydatahere", data="mydatahere",
formdata=True, formdata=True,
formdata_fieldname="fieldname_here", formdata_fieldname="fieldname_here",
backend="requests", backend="requests",
) )
body = ret.get("body", "") body = ret.get("body", "")
boundary = body[: body.find("\r")] boundary = body[: body.find("\r")]
self.assertEqual(body, match_this.format(boundary)) self.assertEqual(body, match_this.format(boundary))
@skipIf(
HAS_CURL is False, "Missing prerequisites for tornado.curl_httpclient li
brary"
)
def test_query_proxy(self):
"""
Test http.query with tornado and with proxy opts set
and then test with no_proxy set to ensure we dont
run into issue #55192 again.
"""
data = "mydatahere"
opts = {
"proxy_host": "127.0.0.1",
"proxy_port": 88,
"proxy_username": "salt_test",
"proxy_password": "super_secret",
}
mock_curl = MagicMock()
with patch("tornado.httpclient.HTTPClient.fetch", mock_curl):
ret = http.query(
self.post_web_root,
method="POST",
data=data,
backend="tornado",
opts=opts,
)
for opt in opts:
assert opt in mock_curl.call_args_list[0][1].keys()
opts["no_proxy"] = ["127.0.0.1"]
ret = http.query(
self.post_web_root, method="POST", data=data, backend="tornado", opt
s=opts
)
body = ret.get("body", "")
assert body == data
class HTTPGetTestCase(TestCase): class HTTPGetTestCase(TestCase):
""" """
Unit TestCase for the salt.utils.http module when Unit TestCase for the salt.utils.http module when
using Get method using Get method
""" """
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.get_webserver = Webserver() cls.get_webserver = Webserver()
cls.get_webserver.start() cls.get_webserver.start()
 End of changes. 2 change blocks. 
1 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)