sumo-wrapper-python 1.0.17__tar.gz → 1.0.19__tar.gz

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.

Potentially problematic release.


This version of sumo-wrapper-python might be problematic. Click here for more details.

Files changed (46) hide show
  1. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/PKG-INFO +1 -1
  2. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/_auth_provider.py +28 -19
  3. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/_version.py +2 -2
  4. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
  5. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.github/workflows/build_docs.yaml +0 -0
  6. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.github/workflows/linting.yml +0 -0
  7. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.github/workflows/publish_release.yml +0 -0
  8. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.github/workflows/pytest.yml +0 -0
  9. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.gitignore +0 -0
  10. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.pre-commit-config.yaml +0 -0
  11. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/.readthedocs.yaml +0 -0
  12. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/CONTRIBUTING.md +0 -0
  13. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/LICENSE +0 -0
  14. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/README.md +0 -0
  15. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/SECURITY.md +0 -0
  16. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/Makefile +0 -0
  17. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/_static/equinor-logo.png +0 -0
  18. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/_static/equinor-logo2.jpg +0 -0
  19. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/_static/equinor_logo.jpg +0 -0
  20. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/_static/equinor_logo_only.jpg +0 -0
  21. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/_templates/layout.html +0 -0
  22. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/api.rst +0 -0
  23. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/conf.py +0 -0
  24. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/index.rst +0 -0
  25. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/make.bat +0 -0
  26. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/docs/sumo-wrapper-python.rst +0 -0
  27. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/pyproject.toml +0 -0
  28. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/setup.cfg +0 -0
  29. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/__init__.py +0 -0
  30. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/__init__.py +0 -0
  31. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/_blob_client.py +0 -0
  32. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/_decorators.py +0 -0
  33. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/_logging.py +0 -0
  34. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/_retry_strategy.py +0 -0
  35. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/config.py +0 -0
  36. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/login.py +0 -0
  37. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo/wrapper/sumo_client.py +0 -0
  38. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -0
  39. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
  40. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
  41. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
  42. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
  43. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/tests/conftest.py +0 -0
  44. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/tests/test_sumo_thin_client.py +0 -0
  45. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/tests/testdata/case.yml +0 -0
  46. {sumo_wrapper_python-1.0.17 → sumo_wrapper_python-1.0.19}/tests/testdata/surface.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sumo-wrapper-python
3
- Version: 1.0.17
3
+ Version: 1.0.19
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -29,6 +29,23 @@ def _maybe_nfs_exception(exception):
29
29
  )
30
30
 
31
31
 
32
+ def get_token_dir():
33
+ return os.path.join(os.path.expanduser("~"), ".sumo")
34
+
35
+
36
+ def get_token_path(resource_id, suffix, case_uuid=None):
37
+ if case_uuid is not None:
38
+ return os.path.join(
39
+ os.path.expanduser("~"),
40
+ ".sumo",
41
+ str(resource_id) + "+" + str(case_uuid) + suffix,
42
+ )
43
+ else:
44
+ return os.path.join(
45
+ os.path.expanduser("~"), ".sumo", str(resource_id) + suffix
46
+ )
47
+
48
+
32
49
  class AuthProvider:
33
50
  def __init__(self, resource_id):
34
51
  self._resource_id = resource_id
@@ -67,11 +84,13 @@ class AuthProvider:
67
84
  return {"Authorization": "Bearer " + token}
68
85
 
69
86
  def store_shared_access_key_for_case(self, case_uuid, token):
87
+ os.makedirs(get_token_dir(), mode=0o700, exist_ok=True)
70
88
  with open(
71
- get_token_path(self._resource_id + "+" + case_uuid, ".sharedkey"),
89
+ get_token_path(self._resource_id, ".sharedkey", case_uuid),
72
90
  "w",
73
91
  ) as f:
74
92
  f.write(token)
93
+ protect_token_cache(self._resource_id, ".sharedkey", case_uuid)
75
94
 
76
95
  pass
77
96
 
@@ -93,6 +112,7 @@ class AuthProviderAccessToken(AuthProvider):
93
112
  self._access_token = access_token
94
113
  payload = jwt.decode(access_token, options={"verify_signature": False})
95
114
  self._expires = payload["exp"]
115
+ self._resource_id = payload["aud"]
96
116
  return
97
117
 
98
118
  def get_token(self):
@@ -117,12 +137,6 @@ class AuthProviderRefreshToken(AuthProvider):
117
137
  pass
118
138
 
119
139
 
120
- def get_token_path(resource_id, suffix):
121
- return os.path.join(
122
- os.path.expanduser("~"), ".sumo", str(resource_id) + suffix
123
- )
124
-
125
-
126
140
  @tn.retry(
127
141
  retry=tn.retry_if_exception(_maybe_nfs_exception),
128
142
  stop=tn.stop_after_attempt(6),
@@ -176,8 +190,8 @@ def get_token_cache(resource_id, suffix):
176
190
  retry_error_callback=_return_last_value,
177
191
  before_sleep=_log_retry_info,
178
192
  )
179
- def protect_token_cache(resource_id, suffix):
180
- token_path = get_token_path(resource_id, suffix)
193
+ def protect_token_cache(resource_id, suffix, case_uuid=None):
194
+ token_path = get_token_path(resource_id, suffix, case_uuid)
181
195
 
182
196
  if sys.platform.startswith("linux") or sys.platform == "darwin":
183
197
  filemode = stat.filemode(os.stat(token_path).st_mode)
@@ -369,9 +383,9 @@ class AuthProviderSumoToken(AuthProvider):
369
383
  retry_error_callback=_return_last_value,
370
384
  before_sleep=_log_retry_info,
371
385
  )
372
- def __init__(self, resource_id):
373
- protect_token_cache(resource_id, ".sharedkey")
374
- token_path = get_token_path(resource_id, ".sharedkey")
386
+ def __init__(self, resource_id, case_uuid=None):
387
+ protect_token_cache(resource_id, ".sharedkey", case_uuid)
388
+ token_path = get_token_path(resource_id, ".sharedkey", case_uuid)
375
389
  with open(token_path, "r") as f:
376
390
  self._token = f.readline().strip()
377
391
  return
@@ -411,13 +425,8 @@ def get_auth_provider(
411
425
  if access_token:
412
426
  return AuthProviderAccessToken(access_token)
413
427
  # ELSE
414
- if case_uuid is not None and os.path.exists(
415
- get_token_path(resource_id + "+" + case_uuid, ".sharedkey")
416
- ):
417
- return AuthProviderSumoToken(resource_id + "+" + case_uuid)
418
- # ELSE
419
- if os.path.exists(get_token_path(resource_id, ".sharedkey")):
420
- return AuthProviderSumoToken(resource_id)
428
+ if os.path.exists(get_token_path(resource_id, ".sharedkey", case_uuid)):
429
+ return AuthProviderSumoToken(resource_id, case_uuid)
421
430
  # ELSE
422
431
  if os.path.exists(get_token_path(resource_id, ".token")):
423
432
  auth_silent = AuthProviderSilent(client_id, authority, resource_id)
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.0.17'
16
- __version_tuple__ = version_tuple = (1, 0, 17)
15
+ __version__ = version = '1.0.19'
16
+ __version_tuple__ = version_tuple = (1, 0, 19)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sumo-wrapper-python
3
- Version: 1.0.17
3
+ Version: 1.0.19
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License