Merge "Add back --insecure option to CURL debug"

This commit is contained in:
Jenkins
2014-02-12 06:40:29 +00:00
committed by Gerrit Code Review
3 changed files with 28 additions and 1 deletions

View File

@@ -55,7 +55,8 @@ class Session(object):
:param verify: The verification arguments to pass to requests. These :param verify: The verification arguments to pass to requests. These
are of the same form as requests expects, so True or are of the same form as requests expects, so True or
False to verify (or not) against system certificates or False to verify (or not) against system certificates or
a path to a bundle or CA certs to check against. a path to a bundle or CA certs to check against or None
for requests to attempt to locate and use certificates.
(optional, defaults to True) (optional, defaults to True)
:param cert: A client certificate to pass to requests. These are of the :param cert: A client certificate to pass to requests. These are of the
same form as requests expects. Either a single filename same form as requests expects. Either a single filename
@@ -171,6 +172,11 @@ class Session(object):
string_parts = ['curl -i'] string_parts = ['curl -i']
# NOTE(jamielennox): None means let requests do its default validation
# so we need to actually check that this is False.
if self.verify is False:
string_parts.append('--insecure')
if method: if method:
string_parts.extend(['-X', method]) string_parts.extend(['-X', method])

View File

@@ -16,6 +16,7 @@
import httpretty import httpretty
import mock import mock
import requests import requests
import six
from keystoneclient.auth import base from keystoneclient.auth import base
from keystoneclient import exceptions from keystoneclient import exceptions
@@ -141,6 +142,23 @@ class SessionTests(utils.TestCase):
self.assertRaises(exceptions.InternalServerError, self.assertRaises(exceptions.InternalServerError,
session.get, self.TEST_URL) session.get, self.TEST_URL)
@httpretty.activate
def test_session_debug_output(self):
session = client_session.Session(verify=False)
headers = {'HEADERA': 'HEADERVALB'}
body = 'BODYRESPONSE'
self.stub_url(httpretty.POST, body=body)
session.post(self.TEST_URL, headers=headers)
self.assertIn('curl', self.logger.output)
self.assertIn('POST', self.logger.output)
self.assertIn('--insecure', self.logger.output)
self.assertIn(body, self.logger.output)
for k, v in six.iteritems(headers):
self.assertIn(k, self.logger.output)
self.assertIn(v, self.logger.output)
class RedirectTests(utils.TestCase): class RedirectTests(utils.TestCase):

View File

@@ -12,9 +12,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import logging
import sys import sys
import time import time
import fixtures
import httpretty import httpretty
import mock import mock
from mox3 import mox from mox3 import mox
@@ -40,6 +42,7 @@ class TestCase(testtools.TestCase):
def setUp(self): def setUp(self):
super(TestCase, self).setUp() super(TestCase, self).setUp()
self.mox = mox.Mox() self.mox = mox.Mox()
self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
self.time_patcher = mock.patch.object(time, 'time', lambda: 1234) self.time_patcher = mock.patch.object(time, 'time', lambda: 1234)
self.time_patcher.start() self.time_patcher.start()