ibm-cloud-sdk-core 3.16.0__py3-none-any.whl → 3.21.0__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 (58) 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 +12 -7
  6. ibm_cloud_sdk_core/authenticators/bearer_token_authenticator.py +7 -2
  7. ibm_cloud_sdk_core/authenticators/container_authenticator.py +25 -16
  8. ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py +38 -23
  9. ibm_cloud_sdk_core/authenticators/iam_authenticator.py +22 -13
  10. ibm_cloud_sdk_core/authenticators/iam_request_based_authenticator.py +10 -8
  11. ibm_cloud_sdk_core/authenticators/mcsp_authenticator.py +134 -0
  12. ibm_cloud_sdk_core/authenticators/vpc_instance_authenticator.py +12 -11
  13. ibm_cloud_sdk_core/base_service.py +137 -103
  14. ibm_cloud_sdk_core/detailed_response.py +21 -15
  15. ibm_cloud_sdk_core/get_authenticator.py +35 -17
  16. ibm_cloud_sdk_core/http_adapter.py +28 -0
  17. ibm_cloud_sdk_core/logger.py +85 -0
  18. ibm_cloud_sdk_core/private_helpers.py +34 -0
  19. ibm_cloud_sdk_core/token_managers/container_token_manager.py +63 -33
  20. ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py +35 -22
  21. ibm_cloud_sdk_core/token_managers/iam_request_based_token_manager.py +50 -21
  22. ibm_cloud_sdk_core/token_managers/iam_token_manager.py +24 -13
  23. ibm_cloud_sdk_core/token_managers/jwt_token_manager.py +3 -16
  24. ibm_cloud_sdk_core/token_managers/mcsp_token_manager.py +108 -0
  25. ibm_cloud_sdk_core/token_managers/token_manager.py +20 -23
  26. ibm_cloud_sdk_core/token_managers/vpc_instance_token_manager.py +37 -18
  27. ibm_cloud_sdk_core/utils.py +127 -48
  28. ibm_cloud_sdk_core/version.py +1 -1
  29. ibm_cloud_sdk_core-3.21.0.dist-info/METADATA +159 -0
  30. ibm_cloud_sdk_core-3.21.0.dist-info/RECORD +35 -0
  31. {ibm_cloud_sdk_core-3.16.0.dist-info → ibm_cloud_sdk_core-3.21.0.dist-info}/WHEEL +1 -1
  32. ibm_cloud_sdk_core-3.21.0.dist-info/top_level.txt +1 -0
  33. ibm_cloud_sdk_core-3.16.0.dist-info/METADATA +0 -112
  34. ibm_cloud_sdk_core-3.16.0.dist-info/RECORD +0 -52
  35. ibm_cloud_sdk_core-3.16.0.dist-info/top_level.txt +0 -3
  36. ibm_cloud_sdk_core-3.16.0.dist-info/zip-safe +0 -1
  37. test/__init__.py +0 -0
  38. test/test_api_exception.py +0 -73
  39. test/test_authenticator.py +0 -21
  40. test/test_base_service.py +0 -933
  41. test/test_basic_authenticator.py +0 -36
  42. test/test_bearer_authenticator.py +0 -28
  43. test/test_container_authenticator.py +0 -105
  44. test/test_container_token_manager.py +0 -283
  45. test/test_cp4d_authenticator.py +0 -171
  46. test/test_cp4d_token_manager.py +0 -56
  47. test/test_detailed_response.py +0 -57
  48. test/test_iam_authenticator.py +0 -157
  49. test/test_iam_token_manager.py +0 -362
  50. test/test_jwt_token_manager.py +0 -109
  51. test/test_no_auth_authenticator.py +0 -15
  52. test/test_token_manager.py +0 -84
  53. test/test_utils.py +0 -634
  54. test/test_vpc_instance_authenticator.py +0 -66
  55. test/test_vpc_instance_token_manager.py +0 -266
  56. test_integration/__init__.py +0 -0
  57. test_integration/test_cp4d_authenticator_integration.py +0 -45
  58. {ibm_cloud_sdk_core-3.16.0.dist-info → ibm_cloud_sdk_core-3.21.0.dist-info}/LICENSE +0 -0
