summaryrefslogtreecommitdiff
path: root/ironicclient/tests/unit/common/test_http.py
Commit message (Collapse)AuthorAgeFilesLines
* Allow to pass additional arguments into adapterVladyslav Drok2020-05-151-0/+26
| | | | | | | | | | | This change allows to pass additional_headers and global_request_id to keystoneauth's Adapter constructor. Also SessionClient now makes use of them while doing HTTP requests (apart from version negotitaion requests). Story: 2007611 Task: 39602 Change-Id: I75cb9311bf44cbf7f6f8737d1d37b2be503be3f9
* Get rid of the oslo.serialization dependencyDmitry Tantsur2020-05-041-3/+3
| | | | | | | | | | | | | It was used to smoothen out the difference in handling bytes in Python 2 and 3. Now that we only support Python 3, it can be replaced. A side effect of this change is that we no longer accept bytes in JSON. JSON does not support bytes, but this problem has been hidden due to oslo.serialization until now. The configdrive handling has been updated to account for that. Change-Id: I230b55db55bce08d46f5023ad7a3f6501c96d100
* Use unittest.mock instead of third party mockSean McGinnis2020-04-301-1/+1
| | | | | | | | Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Change-Id: I805f5a4a901e410492c543c1857943ffd744ea35 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Check import orderRiccardo Pittau2020-04-211-2/+1
| | | | | | | | | | Restore pep 8check for import order. Set flake8-import-order version to 0.17.1 Full py3 compatible version. Add all Python3 modules to stdlib list. Also includes fix to an enum34 dependency bug. Change-Id: I989a84e362a18225c6f79580b22bb028d3e265ff
* Stop using six libraryRiccardo Pittau2019-12-181-1/+1
| | | | | | | | | | Since we've dropped support for Python 2.7, it's time to look at the bright future that Python 3.x will bring and stop forcing compatibility with older versions. This patch removes the six library from requirements, not looking back. Change-Id: I4b60638bb0268e5d1cf54fdf7d61964082536f4f
* Fix TypeError when using endpoint_override with SessionClientDmitry Tantsur2019-09-231-0/+7
| | | | | | | | | | | | First, when endpoint cannot be detected from a session None is returned from get_endpoint, causing subsequent code to fail. This changes fixes it. Second, endpoint_override is not passed to a Session (it's an Adapter) property, doing it has no effect. Use get_endpoint from Adapter instead. Change-Id: Ia942858abe980abf95c1ca136767983e7a0a285e Story: #2006600 Task: #36763
* Remove deprecated endpoint argumentRiccardo Pittau2019-08-211-61/+9
| | | | | | | | | | | Removing the endpoint argument to the v1.client.Client constructor. Please use the standard keystoneauth argument name endpoint_override instead. Change-Id: Ie2b26a667485223029fde05b20c39c5687f9e776 Story: 2006422 Task: 36319
* Remove deprecated common.http.HTTPClient classRiccardo Pittau2019-08-201-421/+0
| | | | | | | | | | | The class common.http.HTTPClient is deprecated and merked for removal in Stein. This patch removes it entirely, the class common.http.SessionClient should be used instead. Change-Id: I527d39d64c3ded9f61babcdf07d0492799b76fb9 Story: 2006422 Task: 36314
* Strip prefix when paginatingJim Rollenhagen2019-08-011-9/+10
| | | | | | | | | | | | The way the next URL is parsed and rebuilt in the pagination code doesn't take a prefixed path into account like devstack uses, e.g. /baremetal/v1/nodes. It ends up prepending the base URL and we get /baremetal/baremetal/v1/nodes. Drop the extra prefix when building this URL. Change-Id: I7e46068521c40f19c1e48eedc69b4ecd862e88fc Story: 2006216 Task: 35809
* Use endpoint_override in version negotiationJason2019-03-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | Change [1] introduced the usage of endpoint_filter when deciding which endpoint to use during version negotiation. This requires properly setting interface/region/service_type in order to properly pick the endpoint. But, sometimes (for example in Kolla-ansible), the endpoint url is explicitly defined. In the event of the endpoint being explicitly defined, it should take priority here. It should be noted that even though SessionClient extends from keystoneauth1's adapter.LegacyJsonAdapter, the `request` function within _make_simple_request is being called on the nested Session object, not the Adapter itself. If it was called on the Adapter this problem wouldn't exist, as the `endpoint_override` (or `endpoint`) kwarg passed in to the constructor of the SessionClient would already take precedence. [1]: I42b66daea1f4397273a3f4eb1638abafb3bb28ce Change-Id: I69dc2c88648ba1d09a9ad3ab3435662e8d1ea6ff Related-Bug: #1818295
* Replace assertRaisesRegexp with assertRaisesRegexChuck Short2018-08-271-4/+4
| | | | | | | | This replaces the deprecated (in python 3.2) unittest.TestCase method assertRaisesRegexp() with assertRaisesRegex(). Change-Id: Ibedff0f77b8f08fa30406586449b166e210409ce Signed-off-by: Chuck Short <chucks@redhat.com>
* Merge "Wire in header microversion into negotiation"Zuul2018-06-041-0/+41
|\
| * Wire in header microversion into negotiationJulia Kreger2018-05-311-0/+41
| | | | | | | | | | | | | | | | | | | | | | In order to properly error and prevent a user defined override version from being saved, we need to explicitly check and fail accordingly. Related-Bug: #1739440 Story: #2001870 Task: #14324 Change-Id: I281224b3de33b7c0c00ed777870df8002e23c4ea
* | Switch to none auth for standalone modeVladyslav Drok2018-05-071-0/+12
|/ | | | | | | | | | | | | | | | | | | | | | Currently, during the ironic shell client construction, if only os_auth_token and endpoint arguments are passed, custom HTTPClient class based on requests' sessions is used. This is unnecessary, as there is admin_token auth type in keystoneauth that does basically the same, eliminating the need for our custom implementation. Apart from that, there is a none auth, which requires only passing the desired endpoint to use, so we can use it too without having to specify fake token strings anymore. Let's use these auth methods instead and deprecate HTTPClient. Also this patch deprecates a bunch of arguments to client.get_client function, changing them to the standard keystoneauth naming. DocImpact Story: 1696791 Task: 11836 Depends-On: https://review.openstack.org/559116 Change-Id: Ifc7b45d047c8882a41021e1604b74d17eac2e6e8
* Minor changes to version negotiation logicJulia Kreger2018-03-121-1/+1
| | | | | | | Address review comments from change set I0dfa3f7fe0a1e2aaf31d37c46b65cc6c064b5e86 Change-Id: I4f2d34d9348f6f778e14ef346d03dd65f5ef1552
* Allow API user to define list of versionsJulia Kreger2018-01-181-0/+95
| | | | | | | | | | | | | | | | In cases where one may need to support multiple API micro-versions, it makes sense to allow a user to submit the list of versions their code can support, as long as they have the visibility into that version. Adds the ability to pass in a list to the os_ironic_api_version value during client initialization, and facilitate the negotiation of the highest available version. Change-Id: I0dfa3f7fe0a1e2aaf31d37c46b65cc6c064b5e86 Related-Bug: #1739440 Related-Bug: #1671145
* Facilitate latest Rest API useJulia Kreger2018-01-181-0/+23
| | | | | | | | | | | | | | | | | | | In order to provide insight into the remote API verison, we need the ability to negotiate upon the latest API version available, and then report what that version is. In order to understand if this has occured, we also need to provide insight into if version negotiation has occured. Adds logic to the session/http clients to faciltate version negotiation on the latest available version, and provide user insight into that verison. Change-Id: I813237eee4b122211f95558f677b25e0675569d5 Related-Bug: #1739440 Related-Bug: #1671145
* Use StrictVersion to compare versionsHironori Shiina2018-01-111-0/+17
| | | | | | | StrictVersion should be used to compare versions in version negotiation. This patch fixes a code not using StrictVersion. Change-Id: I3907419ecada98e8433e8f139a1cd0ade8a06b52
* Pass missing arguments to session in SessionClient._make_session_requestDmitry Tantsur2017-11-031-0/+17
| | | | | | | | If a server does not return API version headers, this will make the fallback to /v1 work correctly. Change-Id: I42b66daea1f4397273a3f4eb1638abafb3bb28ce Closes-Bug: #1726870
* Do not use urljoin in base http clientPavlo Shchelokovskyy2017-10-061-2/+3
| | | | | | | | | | | | | | | | | this fails when ironic API endpoint is not in the form "host:port", but "host/vhost" instead (as when ironic-api is deployed behind Apache), since the 'vhost' gets swallowed by 'urljoin'. This leads to a failure when using ironicclient with token and endpoint passed in, otherwise a SessionClient is used that does not have this problem. Simply concat those url parts together (ensuring there is at least a single '/' between them). Change-Id: I583e0f9bdc81a655861c6ff508782173021428f0 Closes-Bug: #1721599
* Print pecan exceptions properlyVladyslav Drok2017-02-101-5/+34
| | | | | | | | | | Exceptions raised by pecan (for example the ones happening in _lookup methods of ironic controllers) are not properly handled, as the fields that contain the error details are different from wsme raised exceptions. This change fixes it. Closes-Bug: #1619471 Change-Id: I023870ed97d3e97df8ae67e7cec97d6fbf355e79
* Fix python3 compatibility when HTTP Error are returned1.8.0Marc Aubry2016-11-081-61/+73
| | | | | | | | | | | | | | | | When trying to contact Ironic with a bad token, Forbidden exception should be raised, in python3 a TypeError is raised due to json lib being unable do decode a bytes object. In order to be really python3 compatible, the json lib was replaced with oslo.serialization module jsontuils since it's the recommended migration to python3 guide. This is to ensure that data coming from the requests lib can be read even if it's not string any more but bytes. https://wiki.openstack.org/wiki/Python3 Change-Id: I27540f58e31817d4de604334bc4c62899d82f4cc Closes-Bug: #1629068
* Trivial: Remove useless spacesTang Chen2016-08-021-3/+3
| | | | Change-Id: I18a3796eb8ab4e3830581a93aeda117bbb479d61
* Fix py35 unit testsAnton Arefiev2016-07-081-61/+12
| | | | | | | | | | String representation of http_lib' status code differs in python 3.5 from previous versions, so remove error's string asserts. Also two tests that validate error message and traceback were removed. Closes-Bug: #1599796 Change-Id: Iacd26f01d93457e1026ca905f5fdad3dc809c74b
* Catch RetriableConnectionFailures from KAuth and retrySam Betts2016-06-021-0/+15
| | | | | | | | Some keystone auth failures are retriable, this patch ensures that when ironiclient retries are turned on, we also retry on those failures. Change-Id: I7181b2aa4c8d0cc3b5523cb913562bee2e1955a2 Closes-Bug: #1537076
* Set endpoint_override while doing session.requestVladyslav Drok2016-03-211-2/+43
| | | | | | | | | The recent refactor broke multi-region deployments by not using endpoint_override when doing _http_request in SessionClient. This change fixes it. Closes-bug: #1557105 Change-Id: I99cbcd34eeec1388a00d1a0d910dd5759191f954
* Use requests lib in HTTPClientAnton Arefiev2016-03-031-230/+227
| | | | | | | | | | | This change proposes switch to requests lib instead using HTTPConnection and VerifiedHTTPSConnection, requests lib is recommended for higher-level http client interface. Also HTTPConnection can't work with API server behind proxy. Change-Id: I0393aaf38e59bdfdefb0e00aaa514a3246bf639b Closes-Bug: 1500929
* Replace HTTP 'magic numbers' with constantsJohn L. Villalovos2016-02-041-42/+44
| | | | | | | | | Replace HTTP 'magic numbers' (also known as unnamed numerical constants) with constants provided by the http_client/httplib library. For example, use 'http_client.OK' instead of '200' Change-Id: I7fc70ec0c5fee128054c026a78671d07c48d5eaf
* Move ironicclient/common tests to their respective directoryLucas Alvares Gomes2016-01-061-0/+741
The structure of the tests directories should mimic the code repository, therefore this patch is moving the ironicclient/common tests to ironicclient/tests/unit/common. Change-Id: I1c63a72bc53df59f0618dae59e30c80c66c5e0d9