Skip to content

Commit 0fe9482

Browse files
committed
fix(client config): merge from master client config to JWT token manager
1 parent 1243a70 commit 0fe9482

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
[![Build Status](https://travis-ci.com/IBM/python-sdk-core.svg?branch=master)](https://travis-ci.com/IBM/python-sdk-core)
22
[![codecov](https://codecov.io/gh/IBM/python-sdk-core/branch/master/graph/badge.svg)](https://codecov.io/gh/IBM/python-sdk-core)
33
[![Latest Stable Version](https://img.shields.io/pypi/v/ibm-cloud-sdk-core.svg)](https://pypi.python.org/pypi/ibm-cloud-sdk-core)
4+
[![CLA assistant](https://cla-assistant.io/readme/badge/ibm/python-sdk-core)](https://cla-assistant.io/ibm/python-sdk-core)
45

56
# python-sdk-core
67
This project contains the core functionality used by Python SDK's generated by the IBM OpenAPI 3 SDK Generator (openapi-sdkgen).
78
Python code generated by openapi-sdkgen will depend on the function contained in this project.
89

10+
# Notice
11+
Support for Python versions 2.x and versions <= 3.4 is deprecated and will be officially dropped in the next major release, which is expected to be end of September, 2019.
12+
913
## Installation
1014

1115
To install, use `pip` or `easy_install`:

ibm_cloud_sdk_core/base_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
import requests
2222
from requests.structures import CaseInsensitiveDict
2323
from .version import __version__
24-
from .utils import has_bad_first_or_last_char, remove_null_values, cleanup_values, read_external_sources
24+
from .utils import has_bad_first_or_last_char, remove_null_values, cleanup_values
2525
from .detailed_response import DetailedResponse
2626
from .api_exception import ApiException
2727
from .authenticators import Authenticator
28+
from .jwt_token_manager import JWTTokenManager
2829
from http.cookiejar import CookieJar
2930
import logging
3031

@@ -84,6 +85,8 @@ def set_http_config(self, http_config):
8485
"""
8586
if isinstance(http_config, dict):
8687
self.http_config = http_config
88+
if self.authenticator and hasattr(self.authenticator, 'token_manager') and isinstance(self.authenticator.token_manager, JWTTokenManager):
89+
self.authenticator.token_manager.http_config = http_config
8790
else:
8891
raise TypeError("http_config parameter must be a dictionary")
8992

ibm_cloud_sdk_core/jwt_token_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self, url, disable_ssl_verification=False, token_name=None):
3333
self.token_name = token_name
3434
self.token_info = {}
3535
self.time_for_new_token = None
36+
self.http_config = {}
3637

3738
def get_token(self):
3839
"""
@@ -118,6 +119,9 @@ def _request(self,
118119
data=None,
119120
auth_tuple=None,
120121
**kwargs):
122+
kwargs = dict({"timeout": 60}, **kwargs)
123+
kwargs = dict(kwargs, **self.http_config)
124+
121125
if self.disable_ssl_verification:
122126
kwargs['verify'] = False
123127

test/test_base_service.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,21 @@ def test_service_url_not_set():
463463
with pytest.raises(ValueError) as err:
464464
service.prepare_request('POST', url='')
465465
assert str(err.value) == 'The service_url is required'
466+
467+
468+
def test_setting_proxy():
469+
service = BaseService('test', authenticator=IAMAuthenticator('wonder woman'))
470+
assert service.authenticator is not None
471+
assert service.authenticator.token_manager.http_config == {}
472+
473+
http_config = {
474+
"proxies": {
475+
"http": "user:password@host:port"
476+
}
477+
}
478+
service.set_http_config(http_config)
479+
assert service.authenticator.token_manager.http_config == http_config
480+
481+
service2 = BaseService('test', authenticator=BasicAuthenticator('marvellous', 'mrs maisel'))
482+
service2.set_http_config(http_config)
483+
assert service2.authenticator is not None

0 commit comments

Comments
 (0)