port-ocean 0.11.0__py3-none-any.whl → 0.12.1__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.

Potentially problematic release.


This version of port-ocean might be problematic. Click here for more details.

@@ -47,37 +47,48 @@ class JQEntityProcessor(BaseEntityProcessor):
47
47
  pattern = "def env: {}; {} as $ENV | " + pattern
48
48
  return jq.compile(pattern)
49
49
 
50
+ @staticmethod
51
+ def _stop_iterator_handler(func: Any) -> Any:
52
+ """
53
+ Wrap the function to handle StopIteration exceptions.
54
+ Prevents StopIteration from stopping the thread and skipping further queue processing.
55
+ """
56
+
57
+ def inner() -> Any:
58
+ try:
59
+ return func()
60
+ except StopIteration:
61
+ return None
62
+
63
+ return inner
64
+
50
65
  async def _search(self, data: dict[str, Any], pattern: str) -> Any:
51
66
  try:
52
67
  loop = asyncio.get_event_loop()
53
68
  compiled_pattern = self._compile(pattern)
54
69
  func = compiled_pattern.input_value(data)
55
- return await loop.run_in_executor(None, func.first)
70
+ return await loop.run_in_executor(
71
+ None, self._stop_iterator_handler(func.first)
72
+ )
56
73
  except Exception as exc:
57
74
  logger.debug(
58
- f"Failed to search for pattern {pattern} in data {data}, {exc}"
75
+ f"Search failed for pattern '{pattern}' in data: {data}, Error: {exc}"
59
76
  )
60
77
  return None
61
78
 
62
79
  async def _search_as_bool(self, data: dict[str, Any], pattern: str) -> bool:
63
80
  loop = asyncio.get_event_loop()
64
- start_time = loop.time()
81
+
65
82
  compiled_pattern = self._compile(pattern)
66
83
  func = compiled_pattern.input_value(data)
