ibm-cloud-sdk-core 3.15.0__py3-none-any.whl → 3.20.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibm_cloud_sdk_core/__init__.py +1 -0
- ibm_cloud_sdk_core/api_exception.py +18 -4
- ibm_cloud_sdk_core/authenticators/__init__.py +1 -0
- ibm_cloud_sdk_core/authenticators/authenticator.py +3 -3
- ibm_cloud_sdk_core/authenticators/basic_authenticator.py +5 -6
- ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py +1 -1
- ibm_cloud_sdk_core/authenticators/container_authenticator.py +25 -16
- ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py +34 -20
- ibm_cloud_sdk_core/authenticators/iam_authenticator.py +22 -13
- ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py +5 -7
- ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py +130 -0
- ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py +7 -10
- ibm_cloud_sdk_core/base_service.py +113 -92
- ibm_cloud_sdk_core/detailed_response.py +21 -15
- ibm_cloud_sdk_core/get_authenticator.py +28 -16
- ibm_cloud_sdk_core/http_adapter.py +28 -0
- ibm_cloud_sdk_core/private_helpers.py +34 -0
- ibm_cloud_sdk_core/token_managers/container_token_manager.py +61 -30
- ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py +34 -21
- ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py +43 -20
- ibm_cloud_sdk_core/token_managers/iam_token_manager.py +24 -13
- ibm_cloud_sdk_core/token_managers/jwt_token_manager.py +3 -16
- ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py +102 -0
- ibm_cloud_sdk_core/token_managers/token_manager.py +13 -23
- ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py +33 -13
- ibm_cloud_sdk_core/utils.py +126 -32
- ibm_cloud_sdk_core/version.py +1 -1
- {ibm_cloud_sdk_core-3.15.0.dist-info → ibm_cloud_sdk_core-3.20.6.dist-info}/METADATA +39 -30
- ibm_cloud_sdk_core-3.20.6.dist-info/RECORD +34 -0
- {ibm_cloud_sdk_core-3.15.0.dist-info → ibm_cloud_sdk_core-3.20.6.dist-info}/WHEEL +1 -1
- ibm_cloud_sdk_core-3.20.6.dist-info/top_level.txt +1 -0
- ibm_cloud_sdk_core-3.15.0.dist-info/RECORD +0 -52
- ibm_cloud_sdk_core-3.15.0.dist-info/top_level.txt +0 -3
- ibm_cloud_sdk_core-3.15.0.dist-info/zip-safe +0 -1
- test/__init__.py +0 -0
- test/test_api_exception.py +0 -73
- test/test_authenticator.py +0 -21
- test/test_base_service.py +0 -925
- test/test_basic_authenticator.py +0 -36
- test/test_bearer_authenticator.py +0 -28
- test/test_container_authenticator.py +0 -105
- test/test_container_token_manager.py +0 -283
- test/test_cp4d_authenticator.py +0 -171
- test/test_cp4d_token_manager.py +0 -56
- test/test_detailed_response.py +0 -57
- test/test_iam_authenticator.py +0 -157
- test/test_iam_token_manager.py +0 -362
- test/test_jwt_token_manager.py +0 -109
- test/test_no_auth_authenticator.py +0 -15
- test/test_token_manager.py +0 -84
- test/test_utils.py +0 -634
- test/test_vpc_instance_authenticator.py +0 -66
- test/test_vpc_instance_token_manager.py +0 -266
- test_integration/__init__.py +0 -0
- test_integration/test_cp4d_authenticator_integration.py +0 -45
- {ibm_cloud_sdk_core-3.15.0.dist-info → ibm_cloud_sdk_core-3.20.6.dist-info}/LICENSE +0 -0
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# pylint: disable=missing-docstring
|
|
2
|
-
|
|
3
|
-
from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator, Authenticator
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_no_auth_authenticator():
|
|
7
|
-
authenticator = NoAuthAuthenticator()
|
|
8
|
-
assert authenticator is not None
|
|
9
|
-
assert authenticator.authentication_type() == Authenticator.AUTHTYPE_NOAUTH
|
|
10
|
-
|
|
11
|
-
authenticator.validate()
|
|
12
|
-
|
|
13
|
-
request = {'headers': {}}
|
|
14
|
-
authenticator.authenticate(request)
|
|
15
|
-
assert not request['headers']
|
test/test_token_manager.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
|
-
# Copyright 2020 IBM All Rights Reserved.
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
# pylint: disable=missing-docstring,protected-access,abstract-class-instantiated
|
|
18
|
-
from types import SimpleNamespace
|
|
19
|
-
from unittest import mock
|
|
20
|
-
|
|
21
|
-
import pytest
|
|
22
|
-
|
|
23
|
-
from ibm_cloud_sdk_core import ApiException
|
|
24
|
-
from ibm_cloud_sdk_core.token_managers.token_manager import TokenManager
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class MockTokenManager(TokenManager):
|
|
28
|
-
|
|
29
|
-
def request_token(self) -> None:
|
|
30
|
-
response = self._request(
|
|
31
|
-
method='GET',
|
|
32
|
-
url=self.url
|
|
33
|
-
)
|
|
34
|
-
return response
|
|
35
|
-
|
|
36
|
-
def _save_token_info(self, token_response: dict) -> None:
|
|
37
|
-
pass
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def test_abstract_class_instantiation():
|
|
41
|
-
with pytest.raises(TypeError) as err:
|
|
42
|
-
TokenManager(None)
|
|
43
|
-
assert str(err.value) == "Can't instantiate abstract class " \
|
|
44
|
-
"TokenManager with abstract methods " \
|
|
45
|
-
"_save_token_info, " \
|
|
46
|
-
"request_token"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def requests_request_spy(*args, **kwargs):
|
|
50
|
-
return SimpleNamespace(status_code=200, request_args=args, request_kwargs=kwargs)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@mock.patch('requests.request', side_effect=requests_request_spy)
|
|
54
|
-
def test_request_passes_disable_ssl_verification(request): # pylint: disable=unused-argument
|
|
55
|
-
mock_token_manager = MockTokenManager(url="https://example.com", disable_ssl_verification=True)
|
|
56
|
-
assert mock_token_manager.request_token().request_kwargs['verify'] is False
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def requests_request_error_mock(*args, **kwargs): # pylint: disable=unused-argument
|
|
60
|
-
return SimpleNamespace(status_code=300, headers={}, text="")
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@mock.patch('requests.request', side_effect=requests_request_error_mock)
|
|
64
|
-
def test_request_raises_for_non_2xx(request): # pylint: disable=unused-argument
|
|
65
|
-
mock_token_manager = MockTokenManager(url="https://example.com", disable_ssl_verification=True)
|
|
66
|
-
with pytest.raises(ApiException):
|
|
67
|
-
mock_token_manager.request_token()
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_set_disable_ssl_verification_success():
|
|
71
|
-
token_manager = MockTokenManager(None)
|
|
72
|
-
assert token_manager.disable_ssl_verification is False
|
|
73
|
-
|
|
74
|
-
token_manager.set_disable_ssl_verification(True)
|
|
75
|
-
assert token_manager.disable_ssl_verification is True
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def test_set_disable_ssl_verification_fail():
|
|
79
|
-
token_manager = MockTokenManager(None)
|
|
80
|
-
|
|
81
|
-
with pytest.raises(TypeError) as err:
|
|
82
|
-
token_manager.set_disable_ssl_verification('True')
|
|
83
|
-
assert str(err.value) == 'status must be a bool'
|
|
84
|
-
assert token_manager.disable_ssl_verification is False
|