@@ -1 +0,0 @@
1
-
test/__init__.py DELETED
File without changes
@@ -1,73 +0,0 @@
1
- # coding=utf-8
2
- import json
3
-
4
- import requests
5
- import responses
6
-
7
- from ibm_cloud_sdk_core import ApiException
8
-
9
-
10
- @responses.activate
11
- def test_api_exception():
12
- """Test APIException class"""
13
- responses.add(responses.GET,
14
- 'https://test.com',
15
- status=500,
16
- body=json.dumps({'error': 'sorry', 'msg': 'serious error'}),
17
- content_type='application/json')
18
-
19
- mock_response = requests.get('https://test.com')
20
- exception = ApiException(500, http_response=mock_response)
21
- assert exception is not None
22
- assert exception.message == 'sorry'
23
-
24
- responses.add(responses.GET,
25
- 'https://test-again.com',
26
- status=500,
27
- body=json.dumps({
28
- "errors": [
29
- {
30
- "message": "sorry again",
31
- }],
32
- }),
33
- content_type='application/json')
34
- mock_response = requests.get('https://test-again.com')
35
- exception = ApiException(500, http_response=mock_response)
36
- assert exception.message == 'sorry again'
37
-
38
- responses.add(responses.GET,
39
- 'https://test-once-more.com',
40
- status=500,
41
- body=json.dumps({'message': 'sorry once more'}),
42
- content_type='application/json')
43
- mock_response = requests.get('https://test-once-more.com')
44
- exception = ApiException(500, http_response=mock_response)
45
- assert exception.message == 'sorry once more'
46
-
47
- responses.add(responses.GET,
48
- 'https://test-msg.com',
49
- status=500,
50
- body=json.dumps({'msg': 'serious error'}),
51
- content_type='application/json')
52
- mock_response = requests.get('https://test-msg.com')
53
- exception = ApiException(500, http_response=mock_response)
54
- assert exception.message == 'Internal Server Error'
55
-
56
- responses.add(responses.GET,
57
- 'https://test-errormessage.com',
58
- status=500,
59
- body=json.dumps({'errorMessage': 'IAM error message'}),
60
- content_type='application/json')
61
- mock_response = requests.get('https://test-errormessage.com')
62
- exception = ApiException(500, http_response=mock_response)
63
- assert exception.message == 'IAM error message'
64
-
65
- responses.add(responses.GET,
66
- 'https://test-for-text.com',
67
- status=500,
68
- headers={'X-Global-Transaction-ID': 'xx'},
69
- body="plain text error")
70
- mock_response = requests.get('https://test-for-text.com')
71
- exception = ApiException(500, http_response=mock_response)
72
- assert exception.message == 'plain text error'
73
- assert str(exception) == 'Error: plain text error, Code: 500 , X-global-transaction-id: xx'
@@ -1,21 +0,0 @@
1
- # coding=utf-8
2
- # pylint: disable=missing-docstring
3
-
4
- from requests import Request
5
- from ibm_cloud_sdk_core.authenticators import Authenticator
6
-
7
-
8
- class TestAuthenticator(Authenticator):
9
- """A test of the Authenticator base class"""
10
-
11
- def validate(self) -> None:
12
- """Simulated validate() method."""
13
-
14
- def authenticate(self, req: Request) -> None:
15
- """Simulated authenticate() method."""
16
-
17
-
18
- def test_authenticator():
19
- authenticator = TestAuthenticator()
20
- assert authenticator is not None
21
- assert authenticator.authentication_type() == Authenticator.AUTHTYPE_UNKNOWN