67
- compile_time = loop.time() - start_time
68
- value = await loop.run_in_executor(None, func.first)
69
- execute_time = loop.time() - start_time - compile_time
70
- logger.debug(
71
- f"Search for pattern {execute_time:.2f} seconds, compile time {compile_time:.2f} seconds",
72
- pattern=pattern,
73
- compile_time=compile_time,
74
- execute_time=execute_time,
84
+
85
+ value = await loop.run_in_executor(
86
+ None, self._stop_iterator_handler(func.first)
75
87
  )
76
88
  if isinstance(value, bool):
77
89
  return value
78
-
79
90
  raise EntityProcessorException(
80
- f"Expected boolean value, got {type(value)} instead"
91
+ f"Expected boolean value, got value:{value} of type: {type(value)} instead"
81
92
  )
82
93
 
83
94
  async def _search_as_object(
@@ -21,7 +21,7 @@ secret_patterns = {
21
21
  "GitHub": r"[g|G][i|I][t|T][h|H][u|U][b|B].*['|\"][0-9a-zA-Z]{35,40}['|\"]",
22
22
  "Google Cloud Platform API Key": r"AIza[0-9A-Za-z\\-_]{35}",
23
23
  "Google Cloud Platform OAuth": r"[0-9]+-[0-9A-Za-z_]{32}\\.apps\\.googleusercontent\\.com",
24
- "Google (GCP) Service-account": r'"type": "service_account"',
24
+ "Google (GCP) Service-account": f'"type":{" "}"service_account"',
25
25
  "Google OAuth Access Token": r"ya29\\.[0-9A-Za-z\\-_]+",
26
26
  "Connection String": r"[a-zA-Z]+:\/\/[^/\s]+:[^/\s]+@[^/\s]+\/[^/\s]+",
27
27
  }
@@ -195,10 +195,45 @@ class TestJQEntityProcessor:
195
195
  pattern = ".foo"
196
196
  with pytest.raises(
197
197
  EntityProcessorException,
198
- match="Expected boolean value, got <class 'str'> instead",
198
+ match="Expected boolean value, got value:bar of type: <class 'str'> instead",
199
199
  ):
200
200
  await mocked_processor._search_as_bool(data, pattern)
201
201
 
202
+ @pytest.mark.parametrize(
203
+ "pattern, expected",
204
+ [
205
+ ('.parameters[] | select(.name == "not_exists") | .value', None),
206
+ (
207
+ '.parameters[] | select(.name == "parameter_name") | .value',
208
+ "parameter_value",
209
+ ),
210
+ (
211
+ '.parameters[] | select(.name == "another_parameter") | .value',
212
+ "another_value",
213
+ ),
214
+ ],
215
+ )
216
+ async def test_search_fails_on_stop_iteration(
217
+ self, mocked_processor: JQEntityProcessor, pattern: str, expected: Any
218
+ ) -> None:
219
+ data = {
220
+ "parameters": [
221
+ {"name": "parameter_name", "value": "parameter_value"},
222
+ {"name": "another_parameter", "value": "another_value"},
223
+ {"name": "another_parameter", "value": "another_value2"},
224
+ ]
225
+ }
226
+ result = await mocked_processor._search(data, pattern)
227
+ assert result == expected
228
+
229
+ async def test_return_a_list_of_values(
230
+ self, mocked_processor: JQEntityProcessor
231
+ ) -> None:
232
+ data = {"parameters": ["parameter_value", "another_value", "another_value2"]}
233
+ pattern = ".parameters"
234
+ result = await mocked_processor._search(data, pattern)
235
+ assert result == ["parameter_value", "another_value", "another_value2"]
236
+
202
237
  @pytest.mark.timeout(3)
203
238
  async def test_search_performance_10000(
204
239
  self, mocked_processor: JQEntityProcessor
@@ -1,9 +1,8 @@
1
- from os import environ, path
2
- from typing import Any, AsyncGenerator, Callable, List, Tuple, Union
1
+ from os import path
2
+ from typing import Any, Callable, List, Tuple
3
3
 
4
+ import pytest
4
5
  import pytest_asyncio
5
- from loguru import logger
6
- from pydantic import BaseModel
7
6
 
8
7
  from port_ocean.clients.port.client import PortClient
9
8
  from port_ocean.core.handlers.port_app_config.models import ResourceConfig
@@ -12,96 +11,19 @@ from port_ocean.tests.helpers.ocean_app import (
12
11
  get_integation_resource_configs,
13
12
  get_integration_ocean_app,
14
13
  )
14
+ from port_ocean.tests.helpers.smoke_test import (
15
+ SmokeTestDetails,
16
+ get_port_client_for_fake_integration,
17
+ get_smoke_test_details,
18
+ )
15
19
 
16
20
 
17
- def get_port_client_for_integration(
18
- client_id: str,
19
- client_secret: str,
20
- integration_identifier: str,
21
- integration_type: str,
22
- integration_version: str,
23
- base_url: Union[str, None],
24
- ) -> PortClient:
25
- return PortClient(
26
- base_url=base_url or "https://api.getport/io",
27
- client_id=client_id,
28
- client_secret=client_secret,
29
- integration_identifier=integration_identifier,
30
- integration_type=integration_type,
31
- integration_version=integration_version,
32
- )
33
-
34
-
35
- async def cleanup_integration(client: PortClient, blueprints: List[str]) -> None:
36
- for blueprint in blueprints:
37
- try:
38
- bp = await client.get_blueprint(blueprint)
39
- if bp is not None:
40
- migration_id = await client.delete_blueprint(
41
- identifier=blueprint, delete_entities=True
42
- )
43
- if migration_id:
44
- await client.wait_for_migration_to_complete(
45
- migration_id=migration_id
46
- )
47
- except Exception as bp_e:
48
- logger.info(f"Skipping missing blueprint ({blueprint}): {bp_e}")
49
- headers = await client.auth.headers()
50
- try:
51
- await client.client.delete(
52
- f"{client.auth.api_url}/integrations/{client.integration_identifier}",
53
- headers=headers,
54
- )
55
- except Exception as int_e:
56
- logger.info(
57
- f"Failed to delete integration ({client.integration_identifier}): {int_e}"
58
- )
59
-
60
-
61
- class SmokeTestDetails(BaseModel):
62
- integration_identifier: str
63
- blueprint_department: str
64
- blueprint_person: str
65
-
66
-
67
- @pytest_asyncio.fixture()
68
- async def port_client_for_fake_integration() -> (
69
- AsyncGenerator[Tuple[SmokeTestDetails, PortClient], None]
70
- ):
71
- blueprint_department = "fake-department"
72
- blueprint_person = "fake-person"
73
- integration_identifier = "smoke-test-integration"
74
- smoke_test_suffix = environ.get("SMOKE_TEST_SUFFIX")
75
- client_id = environ.get("PORT_CLIENT_ID")
76
- client_secret = environ.get("PORT_CLIENT_SECRET")
77
-
78
- if not client_secret or not client_id:
79
- assert False, "Missing port credentials"
80
-
81
- base_url = environ.get("PORT_BASE_URL")
82
- integration_version = "0.1.1-dev"
83
- integration_type = "smoke-test"
84
- if smoke_test_suffix is not None:
85
- integration_identifier = f"{integration_identifier}-{smoke_test_suffix}"
86
- blueprint_person = f"{blueprint_person}-{smoke_test_suffix}"
87
- blueprint_department = f"{blueprint_department}-{smoke_test_suffix}"
88
-
89
- client = get_port_client_for_integration(
90
- client_id,
91
- client_secret,
92
- integration_identifier,
93
- integration_type,
94
- integration_version,
95
- base_url,
96
- )
21
+ @pytest.fixture
22
+ def port_client_for_fake_integration() -> Tuple[SmokeTestDetails, PortClient]:
23
+ smoke_test_details = get_smoke_test_details()
24
+ port_client = get_port_client_for_fake_integration()
97
25
 
98
- smoke_test_details = SmokeTestDetails(
99
- integration_identifier=integration_identifier,
100
- blueprint_person=blueprint_person,
101
- blueprint_department=blueprint_department,
102
- )
103
- yield smoke_test_details, client
104
- await cleanup_integration(client, [blueprint_department, blueprint_person])
26
+ return smoke_test_details, port_client
105
27
 
106
28
 
107
29
  @pytest_asyncio.fixture
@@ -0,0 +1,31 @@
1
+ from typing import List
2
+
3
+ from loguru import logger
4
+
5
+ from port_ocean.clients.port.client import PortClient
6
+
7
+
8
+ async def cleanup_integration(client: PortClient, blueprints: List[str]) -> None:
9
+ for blueprint in blueprints:
10
+ try:
11
+ bp = await client.get_blueprint(blueprint)
12
+ if bp is not None:
13
+ migration_id = await client.delete_blueprint(
14
+ identifier=blueprint, delete_entities=True
15
+ )
16
+ if migration_id:
17
+ await client.wait_for_migration_to_complete(
18
+ migration_id=migration_id
19
+ )
20
+ except Exception as bp_e:
21
+ logger.info(f"Skipping missing blueprint ({blueprint}): {bp_e}")
22
+ headers = await client.auth.headers()
23
+ try:
24
+ await client.client.delete(
25
+ f"{client.auth.api_url}/integrations/{client.integration_identifier}",
26
+ headers=headers,
27
+ )
28
+ except Exception as int_e:
29
+ logger.info(
30
+ f"Failed to delete integration ({client.integration_identifier}): {int_e}"
31
+ )
@@ -0,0 +1,21 @@
1
+ from typing import Union
2
+
3
+ from port_ocean.clients.port.client import PortClient
4
+
5
+
6
+ def get_port_client_for_integration(
7
+ client_id: str,
8
+ client_secret: str,
9
+ integration_identifier: str,
10
+ integration_type: str,
11
+ integration_version: str,
12
+ base_url: Union[str, None],
13
+ ) -> PortClient:
14
+ return PortClient(
15
+ base_url=base_url or "https://api.getport/io",
16
+ client_id=client_id,
17
+ client_secret=client_secret,
18
+ integration_identifier=integration_identifier,
19
+ integration_type=integration_type,
20
+ integration_version=integration_version,
21
+ )
@@ -0,0 +1,82 @@
1
+ from os import environ
2
+ from port_ocean.clients.port.client import PortClient
3
+
4
+ from loguru import logger
5
+ from pydantic import BaseModel
6
+
7
+ from port_ocean.tests.helpers.integration import cleanup_integration
8
+ from port_ocean.tests.helpers.port_client import get_port_client_for_integration
9
+
10
+
11
+ class SmokeTestDetails(BaseModel):
12
+ integration_identifier: str
13
+ blueprint_department: str
14
+ blueprint_person: str
15
+ integration_type: str
16
+ integration_version: str
17
+
18
+
19
+ def get_smoke_test_details() -> SmokeTestDetails:
20
+ blueprint_department = "fake-department"
21
+ blueprint_person = "fake-person"
22
+ integration_identifier = "smoke-test-integration"
23
+ smoke_test_suffix = environ.get("SMOKE_TEST_SUFFIX")
24
+ if smoke_test_suffix is not None:
25
+ integration_identifier = f"{integration_identifier}-{smoke_test_suffix}"
26
+ blueprint_person = f"{blueprint_person}-{smoke_test_suffix}"
27
+ blueprint_department = f"{blueprint_department}-{smoke_test_suffix}"
28
+
29
+ return SmokeTestDetails(
30
+ integration_identifier=integration_identifier,
31
+ blueprint_person=blueprint_person,
32
+ blueprint_department=blueprint_department,
33
+ integration_version="0.1.4-dev",
34
+ integration_type="smoke-test",
35
+ )
36
+
37
+
38
+ async def cleanup_smoke_test() -> None:
39
+ smoke_test_details = get_smoke_test_details()
40
+ client_id = environ.get("PORT_CLIENT_ID")
41
+ client_secret = environ.get("PORT_CLIENT_SECRET")
42
+
43
+ if not client_secret or not client_id:
44
+ assert False, "Missing port credentials"
45
+
46
+ base_url = environ.get("PORT_BASE_URL")
47
+ client = get_port_client_for_integration(
48
+ client_id,
49
+ client_secret,
50
+ smoke_test_details.integration_identifier,
51
+ smoke_test_details.integration_type,
52
+ smoke_test_details.integration_version,
53
+ base_url,
54
+ )
55
+
56
+ logger.info("Cleaning up fake integration")
57
+ await cleanup_integration(
58
+ client,
59
+ [smoke_test_details.blueprint_department, smoke_test_details.blueprint_person],
60
+ )
61
+ logger.info("Cleaning up fake integration complete")
62
+
63
+
64
+ def get_port_client_for_fake_integration() -> PortClient:
65
+ smoke_test_details = get_smoke_test_details()
66
+ client_id = environ.get("PORT_CLIENT_ID")
67
+ client_secret = environ.get("PORT_CLIENT_SECRET")
68
+
69
+ if not client_secret or not client_id:
70
+ assert False, "Missing port credentials"
71
+
72
+ base_url = environ.get("PORT_BASE_URL")
73
+ client = get_port_client_for_integration(
74
+ client_id,
75
+ client_secret,
76
+ smoke_test_details.integration_identifier,
77
+ smoke_test_details.integration_type,
78
+ smoke_test_details.integration_version,
79
+ base_url,
80
+ )
81
+
82
+ return client
@@ -4,7 +4,7 @@ import pytest
4
4
 
5
5
  from port_ocean.clients.port.client import PortClient
6
6
  from port_ocean.clients.port.types import UserAgentType
7
- from port_ocean.tests.helpers.fixtures import SmokeTestDetails
7
+ from port_ocean.tests.helpers.smoke_test import SmokeTestDetails
8
8
 
9
9
 
10
10
  pytestmark = pytest.mark.smoke
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.11.0
3
+ Version: 0.12.1
4
4
  Summary: Port Ocean is a CLI tool for managing your Port projects.
5
5
  Home-page: https://app.getport.io
6
6
  Keywords: ocean,port-ocean,port
@@ -81,7 +81,7 @@ port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py,sha
81
81
  port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py,sha256=82BvU8t5w9uhsxX8hbnwuRPuWhW3cMeuT_5sVIkip1I,1550
82
82
  port_ocean/core/handlers/entity_processor/__init__.py,sha256=FvFCunFg44wNQoqlybem9MthOs7p1Wawac87uSXz9U8,156
83
83
  port_ocean/core/handlers/entity_processor/base.py,sha256=udR0w5TstTOS5xOfTjAZIEdldn4xr6Oyb3DylatYX3Q,1869
84
- port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=HQ3lnOqNITHxSn0_9TXZFaQYfMZvvPaJwnsvlNKGDKQ,8703
84
+ port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=EHxU5PxvGxKJn5gKRO01bMR9PmXM6NC_NZ1L2xqlQsI,8868
85
85
  port_ocean/core/handlers/port_app_config/__init__.py,sha256=8AAT5OthiVM7KCcM34iEgEeXtn2pRMrT4Dze5r1Ixbk,134
86
86
  port_ocean/core/handlers/port_app_config/api.py,sha256=6VbKPwFzsWG0IYsVD81hxSmfqtHUFqrfUuj1DBX5g4w,853
87
87
  port_ocean/core/handlers/port_app_config/base.py,sha256=4Nxt2g8voEIHJ4Y1Km5NJcaG2iSbCklw5P8-Kus7Y9k,3007
@@ -113,7 +113,7 @@ port_ocean/helpers/retry.py,sha256=IQ0RfQ2T5o6uoZh2WW2nrFH5TT6K_k3y2Im0HDp5j9Y,1
113
113
  port_ocean/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
114
  port_ocean/log/handlers.py,sha256=k9G_Mb4ga2-Jke9irpdlYqj6EYiwv0gEsh4TgyqqOmI,2853
115
115
  port_ocean/log/logger_setup.py,sha256=BaXt-mh9CVXhneh37H46d04lqOdIBixG1pFyGfotuZs,2328
116
- port_ocean/log/sensetive.py,sha256=wkyvkKMbyLTjZDSbvvLHL9bv4RvD0DPAyL3uWSttUOA,2916
116
+ port_ocean/log/sensetive.py,sha256=lVKiZH6b7TkrZAMmhEJRhcl67HNM94e56x12DwFgCQk,2920
117
117
  port_ocean/middlewares.py,sha256=9wYCdyzRZGK1vjEJ28FY_DkfwDNENmXp504UKPf5NaQ,2727
118
118
  port_ocean/ocean.py,sha256=Oe4H3kKtkj52uNO4Rd_47iY3MBdrTtshXZ_16q7A8bM,5071
119
119
  port_ocean/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -122,11 +122,14 @@ port_ocean/sonar-project.properties,sha256=X_wLzDOkEVmpGLRMb2fg9Rb0DxWwUFSvESId8
122
122
  port_ocean/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
123
  port_ocean/tests/clients/port/mixins/test_entities.py,sha256=A9myrnkLhKSQrnOLv1Zz2wiOVSxW65Q9RIUIRbn_V7w,1586
124
124
  port_ocean/tests/conftest.py,sha256=JXASSS0IY0nnR6bxBflhzxS25kf4iNaABmThyZ0mZt8,101
125
- port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py,sha256=fqhlLTFkP0SS12bqViYWgqayNGXWZhqpDSJObHVRnNg,9472
125
+ port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py,sha256=Yv03P-LDcJCKZ21exiTFrcT1eu0zn6Z954dilxrb52Y,10842
126
126
  port_ocean/tests/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
127
- port_ocean/tests/helpers/fixtures.py,sha256=hnHC1Heey1FwlCb0gt6smD5dAz0M3XOvi9HkRN71LZk,4152
127
+ port_ocean/tests/helpers/fixtures.py,sha256=blc4ZgPEkKOmmwT6GVxceS9r1ERUwSdOIBGxWFwvRyY,1398
128
+ port_ocean/tests/helpers/integration.py,sha256=_RxS-RHpu11lrbhUXYPZp862HLWx8AoD7iZM6iXN8rs,1104
128
129
  port_ocean/tests/helpers/ocean_app.py,sha256=Dp1bwEDhWsx_G-KVxOfJX1eVIS4168ajLu39wAY275g,1693
129
- port_ocean/tests/test_smoke.py,sha256=LI_P1ZN56d5_FJaFHwjsWjqm8adGTpjlkgdVVh0fbXg,2555
130
+ port_ocean/tests/helpers/port_client.py,sha256=5d6GNr8vNNSOkrz1AdOhxBUKuusr_-UPDP7AVpHasQw,599
131
+ port_ocean/tests/helpers/smoke_test.py,sha256=_9aJJFRfuGJEg2D2YQJVJRmpreS6gEPHHQq8Q01x4aQ,2697
132
+ port_ocean/tests/test_smoke.py,sha256=uix2uIg_yOm8BHDgHw2hTFPy1fiIyxBGW3ENU_KoFlo,2557
130
133
  port_ocean/utils/__init__.py,sha256=KMGnCPXZJbNwtgxtyMycapkDz8tpSyw23MSYT3iVeHs,91
131
134
  port_ocean/utils/async_http.py,sha256=arnH458TExn2Dju_Sy6pHas_vF5RMWnOp-jBz5WAAcE,1226
132
135
  port_ocean/utils/async_iterators.py,sha256=iw3cUHxfQm3zUSPdw2FmSXDU8E1Ppnys4TGhswNuQ8s,1569
@@ -137,8 +140,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
137
140
  port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
138
141
  port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
139
142
  port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
140
- port_ocean-0.11.0.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
141
- port_ocean-0.11.0.dist-info/METADATA,sha256=wyTAEI3z-dSpeCraOy7_SmwOLiwjjXrda5Y_LJA9kNE,6614
142
- port_ocean-0.11.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
143
- port_ocean-0.11.0.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
144
- port_ocean-0.11.0.dist-info/RECORD,,
143
+ port_ocean-0.12.1.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
144
+ port_ocean-0.12.1.dist-info/METADATA,sha256=HbzZAIo77FdVcf7OABIERqjeMGNUXWLAs1oMV7qWl30,6614
145
+ port_ocean-0.12.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
146
+ port_ocean-0.12.1.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
147
+ port_ocean-0.12.1.dist-info/RECORD,,