ibm-cloud-sdk-core 3.16.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.
Files changed (56) hide show
  1. ibm_cloud_sdk_core/__init__.py +1 -0
  2. ibm_cloud_sdk_core/api_exception.py +18 -4
  3. ibm_cloud_sdk_core/authenticators/__init__.py +1 -0
  4. ibm_cloud_sdk_core/authenticators/authenticator.py +2 -1
  5. ibm_cloud_sdk_core/authenticators/basic_authenticator.py +5 -6
  6. ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py +1 -1
  7. ibm_cloud_sdk_core/authenticators/container_authenticator.py +25 -16
  8. ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py +33 -21
  9. ibm_cloud_sdk_core/authenticators/iam_authenticator.py +22 -13
  10. ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py +5 -7
  11. ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py +130 -0
  12. ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py +7 -10
  13. ibm_cloud_sdk_core/base_service.py +107 -91
  14. ibm_cloud_sdk_core/detailed_response.py +21 -15
  15. ibm_cloud_sdk_core/get_authenticator.py +28 -16
  16. ibm_cloud_sdk_core/http_adapter.py +28 -0
  17. ibm_cloud_sdk_core/private_helpers.py +34 -0
  18. ibm_cloud_sdk_core/token_managers/container_token_manager.py +61 -30
  19. ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py +30 -22
  20. ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py +43 -20
  21. ibm_cloud_sdk_core/token_managers/iam_token_manager.py +24 -13
  22. ibm_cloud_sdk_core/token_managers/jwt_token_manager.py +3 -16
  23. ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py +102 -0
  24. ibm_cloud_sdk_core/token_managers/token_manager.py +13 -23
  25. ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py +33 -13
  26. ibm_cloud_sdk_core/utils.py +121 -46
  27. ibm_cloud_sdk_core/version.py +1 -1
  28. {ibm_cloud_sdk_core-3.16.0.dist-info → ibm_cloud_sdk_core-3.20.6.dist-info}/METADATA +40 -28
  29. ibm_cloud_sdk_core-3.20.6.dist-info/RECORD +34 -0
  30. {ibm_cloud_sdk_core-3.16.0.dist-info → ibm_cloud_sdk_core-3.20.6.dist-info}/WHEEL +1 -1
  31. ibm_cloud_sdk_core-3.20.6.dist-info/top_level.txt +1 -0
  32. ibm_cloud_sdk_core-3.16.0.dist-info/RECORD +0 -52
  33. ibm_cloud_sdk_core-3.16.0.dist-info/top_level.txt +0 -3
  34. ibm_cloud_sdk_core-3.16.0.dist-info/zip-safe +0 -1
  35. test/__init__.py +0 -0
  36. test/test_api_exception.py +0 -73
  37. test/test_authenticator.py +0 -21
  38. test/test_base_service.py +0 -933
  39. test/test_basic_authenticator.py +0 -36
  40. test/test_bearer_authenticator.py +0 -28
  41. test/test_container_authenticator.py +0 -105
  42. test/test_container_token_manager.py +0 -283
  43. test/test_cp4d_authenticator.py +0 -171
  44. test/test_cp4d_token_manager.py +0 -56
  45. test/test_detailed_response.py +0 -57
  46. test/test_iam_authenticator.py +0 -157
  47. test/test_iam_token_manager.py +0 -362
  48. test/test_jwt_token_manager.py +0 -109
  49. test/test_no_auth_authenticator.py +0 -15
  50. test/test_token_manager.py +0 -84
  51. test/test_utils.py +0 -634
  52. test/test_vpc_instance_authenticator.py +0 -66
  53. test/test_vpc_instance_token_manager.py +0 -266
  54. test_integration/__init__.py +0 -0
  55. test_integration/test_cp4d_authenticator_integration.py +0 -45
  56. {ibm_cloud_sdk_core-3.16.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']
@@ -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