:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse-sources): add jumpcloud membership and binding tables (#112549)
Tom Owers8dbb9cdb4b1d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 4560bd6a46e9..2f9076df0d5a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -4610,14 +4610,14 @@ Note: The OpenAPI 3.0 spec (served to ReDoc from https://judge.me/api/docs.yaml)## Jumpcloud — **thin**-Today (6): `applications`, `events`, `system_groups`, `systems`, `user_groups`, `users`+Today (11): `application_user_groups`, `application_users`, `applications`, `events`, `system_group_members`, `system_groups`, `system_users`, `systems`, `user_group_members`, `user_groups`, `users`Diffed against: <https://docs.jumpcloud.com/api/2.0/index.yaml>-- [ ] `/api/v2/usergroups/{group_id}/members (and /membership)` — the user-to-group edges; user_groups and users are synced but the join between them is not (high)-- [ ] `/api/v2/systemgroups/{group_id}/members (and /membership)` — the system-to-group edges completing the already-synced system_groups table (high)-- [ ] `/api/v2/systems/{system_id}/users (or /api/v2/users/{user_id}/systems)` — which users can log into which devices - the central access-review fact table (high)-- [ ] `/api/v2/applications/{application_id}/users and /usergroups` — SSO application entitlements per user and group, resolving the synced applications table (high)+- [x] `/api/v2/usergroups/{group_id}/members (and /membership)` — the user-to-group edges; user_groups and users are synced but the join between them is not (high)+- [x] `/api/v2/systemgroups/{group_id}/members (and /membership)` — the system-to-group edges completing the already-synced system_groups table (high)+- [x] `/api/v2/systems/{system_id}/users (or /api/v2/users/{user_id}/systems)` — which users can log into which devices - the central access-review fact table (high)+- [x] `/api/v2/applications/{application_id}/users and /usergroups` — SSO application entitlements per user and group, resolving the synced applications table (high)- [ ] `/api/v2/systeminsights/* (apps, programs, os_version, patches, disk_encryption, browser_plugins, chrome_extensions, ...)` — ~60 device inventory and compliance fact tables keyed by system_id - the richest analytical surface in the API (high)- [ ] `/api/v2/policies, /api/v2/policyresults, /api/v2/systems/{id}/policystatuses` — policy catalog plus per-device application results - device compliance state over time (high)- [ ] `/api/commands and /api/commandresults` — remote command execution history with exit codes and output (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/canonical_descriptions.pyindex 8d1f9a02cbb4..d541b31e6cd0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/canonical_descriptions.py@@ -80,6 +80,61 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"config": "Connector-specific configuration for the application.",},},+ "user_group_members": {+ "description": "Users that are members of each user group, one row per group and user.",+ "docs_url": "https://docs.jumpcloud.com/api/2.0/index.html#tag/User-Group-Members-&-Membership/operation/graph_userGroupMembership",+ "columns": {+ "group_id": "Identifier of the user group (joins to user_groups.id).",+ "id": "Identifier of the member user (joins to users._id).",+ "type": "Graph object type of the member.",+ "compiledAttributes": "Graph attributes compiled across every path to the member.",+ "paths": "Each path through the JumpCloud graph that connects the member, as a list of edges.",+ },+ },+ "system_group_members": {+ "description": "Systems that are members of each system group, one row per group and system.",+ "docs_url": "https://docs.jumpcloud.com/api/2.0/index.html#tag/System-Group-Members-&-Membership/operation/graph_systemGroupMembership",+ "columns": {+ "group_id": "Identifier of the system group (joins to system_groups.id).",+ "id": "Identifier of the member system (joins to systems._id).",+ "type": "Graph object type of the member.",+ "compiledAttributes": "Graph attributes compiled across every path to the member.",+ "paths": "Each path through the JumpCloud graph that connects the member, as a list of edges.",+ },+ },+ "application_users": {+ "description": "Users bound to each SSO application, directly or through a user group.",+ "docs_url": "https://docs.jumpcloud.com/api/2.0/index.html#tag/Applications/operation/graph_applicationTraverseUser",+ "columns": {+ "application_id": "Identifier of the application (joins to applications._id).",+ "id": "Identifier of the bound user (joins to users._id).",+ "type": "Graph object type of the member.",+ "compiledAttributes": "Graph attributes compiled across every path to the member.",+ "paths": "Each path through the JumpCloud graph that connects the member, as a list of edges.",+ },+ },+ "application_user_groups": {+ "description": "User groups bound to each SSO application.",+ "docs_url": "https://docs.jumpcloud.com/api/2.0/index.html#tag/Applications/operation/graph_applicationTraverseUserGroup",+ "columns": {+ "application_id": "Identifier of the application (joins to applications._id).",+ "id": "Identifier of the bound user group (joins to user_groups.id).",+ "type": "Graph object type of the member.",+ "compiledAttributes": "Graph attributes compiled across every path to the member.",+ "paths": "Each path through the JumpCloud graph that connects the member, as a list of edges.",+ },+ },+ "system_users": {+ "description": "Users bound to each system, directly or through a user or system group, so they can log in to it.",+ "docs_url": "https://docs.jumpcloud.com/api/2.0/index.html#tag/Systems/operation/graph_systemTraverseUser",+ "columns": {+ "system_id": "Identifier of the system (joins to systems._id).",+ "id": "Identifier of the bound user (joins to users._id).",+ "type": "Graph object type of the member.",+ "compiledAttributes": "Graph attributes compiled across every path to the member.",+ "paths": "Each path through the JumpCloud graph that connects the member, as a list of edges.",+ },+ },"events": {"description": "Directory Insights activity events across JumpCloud services: admin console actions, directory changes, SSO, RADIUS, LDAP, MDM, and agent-reported system events.","docs_url": "https://docs.jumpcloud.com/api/insights/directory/1.0/index.html",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/docs/jumpcloud.mdx b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/docs/jumpcloud.mdxindex 3798cd671453..885aa47aa642 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/docs/jumpcloud.mdx+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/docs/jumpcloud.mdx@@ -58,6 +58,11 @@ the last synced event timestamp. The directory tables (`users`, `systems`, `user`applications`) have no server-side "updated since" filter in JumpCloud's API, so they sync as a **fullrefresh** — schedule them at a cadence that fits how often your directory changes.+The association tables (`user_group_members`, `system_group_members`, `application_users`,+`application_user_groups`, and `system_users`) also sync as a full refresh. Each one requests JumpCloud once per+parent group, application, or system, so a large directory takes longer to sync. Join them to the directory tables+on the parent ID column (`group_id`, `application_id`, or `system_id`) and on `id`.+## Configuration<SourceParameters />diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/jumpcloud.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/jumpcloud.pyindex f71a81a21237..e005a8efec08 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/jumpcloud.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/jumpcloud.py@@ -3,7 +3,7 @@ import dataclassesfrom collections.abc import Iteratorfrom datetime import UTC, date, datetime, timedeltafrom typing import Any, Optional-from urllib.parse import urlencode+from urllib.parse import quote, urlencodeimport requestsfrom structlog.types import FilteringBoundLogger@@ -192,6 +192,33 @@ def _parse_search_after(raw: str | None, logger: FilteringBoundLogger) -> list[Areturn parsed+def _fetch_rest_page(+ session: requests.Session,+ base_url: str,+ path: str,+ config: JumpcloudEndpointConfig,+ skip: int,+ logger: FilteringBoundLogger,+) -> list[dict[str, Any]]:+ params: dict[str, Any] = {"limit": REST_PAGE_SIZE, "skip": skip}+ if config.sort:+ params["sort"] = config.sort+ url = f"{base_url}{path}?{urlencode(params)}"++ response = _request(session, "GET", url, logger)+ data = response.json()++ # v1 wraps rows as {"totalCount": n, "results": [...]}; v2 returns a bare array. Any+ # other 200 payload is a permanent API-contract violation, not a transient failure.+ if config.api == "v1":+ rows = data.get("results") if isinstance(data, dict) else None+ else:+ rows = data if isinstance(data, list) else None+ if not isinstance(rows, list):+ raise ValueError(f"JumpCloud API returned an unexpected response shape: url={url}")+ return rows++def _get_rest_rows(session: requests.Session,base_url: str,@@ -206,22 +233,7 @@ def _get_rest_rows(logger.debug(f"JumpCloud: resuming {config.name} from skip={skip}")while True:- params: dict[str, Any] = {"limit": REST_PAGE_SIZE, "skip": skip}- if config.sort:- params["sort"] = config.sort- url = f"{base_url}{config.path}?{urlencode(params)}"-- response = _request(session, "GET", url, logger)- data = response.json()-- # v1 wraps rows as {"totalCount": n, "results": [...]}; v2 returns a bare array. Any- # other 200 payload is a permanent API-contract violation, not a transient failure.- if config.api == "v1":- rows = data.get("results") if isinstance(data, dict) else None- else:- rows = data if isinstance(data, list) else None- if not isinstance(rows, list):- raise ValueError(f"JumpCloud API returned an unexpected response shape: url={url}")+ rows = _fetch_rest_page(session, base_url, config.path, config, skip, logger)if not rows:break@@ -238,6 +250,81 @@ def _get_rest_rows(resumable_source_manager.save_state(JumpcloudResumeConfig(skip=skip))+def _get_child_rows(+ session: requests.Session,+ base_url: str,+ config: JumpcloudEndpointConfig,+ parent_id: str,+ logger: FilteringBoundLogger,+) -> Iterator[list[dict[str, Any]]]:+ path = config.path.replace("{parent_id}", quote(parent_id, safe=""))+ skip = 0+ while True:+ try:+ rows = _fetch_rest_page(session, base_url, path, config, skip, logger)+ except requests.HTTPError as e:+ # The parent can be deleted between listing it and requesting its children.+ if e.response is not None and e.response.status_code == 404:+ logger.warning(f"JumpCloud: {config.parent} {parent_id} not found while syncing {config.name}")+ return+ raise++ if not rows:+ return++ yield rows++ if len(rows) < REST_PAGE_SIZE:+ return+ skip += len(rows)+++def _get_fanout_rows(+ session: requests.Session,+ base_url: str,+ config: JumpcloudEndpointConfig,+ logger: FilteringBoundLogger,+ resumable_source_manager: ResumableSourceManager[JumpcloudResumeConfig],+) -> Iterator[list[dict[str, Any]]]:+ """Page through the parent endpoint, then through the child endpoint of each parent row.++ The resume cursor is the parent page offset, so a resumed attempt re-requests the children of+ at most one parent page; the merge dedupes them on the composite primary key.+ """+ if config.parent is None or config.parent_id_column is None:+ raise ValueError(f"JumpCloud endpoint {config.name} is not a fan-out endpoint")+ parent_config = JUMPCLOUD_ENDPOINTS[config.parent]+ parent_id_column = config.parent_id_column++ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None+ parent_skip = resume.skip if resume else 0+ if resume:+ logger.debug(f"JumpCloud: resuming {config.name} from parent skip={parent_skip}")++ while True:+ parents = _fetch_rest_page(session, base_url, parent_config.path, parent_config, parent_skip, logger)+ if not parents:+ break++ for parent in parents:+ parent_id = parent.get(parent_config.primary_key)+ if not parent_id:+ continue+ has_children = False+ for rows in _get_child_rows(session, base_url, config, str(parent_id), logger):+ has_children = True+ yield [{**row, parent_id_column: parent_id} for row in rows]+ if not has_children:+ resumable_source_manager.safe_point()++ if len(parents) < REST_PAGE_SIZE:+ break++ parent_skip += len(parents)+ resumable_source_manager.save_state(JumpcloudResumeConfig(skip=parent_skip))+ resumable_source_manager.safe_point()++def _get_event_rows(session: requests.Session,base_url: str,@@ -319,6 +406,9 @@ def validate_credentials((``schema_name`` set) treats 403 as a hard failure."""endpoint = JUMPCLOUD_ENDPOINTS.get(schema_name) if schema_name else None+ if endpoint is not None and endpoint.parent:+ # A child path needs a parent id, so a scoped probe checks the parent listing instead.+ endpoint = JUMPCLOUD_ENDPOINTS[endpoint.parent]# A scoped probe against a secret-bearing endpoint returns rows too, so keep its response out# of HTTP sample capture as well.session = _make_session(api_key, org_id, capture=not (endpoint is not None and endpoint.redact_keys))@@ -379,8 +469,10 @@ def get_rows(config = JUMPCLOUD_ENDPOINTS[endpoint]# One session reused across every page so urllib3 keeps the connection alive. Endpoints that# redact secret-bearing fields opt out of HTTP sample capture entirely, since capture records- # the raw body before those fields can be stripped.- session = _make_session(api_key, org_id, capture=not config.redact_keys)+ # the raw body before those fields can be stripped. A fan-out endpoint also reads its parent's+ # raw listing, so it inherits the parent's opt-out.+ parent_redacts = config.parent is not None and bool(JUMPCLOUD_ENDPOINTS[config.parent].redact_keys)+ session = _make_session(api_key, org_id, capture=not (config.redact_keys or parent_redacts))if config.api == "insights":pages = _get_event_rows(@@ -392,6 +484,8 @@ def get_rows(should_use_incremental_field,db_incremental_field_last_value,)+ elif config.parent:+ pages = _get_fanout_rows(session, _console_base_url(region), config, logger, resumable_source_manager)else:pages = _get_rest_rows(session, _console_base_url(region), config, logger, resumable_source_manager)@@ -429,7 +523,7 @@ def jumpcloud_source(should_use_incremental_field=should_use_incremental_field,db_incremental_field_last_value=db_incremental_field_last_value,),- primary_keys=[endpoint_config.primary_key],+ primary_keys=endpoint_config.primary_keys,# Directory Insights doesn't document a guaranteed response ordering for the events# query, so "desc" keeps the incremental watermark safe: it's persisted once, as the# run's max, only after the whole window has been walked. The REST endpoints arediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/settings.pyindex af22451263bc..3560531a4544 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/settings.py@@ -4,7 +4,7 @@ from typing import Literalfrom products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType-@dataclass+@dataclass(frozen=True)class JumpcloudEndpointConfig:name: strpath: str@@ -26,12 +26,26 @@ class JumpcloudEndpointConfig:# the warehouse where any table reader could see them. Each entry is a dotted path, so nested# fields can be redacted (e.g. `config.idpPrivateKey`); a bare name targets a top-level field.redact_keys: list[str] = field(default_factory=list)+ # Fan-out endpoints page through the `parent` endpoint and request `path` once per parent row,+ # with `{parent_id}` replaced by the parent's primary key. Child rows are graph objects whose+ # `id` is only unique within one parent, so the parent id is injected as `parent_id_column`+ # and joins the primary key.+ parent: str | None = None+ parent_id_column: str | None = None++ @property+ def primary_keys(self) -> list[str]:+ if self.parent_id_column:+ return [self.parent_id_column, self.primary_key]+ return [self.primary_key]# Core directory resources plus the Directory Insights activity event log. The REST entity# endpoints (users, systems, groups, applications) expose no server-side "updated since"# filter, so they sync as full refresh. Directory Insights events accept a server-side-# start_time/end_time window, so that stream syncs incrementally on `timestamp`.+# start_time/end_time window, so that stream syncs incrementally on `timestamp`. The graph+# association tables (memberships and bindings) fan out per parent and have no timestamps,+# so they also sync as full refresh.JUMPCLOUD_ENDPOINTS: dict[str, JumpcloudEndpointConfig] = {"users": JumpcloudEndpointConfig(name="users",@@ -70,6 +84,46 @@ JUMPCLOUD_ENDPOINTS: dict[str, JumpcloudEndpointConfig] = {# trust it, so drop the whole private-key object before the row is emitted.redact_keys=["config.idpPrivateKey"],),+ "user_group_members": JumpcloudEndpointConfig(+ name="user_group_members",+ path="/api/v2/usergroups/{parent_id}/membership",+ api="v2",+ primary_key="id",+ parent="user_groups",+ parent_id_column="group_id",+ ),+ "system_group_members": JumpcloudEndpointConfig(+ name="system_group_members",+ path="/api/v2/systemgroups/{parent_id}/membership",+ api="v2",+ primary_key="id",+ parent="system_groups",+ parent_id_column="group_id",+ ),+ "application_users": JumpcloudEndpointConfig(+ name="application_users",+ path="/api/v2/applications/{parent_id}/users",+ api="v2",+ primary_key="id",+ parent="applications",+ parent_id_column="application_id",+ ),+ "application_user_groups": JumpcloudEndpointConfig(+ name="application_user_groups",+ path="/api/v2/applications/{parent_id}/usergroups",+ api="v2",+ primary_key="id",+ parent="applications",+ parent_id_column="application_id",+ ),+ "system_users": JumpcloudEndpointConfig(+ name="system_users",+ path="/api/v2/systems/{parent_id}/users",+ api="v2",+ primary_key="id",+ parent="systems",+ parent_id_column="system_id",+ ),"events": JumpcloudEndpointConfig(name="events",path="/insights/directory/v1/events",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/source.pyindex b2c9d3ef6d98..4d121646fe94 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/source.py@@ -131,7 +131,7 @@ The `events` table requires a Directory Insights subscription. If you're an MSP/supports_incremental=bool(INCREMENTAL_FIELDS.get(endpoint)),supports_append=False,incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),- detected_primary_keys=[JUMPCLOUD_ENDPOINTS[endpoint].primary_key],+ detected_primary_keys=JUMPCLOUD_ENDPOINTS[endpoint].primary_keys,description=("Directory Insights activity events (console, SSO, RADIUS, LDAP, systems, and directory changes). ""Only syncs the last 90 days on initial sync, bounded by your Directory Insights retention"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/tests/test_jumpcloud.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/tests/test_jumpcloud.pyindex 70498c3203c7..e5373ed16d30 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/tests/test_jumpcloud.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jumpcloud/tests/test_jumpcloud.py@@ -39,6 +39,9 @@ class _FakeResumableManager:def save_state(self, data: JumpcloudResumeConfig) -> None:self.saved.append(data)+ def safe_point(self) -> None:+ pass+def _response_with_status(status_code: int, body: bytes = b"", headers: dict[str, str] | None = None):response = requests.Response()@@ -197,7 +200,9 @@ class TestRestRows:}]- @parameterized.expand([("applications", False), ("users", True)])+ @parameterized.expand(+ [("applications", False), ("users", True), ("application_users", False), ("system_users", True)]+ )def test_secret_bearing_endpoint_disables_http_sample_capture(self, endpoint: str, expected_capture: bool) -> None:# HTTP sample capture writes the raw response body before row-level `redact_keys` runs, so# endpoints that redact secrets (applications' SAML key) must opt out of capture entirely.@@ -207,9 +212,11 @@ class TestRestRows:capture_kwargs.append(kwargs.get("capture"))return MagicMock()+ listing = JUMPCLOUD_ENDPOINTS[JUMPCLOUD_ENDPOINTS[endpoint].parent or endpoint]+def fake_request(session: Any, method: str, url: str, logger: Any, json_body: Any = None) -> Any:response = MagicMock()- response.json.return_value = {"results": []} if JUMPCLOUD_ENDPOINTS[endpoint].api == "v1" else []+ response.json.return_value = {"results": []} if listing.api == "v1" else []return responsewith (@@ -245,6 +252,107 @@ class TestRestRows:)+class TestFanoutRows:+ @staticmethod+ def _collect(+ endpoint: str,+ parent_pages: list[list[dict]],+ children: dict[str, list[dict] | int],+ manager: _FakeResumableManager,+ monkeypatch: Any,+ ) -> tuple[list[dict], list[str]]:+ fetched_urls: list[str] = []+ config = JUMPCLOUD_ENDPOINTS[endpoint]+ parent_config = JUMPCLOUD_ENDPOINTS[config.parent or ""]++ def fake_request(session: Any, method: str, url: str, logger: Any, json_body: Any = None) -> Any:+ fetched_urls.append(url)+ path, query = url.removeprefix("https://console.jumpcloud.com").split("?")+ skip = int(query.split("skip=")[1].split("&")[0])+ response = MagicMock()+ if path == parent_config.path:+ index = skip // REST_PAGE_SIZE+ page = parent_pages[index] if index < len(parent_pages) else []+ response.json.return_value = {"results": page} if parent_config.api == "v1" else page+ return response+ parent_id = path.split("/")[4]+ child = children.get(parent_id, [])+ if isinstance(child, int):+ raise requests.HTTPError(response=_response_with_status(child))+ response.json.return_value = child[skip : skip + REST_PAGE_SIZE]+ return response++ monkeypatch.setattr(jumpcloud, "_request", fake_request)+ monkeypatch.setattr(jumpcloud, "make_tracked_session", lambda **kwargs: MagicMock())++ rows: list[dict] = []+ for page in get_rows(+ api_key="key",+ endpoint=endpoint,+ logger=MagicMock(),+ resumable_source_manager=manager, # type: ignore[arg-type]+ ):+ rows.extend(page)+ return rows, fetched_urls++ def test_injects_parent_id_into_each_child_row(self, monkeypatch: Any) -> None:+ member = {"id": "u1", "type": "user", "paths": [[{"to": {"id": "u1", "type": "user"}}]]}+ manager = _FakeResumableManager()+ rows, urls = self._collect(+ "user_group_members",+ [[{"id": "g1"}, {"id": "g2"}]],+ {"g1": [member], "g2": [{"id": "u1", "type": "user", "paths": []}]},+ manager,+ monkeypatch,+ )+ # The same user in two groups must stay two distinct rows under the composite key.+ assert rows == [{**member, "group_id": "g1"}, {"id": "u1", "type": "user", "paths": [], "group_id": "g2"}]+ assert JUMPCLOUD_ENDPOINTS["user_group_members"].primary_keys == ["group_id", "id"]+ assert urls[1].startswith("https://console.jumpcloud.com/api/v2/usergroups/g1/membership?")+ assert manager.saved == []++ def test_reads_v1_parent_ids_and_pages_children(self, monkeypatch: Any) -> None:+ many_users = [{"id": f"u{i}", "type": "user"} for i in range(REST_PAGE_SIZE + 1)]+ manager = _FakeResumableManager()+ rows, urls = self._collect("system_users", [[{"_id": "s1"}]], {"s1": many_users}, manager, monkeypatch)+ assert len(rows) == REST_PAGE_SIZE + 1+ assert {row["system_id"] for row in rows} == {"s1"}+ assert [u.split("?")[0] for u in urls[1:]] == ["https://console.jumpcloud.com/api/v2/systems/s1/users"] * 2++ def test_checkpoints_parent_offset_after_each_full_parent_page(self, monkeypatch: Any) -> None:+ full_page = [{"_id": f"a{i}"} for i in range(REST_PAGE_SIZE)]+ manager = _FakeResumableManager()+ rows, _ = self._collect(+ "application_users", [full_page, [{"_id": "last"}]], {"last": [{"id": "u1"}]}, manager, monkeypatch+ )+ assert rows == [{"id": "u1", "application_id": "last"}]+ assert manager.saved == [JumpcloudResumeConfig(skip=REST_PAGE_SIZE)]++ def test_resumes_from_saved_parent_offset(self, monkeypatch: Any) -> None:+ full_page = [{"_id": f"a{i}"} for i in range(REST_PAGE_SIZE)]+ manager = _FakeResumableManager(JumpcloudResumeConfig(skip=REST_PAGE_SIZE))+ _, urls = self._collect("application_user_groups", [full_page, [{"_id": "last"}]], {}, manager, monkeypatch)+ assert f"skip={REST_PAGE_SIZE}" in urls[0]+ assert [u.split("?")[0] for u in urls[1:]] == [+ "https://console.jumpcloud.com/api/v2/applications/last/usergroups"+ ]++ def test_parent_deleted_mid_sync_is_skipped(self, monkeypatch: Any) -> None:+ manager = _FakeResumableManager()+ rows, _ = self._collect(+ "system_group_members",+ [[{"id": "gone"}, {"id": "g2"}]],+ {"gone": 404, "g2": [{"id": "s1", "type": "system"}]},+ manager,+ monkeypatch,+ )+ assert rows == [{"id": "s1", "type": "system", "group_id": "g2"}]++ def test_child_permission_error_is_raised(self, monkeypatch: Any) -> None:+ with pytest.raises(requests.HTTPError):+ self._collect("system_users", [[{"_id": "s1"}]], {"s1": 403}, _FakeResumableManager(), monkeypatch)++class TestEventRows:@staticmethoddef _collect(@@ -398,6 +506,16 @@ class TestValidateCredentials:assert url == "https://api.jumpcloud.com/insights/directory/v1/events"assert session.post.call_args.kwargs["json"]["limit"] == 1+ def test_fanout_schema_probes_the_parent_listing(self) -> None:+ session = MagicMock()+ session.get.return_value = _response_with_status(200)+ with patch.object(jumpcloud, "_make_session", return_value=session) as make_session:+ ok, _error = validate_credentials("key", schema_name="application_users")+ assert ok is True+ assert session.get.call_args.args[0] == "https://console.jumpcloud.com/api/applications?limit=1"+ # The parent listing carries SAML signing keys, so the probe must not be sample-captured.+ assert make_session.call_args.kwargs["capture"] is False+def test_connection_error_returns_message(self) -> None:session = MagicMock()session.get.side_effect = requests.ConnectionError("boom")@@ -418,7 +536,7 @@ class TestJumpcloudSourceResponse:)config = JUMPCLOUD_ENDPOINTS[name]assert response.name == name- assert response.primary_keys == [config.primary_key]+ assert response.primary_keys == config.primary_keys# Directory Insights response ordering is undocumented, so the events stream defers# its watermark to job end (desc); everything else is plain ascending full refresh.assert response.sort_mode == ("desc" if config.api == "insights" else "asc")