Skip to content

Commit 1a2fb83

Browse files
authored
Fix settings.integration_events() to request the events path (#131)
* Request the events path in settings.integration_events() The method requested orgs/{org}/settings/integrations/{id}, which has no GET route, so it always failed. The events listing lives under /events and checks integration:list. * Type integration_events() as the list the endpoint returns GET .../integrations/{integration_id}/events answers with a bare JSON array of events. The method was annotated -> dict and fell back to {}, and its test mocked a {"results": [...]} wrapper the API never sends. The annotation and fallback are now a list, and the fixture has the shape of a real event.
1 parent 58ef060 commit 1a2fb83

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 3.6.3
4+
5+
### Fixed: `settings.integration_events()` requested the wrong path
6+
7+
- `settings.integration_events()` now calls
8+
`GET orgs/{org_slug}/settings/integrations/{integration_id}/events`. It
9+
previously requested the integration's own path, which has no `GET` route,
10+
so the method always failed. It needs the `integration:list` scope.
11+
- Its return annotation is now `list`, matching the JSON array the endpoint
12+
returns.
13+
314
## 3.6.2
415

516
### Fixed: reject retired API credentials before use

‎socketdev/settings/__init__.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,25 @@ def get(
108108
)
109109
return {}
110110

111-
def integration_events(self, org_slug: str, integration_id: str) -> dict:
111+
def integration_events(self, org_slug: str, integration_id: str) -> list:
112112
"""Get integration events for a specific integration.
113113
114114
Args:
115115
org_slug: Organization slug
116116
integration_id: Integration ID
117+
118+
Returns:
119+
The integration's events, as the list the API returns.
117120
"""
118-
path = f"orgs/{org_slug}/settings/integrations/{integration_id}"
121+
path = f"orgs/{org_slug}/settings/integrations/{integration_id}/events"
119122
response = self.api.do_request(path=path)
120123

121124
if response.status_code == 200:
122125
return response.json()
123126

124127
error_message = response.json().get("error", {}).get("message", "Unknown error")
125128
log.error(f"Error getting integration events: {response.status_code}, message: {error_message}")
126-
return {}
129+
return []
127130

128131
def get_license_policy(self, org_slug: str) -> dict:
129132
"""Get license policy settings for an organization.

‎socketdev/version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.6.2"
1+
__version__ = "3.6.3"

‎tests/unit/test_all_endpoints_unit.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,33 @@ def test_settings_get_unit(self):
736736
self.assertEqual(call_args[0][0], "GET")
737737
self.assertIn("/orgs/test-org/settings", call_args[0][1])
738738

739+
def test_settings_integration_events_unit(self):
740+
"""Test integration events retrieval."""
741+
expected_data = [
742+
{
743+
"id": "event-1",
744+
"integration_id": "integration-1",
745+
"type": "alert",
746+
"payload": {},
747+
"status_code": 200,
748+
"error": "",
749+
"sent_at": "2026-01-01T00:00:00.000Z",
750+
"retry_info": [],
751+
"created_at": "2026-01-01T00:00:00.000Z",
752+
"updated_at": "2026-01-01T00:00:00.000Z",
753+
}
754+
]
755+
self._mock_response(expected_data)
756+
757+
result = self.sdk.settings.integration_events("test-org", "integration-1")
758+
759+
self.assertEqual(result, expected_data)
760+
call_args = self.mock_requests.request.call_args
761+
self.assertEqual(call_args[0][0], "GET")
762+
self.assertTrue(
763+
call_args[0][1].endswith("/orgs/test-org/settings/integrations/integration-1/events")
764+
)
765+
739766
# Triage endpoints
740767
def test_triage_list_alert_triage_unit(self):
741768
"""Test alert triage listing."""

0 commit comments

Comments
 (0)