insightconnect-plugin-runtime 5.5.4__py3-none-any.whl → 5.6.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.
- insightconnect_plugin_runtime/clients/aws_client.py +1 -1
- insightconnect_plugin_runtime/exceptions.py +6 -0
- insightconnect_plugin_runtime/helper.py +2 -1
- {insightconnect_plugin_runtime-5.5.4.dist-info → insightconnect_plugin_runtime-5.6.0.dist-info}/METADATA +3 -1
- {insightconnect_plugin_runtime-5.5.4.dist-info → insightconnect_plugin_runtime-5.6.0.dist-info}/RECORD +9 -9
- {insightconnect_plugin_runtime-5.5.4.dist-info → insightconnect_plugin_runtime-5.6.0.dist-info}/WHEEL +1 -1
- tests/unit/test_exceptions.py +18 -1
- tests/unit/test_helpers.py +7 -1
- {insightconnect_plugin_runtime-5.5.4.dist-info → insightconnect_plugin_runtime-5.6.0.dist-info}/top_level.txt +0 -0
|
@@ -85,7 +85,7 @@ class PaginationHelper:
|
|
|
85
85
|
|
|
86
86
|
return is_paginated
|
|
87
87
|
|
|
88
|
-
def check_total_results(self, params, response:
|
|
88
|
+
def check_total_results(self, params, response: Dict[str, Any]) -> bool:
|
|
89
89
|
"""
|
|
90
90
|
Check if we have ran the AWS call too many times, eg params[max_keys] * max_pages = len response
|
|
91
91
|
:param params: parameters used within the ListObjectsv2 command
|
|
@@ -207,3 +207,9 @@ class PluginException(ConnectionTestException):
|
|
|
207
207
|
return "An error occurred during plugin execution!\n\n{cause} {assistance}".format(
|
|
208
208
|
cause=self.cause, assistance=self.assistance
|
|
209
209
|
)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class APIException(PluginException):
|
|
213
|
+
def __init__(self, cause=None, assistance=None, data=None, preset=None, status_code=None):
|
|
214
|
+
super().__init__(cause, assistance, data, preset)
|
|
215
|
+
self.status_code = status_code
|
|
@@ -243,7 +243,8 @@ def response_handler(
|
|
|
243
243
|
if hasattr(exception, "data") and data is not None:
|
|
244
244
|
exception.data = data
|
|
245
245
|
elif status_code_preset:
|
|
246
|
-
exception = PluginException(preset=status_code_preset
|
|
246
|
+
exception = PluginException(preset=status_code_preset)
|
|
247
|
+
exception.data = data
|
|
247
248
|
|
|
248
249
|
raise exception
|
|
249
250
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: insightconnect-plugin-runtime
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.6.0
|
|
4
4
|
Summary: InsightConnect Plugin Runtime
|
|
5
5
|
Home-page: https://github.com/rapid7/komand-plugin-sdk-python
|
|
6
6
|
Author: Rapid7 Integrations Alliance
|
|
@@ -211,6 +211,8 @@ contributed. Black is installed as a test dependency and the hook can be initial
|
|
|
211
211
|
after cloning this repository.
|
|
212
212
|
|
|
213
213
|
## Changelog
|
|
214
|
+
* 5.6.0 - Add APIException class for error handling | Fix error in response_handler where data of type Response was not correctly being returned
|
|
215
|
+
* 5.5.5 - Address bug with typing for type `Dict` in Python 3.8
|
|
214
216
|
* 5.5.4 - Support pagination parameters within AWS client.
|
|
215
217
|
* 5.5.3 - Adding in a new endpoint that can be called to run a task connection test
|
|
216
218
|
* 5.5.2 - Address bug with typing for type `List` in Python 3.8
|
|
@@ -3,8 +3,8 @@ insightconnect_plugin_runtime/action.py,sha256=8gsOONf7mzY83O3DNjCBIafk7C7acnf7m
|
|
|
3
3
|
insightconnect_plugin_runtime/cli.py,sha256=Pb-Janu-XfRlSXxPHh30OIquljWptrhhS51C3clJqh4,8939
|
|
4
4
|
insightconnect_plugin_runtime/connection.py,sha256=4bHHV2B0UFGsAtvLu1fiYQRwx7fissUakHPUyjLQO0E,2340
|
|
5
5
|
insightconnect_plugin_runtime/dispatcher.py,sha256=ru7njnyyWE1-oD-VbZJ-Z8tELwvDf69rM7Iezs4rbnw,1774
|
|
6
|
-
insightconnect_plugin_runtime/exceptions.py,sha256=
|
|
7
|
-
insightconnect_plugin_runtime/helper.py,sha256=
|
|
6
|
+
insightconnect_plugin_runtime/exceptions.py,sha256=Pvcdkx81o6qC2qU661x-DzNjuIMP82x52nPMSEqEo4s,8491
|
|
7
|
+
insightconnect_plugin_runtime/helper.py,sha256=kXUt_yq6-9_wMdCIkS1fC3dddE8uwH9tcRITXvrJHIM,31178
|
|
8
8
|
insightconnect_plugin_runtime/metrics.py,sha256=hf_Aoufip_s4k4o8Gtzz90ymZthkaT2e5sXh5B4LcF0,3186
|
|
9
9
|
insightconnect_plugin_runtime/plugin.py,sha256=s2YVyygPcNeXeDi3X_JmaCiLHXZWIqz4mlLJy6p7-UA,24904
|
|
10
10
|
insightconnect_plugin_runtime/schema.py,sha256=jTNc6KAMqFpaDVWrAYhkVC6e8I63P3X7uVlJkAr1hiY,583
|
|
@@ -18,7 +18,7 @@ insightconnect_plugin_runtime/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
|
18
18
|
insightconnect_plugin_runtime/api/endpoints.py,sha256=rqieWL71Eu0jIKrspizof4xSyp672xCQxbrQUYdpbbA,32560
|
|
19
19
|
insightconnect_plugin_runtime/api/schemas.py,sha256=jRmDrwLJTBl-iQOnyZkSwyJlCWg4eNjAnKfD9Eko4z0,2754
|
|
20
20
|
insightconnect_plugin_runtime/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
insightconnect_plugin_runtime/clients/aws_client.py,sha256=
|
|
21
|
+
insightconnect_plugin_runtime/clients/aws_client.py,sha256=qKldWkyETmVhfoXbMZY58FFaDas6B5Uqc0D1LJROf6M,21658
|
|
22
22
|
insightconnect_plugin_runtime/clients/oauth.py,sha256=bWtAGRMwdK4dw9vMPcw9usklyIHBDtZh55kMZ7sWROc,2453
|
|
23
23
|
insightconnect_plugin_runtime/data/input_message_schema.json,sha256=7_BcHi6UOBiVWGrrJHHn5IoddteXjL7GOKETdO9T2DE,1770
|
|
24
24
|
insightconnect_plugin_runtime/data/output_message_schema.json,sha256=Qya6U-NR5MfOlw4V98VpQzGBVq75eGMUQhI-j3yxOHI,1137
|
|
@@ -67,8 +67,8 @@ tests/unit/test_api.py,sha256=uZ1dWMmgQ-ZePYjmcZfjc-qOTJsjs20Wic0Uf4U12-8,4441
|
|
|
67
67
|
tests/unit/test_aws_action.py,sha256=eei4uPDx1Y8WcYgAWhiyqBYv5OOHGiZrCvajXC7RHdM,9597
|
|
68
68
|
tests/unit/test_custom_encoder.py,sha256=KLYyVOTq9MEkZXyhVHqjm5LVSW6uJS4Davgghsw9DGk,2207
|
|
69
69
|
tests/unit/test_endpoints.py,sha256=LuXOfLBu47rDjGa5YEsOwTZBEdvQdl_C6-r46oxWZA8,6401
|
|
70
|
-
tests/unit/test_exceptions.py,sha256=
|
|
71
|
-
tests/unit/test_helpers.py,sha256=
|
|
70
|
+
tests/unit/test_exceptions.py,sha256=Y4F-ij8WkEJkUU3mPvxlEchqE9NCdxDvR8bJzPVVNao,5328
|
|
71
|
+
tests/unit/test_helpers.py,sha256=_1jlU-h-GNY9MLQ8nV_or4zkTI911AmHKtvFyamKjfU,16297
|
|
72
72
|
tests/unit/test_metrics.py,sha256=PjjTrB9w7uQ2Q5UN-893-SsH3EGJuBseOMHSD1I004s,7979
|
|
73
73
|
tests/unit/test_oauth.py,sha256=nbFG0JH1x04ExXqSe-b5BGdt_hJs7DP17eUa6bQzcYI,2093
|
|
74
74
|
tests/unit/test_plugin.py,sha256=ZTNAZWwZhDIAbxkVuWhnz9FzmojbijgMmsLWM2mXQI0,4160
|
|
@@ -78,7 +78,7 @@ tests/unit/test_server_spec.py,sha256=je97BaktgK0Fiz3AwFPkcmHzYtOJJNqJV_Fw5hrvqX
|
|
|
78
78
|
tests/unit/test_trigger.py,sha256=E53mAUoVyponWu_4IQZ0IC1gQ9lakBnTn_9vKN2IZfg,1692
|
|
79
79
|
tests/unit/test_variables.py,sha256=OUEOqGYZA3Nd5oKk5GVY3hcrWKHpZpxysBJcO_v5gzs,291
|
|
80
80
|
tests/unit/utils.py,sha256=VooVmfpIgxmglNdtmT32AkEDFxHxyRHLK8RsCWjjYRY,2153
|
|
81
|
-
insightconnect_plugin_runtime-5.
|
|
82
|
-
insightconnect_plugin_runtime-5.
|
|
83
|
-
insightconnect_plugin_runtime-5.
|
|
84
|
-
insightconnect_plugin_runtime-5.
|
|
81
|
+
insightconnect_plugin_runtime-5.6.0.dist-info/METADATA,sha256=5zYfXPKpqKNmeylm7-7KdhwXgujAZ3mmfxQTiEpjeJ8,13988
|
|
82
|
+
insightconnect_plugin_runtime-5.6.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
83
|
+
insightconnect_plugin_runtime-5.6.0.dist-info/top_level.txt,sha256=AJtyJOpiFzHxsbHUICTcUKXyrGQ3tZxhrEHsPjJBvEA,36
|
|
84
|
+
insightconnect_plugin_runtime-5.6.0.dist-info/RECORD,,
|
tests/unit/test_exceptions.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from insightconnect_plugin_runtime.exceptions import PluginException
|
|
1
|
+
from insightconnect_plugin_runtime.exceptions import PluginException, APIException
|
|
2
2
|
from unittest import TestCase
|
|
3
3
|
|
|
4
4
|
|
|
@@ -85,3 +85,20 @@ class TestExceptions(TestCase):
|
|
|
85
85
|
raise (PluginException(preset=test_data.get("preset")))
|
|
86
86
|
assert context.exception.cause == test_data.get("expected_cause")
|
|
87
87
|
assert context.exception.assistance == test_data.get("expected_assistance")
|
|
88
|
+
|
|
89
|
+
def test_api_exception(self):
|
|
90
|
+
with self.assertRaises(APIException) as context:
|
|
91
|
+
raise (
|
|
92
|
+
APIException(
|
|
93
|
+
preset=PluginException.Preset.NOT_FOUND,
|
|
94
|
+
status_code=404,
|
|
95
|
+
data="example",
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
assert context.exception.cause == "Invalid or unreachable endpoint provided."
|
|
99
|
+
assert (
|
|
100
|
+
context.exception.assistance
|
|
101
|
+
== "Verify the URLs or endpoints in your configuration are correct."
|
|
102
|
+
)
|
|
103
|
+
assert context.exception.data == "example"
|
|
104
|
+
assert context.exception.status_code == 404
|
tests/unit/test_helpers.py
CHANGED
|
@@ -439,7 +439,11 @@ class TestRequestsHelpers(TestCase):
|
|
|
439
439
|
):
|
|
440
440
|
request = requests.Request(method=method, url=url, json=None)
|
|
441
441
|
with self.assertRaises(PluginException) as error:
|
|
442
|
-
helper.make_request(
|
|
442
|
+
helper.make_request(
|
|
443
|
+
_request=request,
|
|
444
|
+
exception_custom_configs=exp_config,
|
|
445
|
+
exception_data_location=ResponseExceptionData.RESPONSE,
|
|
446
|
+
)
|
|
443
447
|
assert (isinstance(error, exception_type), True)
|
|
444
448
|
if test_name == "custom404":
|
|
445
449
|
self.assertEqual(
|
|
@@ -450,6 +454,8 @@ class TestRequestsHelpers(TestCase):
|
|
|
450
454
|
error.exception.assistance,
|
|
451
455
|
"CustomAssistance",
|
|
452
456
|
)
|
|
457
|
+
self.assertEqual(error.exception.data.text, "example")
|
|
458
|
+
self.assertEqual(error.exception.data.status_code, 404)
|
|
453
459
|
|
|
454
460
|
@parameterized.expand(
|
|
455
461
|
[
|
|
File without changes
|