summaryrefslogtreecommitdiff
path: root/tests/test_http.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix the ordering of assertEqual argumentsLouis Taylor2014-09-191-4/+4
| | | | | | | | This keeps testtools happy, since it expects the argument ordering to be (expected, actual). Change-Id: I95b41ad7645700ce23b46c7a5700e79008ed08be Closes-bug: #1277104
* Handle UnicodeDecodeError in log_http_responseMatt Riedemann2014-09-151-0/+10
| | | | | | | | | Similar to commit dec9c9f35 and log_curl_request, this ignores decoding errors when logging response headers by passing errors='ignore' to safe_encode. Change-Id: Ic915a7d8334e9473f300c9db670a3a8f5cda8976 Closes-Bug: #1369756
* Replace old httpclient with requestsAmalaBasha2014-07-101-294/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This review implements blueprint python-request and replaces the old http client implementation in favor of a new one based on python-requests. Major changes: * raw_request and json_request removed since everything is now being handled by the same method "_request" * New methods that match HTTP's methods were added: - get - put - post - head - patch - delete * Content-Type is now being "inferred" based on the data being sent: - if it is file-like object it chunks the request - if it is a python type not instance of basestring then it'll try to serialize it to json - Every other case will keep the incoming content-type and will send the data as is. * Glanceclient's HTTPSConnection implementation will be used if no-compression flag is set to True. Co-Author: Flavio Percoco<flaper87@gmail.com> Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
* Change a debug line to prevent UnicodeDecodeError issueMichael Still2014-06-181-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | This debug line is causing tracebacks in the n-cpu logs for tempest runs. Its because the logged data is sometimes unicode: Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 846, in emit msg = self.format(record) File "/opt/stack/new/nova/nova/openstack/common/log.py", line 710, in format return logging.StreamHandler.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 723, in format return fmt.format(record) File "/opt/stack/new/nova/nova/openstack/common/log.py", line 674, in format return logging.Formatter.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 467, in format s = self._fmt % record.__dict__ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1234: ordinal not in range(128) Logged from file http.py, line 153 The change used correct encoding error handling policy for the log which may includes non-ascii char. Closes-bug: 1320655 Change-Id: I97f5f14b9beddcceb7fbd371062caf5a38a62a20
* Finalize Python3 supportFrederic Lepied2014-05-201-15/+19
| | | | | | | Set the environment variable PYTHONHASHSEED to 0 to have predictive tests under Python 3. Change-Id: Ia15a9383e0f20bd0e4572e9f9b9772f1704dff86
* Merge "Fix the parameter order of assertEqual in glanceclient test"Jenkins2014-04-211-19/+19
|\
| * Fix the parameter order of assertEqual in glanceclient testEiichi Aikawa2014-02-251-19/+19
| | | | | | | | | | | | | | | | | | On assertEqual, the order of parameters should be (expected, observed). But, some part of glanceclient test were written with invalid order. This patch fixes this problem. Change-Id: I7722fdce766ce3cc5bc9944dc72d7d0af0b09f69 Partially-bug: #1277104
* | Fix for invalid literal ValueError parsing ipv6 url(s)Davanum Srinivas2014-04-021-2/+2
|/ | | | | | | | Switch to using network_utils for splitting the URL. The code in oslo-incubator supports ipv6 urls Change-Id: I76be6173b97eb000319d30b4e9232a5a7c4a5aba Closes-Bug: #1298137
* Pass bytes to tempfile.NamedTemporaryFile().write()Cyril Roelandt2014-02-181-3/+3
| | | | | | | This method takes bytes as input; the current code fails in Python 3. Closes-Bug: #1281372 Change-Id: I070d9e9e07523c124f3168b55048fb9d1b338f69
* Add support for image size in v2 api uploadEdward Hope-Morley2014-02-031-0/+83
| | | | | | | | | | | | Some backend stores e.g. RBD, will fail if told to create an image without a valid size (RBD will fail to write to a zero-size image). Here we add support to allow the image size to be provided when doing an upload. The result is that the upload content-length will be set if available either from checking the supplied file object or as provided by user. Closes-Bug: 1220197 Change-Id: Ia1f2ea5680a139750d931591949b3e0058148b4b
* It was removed urllib, urllib2 & urlparse modulesVictor Morales2014-01-181-5/+5
| | | | | | | | Those modules have been combined in python 3. Therefore, implementing the six module helps to have support to both versions. Change-Id: I164a0f19790ff066d16d0cf4f0daa6f1097c848e Closes-Bug: #1267181
* python3: Switch to mox3 instead of moxDirk Mueller2014-01-161-1/+1
| | | | | | | | In order to transition to a python 3.x compatible world, lets switch to mox3 which is python 3.x compatible drop-in replacement of mox. Change-Id: Id971475f0e92900689d6784ffc55ae5fe63d9fe4
* Python3: use six.StringIO rather than StringIO.StringIOYassine Lamgarchal2014-01-101-11/+11
| | | | | | | It’s an alias for StringIO.StringIO in Python 2 and io.StringIO in Python 3. Change-Id: I5316eaffa2d9d2d5679b85a901933ef0fbfcc2f7
* Fix glanceclient http.py string formatting errorLe Tian Ren2014-01-071-0/+17
| | | | | | | | | * Fix "TypeError: not all arguments converted during string formatting" * Add a UT case to cover the path where the bug is in Change-Id: I91a137c5c3a9a3cc603804bef5eaea14ae281c08 Closes-Bug: #1265730
* Fix and enable gating on H306Dirk Mueller2013-12-161-1/+1
| | | | | | H306 - module imports should be in alphabetical order Change-Id: I1f8fc25b0e6ca23c21c90bda420f42a45141c2e2
* Merge "change assertEquals to assertEqual"Jenkins2013-11-151-2/+2
|\
| * change assertEquals to assertEqualChristian Berendt2013-10-241-2/+2
| | | | | | | | | | | | | | According to http://docs.python.org/2/library/unittest.html assertEquals is a deprecated alias of assertEqual. Change-Id: I22f4702f41537c05684dfacb3f305627b36849c5
* | Merge "Replace OpenStack LLC with OpenStack Foundation"Jenkins2013-11-151-1/+1
|\ \
| * | Replace OpenStack LLC with OpenStack FoundationZhiQiang Fan2013-09-201-1/+1
| | | | | | | | | | | | | | | Change-Id: I38dcbcf1a6c8efe540fcf5f29e782cb3826e583d Fixes-Bug: #1214176
* | | python3: use six.moves for httplib importsChuck Short2013-10-161-17/+17
| |/ |/| | | | | | | | | | | | | | | | | | | | | This adds six to the requirements.txt file in order to make some HTTP-related imports work across Python 2's httplib and Python 3's http.client modules. Tests were updated, including one change to the location of HTTPConnection - moving it from being accessed where it was imported rather than its canonical location inside of six.moves.http_client. Change-Id: Ibc4932b37dfdf195cd5091066914513af1876955 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* | Merge "Fix regression bug after removing posixpath in http.py"Jenkins2013-10-091-0/+28
|\ \
| * | Fix regression bug after removing posixpath in http.pyYang Yu2013-09-281-0/+28
| |/ | | | | | | | | | | | | | | | | | | | | After removing posixpath.normpath(url) in http.py, the code has a regression bug that the url like 'http://example.com:80/test' can not work. The code urlparse.urljoin() can not work as '%s%s' % (self.endpoint_path, url). Fixes bug #1230032 Change-Id: Ie7266fc3a067b92dfeed169086b4bf6a87dedbd6
* | Fix getting header in redirect processingRussell Bryant2013-09-261-0/+24
|/ | | | | | | | | | The code for processing an HTTP redirect included an incorrect method of getting the Location header from an HTTPResponse. It needs to use the getheader() method on the response, instead. This patch fixes that and includes a unit test that covers this code path. Change-Id: I0952fabad581b020dee07bdc4007b55b47c906aa Closes-Bug: #1231524
* Show a pretty progressbar when uploading and downloading an image.mouad benchchaoui2013-08-081-0/+35
| | | | | | | | | | | | Add a new module that contain generic wrapper for file and iterator, which are used to wrap image to upload and the request body iterator in upload and download cases repectively, to show and advance a pretty progress bar when this laters are consumed, The progress bar is triggered by adding a --progress command line argument to commands: image-create, image-download or image-update. Change-Id: I2ba42fd0c58f4fa087adb568ec3f08246cae3759 bug fix: LP#1112309 blueprint: progressbar-when-uploading
* Pass all identity headers received to glanceiccha.sethi2013-07-151-0/+33
| | | | | | | | | | | There is an upcoming patch in nova which passes identity headers to glance client. We want to ensure that these get passed to glance, which in turn with help the no auth option in glance. Resolves bug 1200761 Change-Id: Ifbef582aa4e64a2e7a46db43a9cc6cf8c3531dbd
* Start using Pyflakes and HackingDirk Mueller2013-06-221-1/+1
| | | | | | | | | | Instead of globally ignoring pyflakes and hacking warnings, only blacklist those that trigger very frequently so far, in order to clean them up in followup commits. Fix and start gating on the rest already. Change-Id: Ied7c7250061e3bf379e8286e8ce3b9e4af817faf
* Removes extra slash on endpoints without a pathKevin McDonald2013-06-191-0/+21
| | | | | Change-Id: I5ce54117c5ac276fb9629c71eb16db88e078c947 Fixes: bug #1179984
* Add tests for encodingsFlaper Fesp2013-06-031-0/+5
| | | | | | | | | The patch adds tests for headers encodings, incoming data decoding, outgoing meta encoding and filters encoding. Fixes bug: #1187013 Change-Id: I7e59bf6c44b9d188bd3faf32fc09f309f3ad67d3
* Improve Python 3.x compatibilityDirk Mueller2013-04-221-2/+2
| | | | | | | | Some mechanical translation of the deprecated except x,y construct. Should work with Python >= 2.6 just fine Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
* Improve unit tests for python-glanceclient.glanceclient.common.httpTatyana Leontovich2013-04-041-1/+57
| | | | | | | Add several tests for glanceclient.common.http module Fixes: bug #1149445 Change-Id: I6a47c64e11cefea276163777dcd559316fc8e0ad
* Report name resolution errors properlyStanislaw Pitucha2013-02-191-0/+42
| | | | | | | | | | | | | | Errors in name resolution have been logged previously with the url path rather than the hostname. That resulted in incorrect errors like: InvalidEndpoint: Error finding address for /v1/images/detail?is_public=none&limit=20: [Errno -2] Name or service not known rather than one mentioning hostname itself. This patch changes the log message to fit the situation. Change-Id: I1eecbcb22d41b1341c214937b9cbfd046fd301a0
* Decode input and encode outputFlaper Fesp2013-02-131-10/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently glanceclient doesn't support non-ASCII characters for images names and properties (names and values as well). This patch introduces 2 functions (utils.py) that will help encoding and decoding strings in a more "secure" way. About the ensure_(str|unicode) functions: They both try to use first the encoding used in stdin (or python's default encoding if that's None) and fallback to utf-8 if those encodings fail to decode a given text. About the changes in glanceclient: The major change is that all inputs will be decoded and will kept as such inside the client's functions and will then be encoded before being printed / sent out the client. There are other small changes, all related to encoding to str, around in order to avoid fails during some conversions. i.e: quoting url encoded parameters. Fixes bug: 1061150 Change-Id: I5c3ea93a716edfe284d19f6291d4e36028f91eb2
* Use testtools instead of unittest.Monty Taylor2013-01-021-3/+3
| | | | | | Part of blueprint grizzly-testtools Change-Id: Ie914fd8f59cddb1a480566ec4eff908bfb51921c
* Pin pep8 to 1.3.3Chuck Short2012-11-251-5/+5
| | | | | | | | Standardize pep8 to 1.3.3 and cleared up any errors found by pep8 tests. Change-Id: Ib7eb97d0789556d1676ccad58b5d3364065b7d15 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* Add happy path tests for ResponseBodyIteratorBrian Waldon2012-10-021-0/+10
| | | | Change-Id: I5e971b57a0591752e7fca76d0df78ce139308db5
* Make ConnectionRefused error more informative.Andrew Laski2012-09-121-0/+55
When the server refuses the connection the error message displayed now lists the endpoint that refused the connection. Fixes: bug 1043067 Change-Id: I62797106732bbb6eec8c99e491fd38850ad58ff8