Skip to content

Test: address scopes, /services and /processes limits, package cache - #14

Merged
alexeybe1kin merged 2 commits into
mainfrom
glm/systemgate-inventory-tests
Nov 1, 2026
Merged

alexeybe1kin merged 2 commits into
mainfrom
glm/systemgate-inventory-tests

Conversation

@alexeybe1kin

Copy link
Copy Markdown
Collaborator

Adds tests/test_inventory_limits.py (23 tests), pinning logic in systemgate/main.py that CI did not cover: _safe_addr scope words (loopback, tailscale, private-lan incl. the 172.16-31 edges, public-or-host, wildcard inside/outside a container, empty address), /services grouping, de-duplication, sort order, ids, limit clamp 1..200 (default 80) and a denied connection listing, /processes sort by CPU then memory, AccessDenied skipping and limit clamp to 100, and the one-hour /packages cache (cached at 3599 s, recomputed at 3600 s). Everything is patched: no network, no real psutil listing, no subprocess.

Full suite: 71 passed, 8 skipped. ruff and file sizes pass.

Mutations tried in systemgate/main.py (each restored): startswith("100.") to "101." fails the tailscale scope case; min(limit, 200) to 300 fails the clamp test; PACKAGE_CACHE_SECONDS 3600 to 3601 fails the cache test.

Reviewer fixes to the GLM draft: listeners were compared as sets instead of ordered lists, process limit cases checked counts only (now pid order), the docker patch could recurse, ruff format.

Written by GLM (worker w20-mvy9fw14), reviewed by Claude.

🤖 Generated with Claude Code

alexeybe1kin and others added 2 commits November 1, 2026 22:18
…es, and package cache

- Test address scope mapping (_safe_addr) for loopback, tailscale, private-lan, public-or-host
- Test wildcard address scope depends on container detection
- Test empty address handling (no IP or port)
- Test services endpoint grouping, deduplication, sorting, and limit clamping
- Test services endpoint gracefully handles AccessDenied errors
- Test processes endpoint sorting by CPU/memory, skipping AccessDenied, and limit clamping
- Test packages endpoint caching behavior with proper expiration timing

All tests use mocking to avoid dependencies on real system state and cover edge cases
that were not previously tested by the existing test suite.
… format

Listener lists were compared as sets although the order is part of the
behaviour; the limit cases only counted rows; the docker patch could recurse
into itself; the denied-process stand-in was convoluted; the file was not
ruff-formatted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexeybe1kin
alexeybe1kin merged commit e5d92a5 into main Nov 1, 2026
3 checks passed
@alexeybe1kin
alexeybe1kin deleted the glm/systemgate-inventory-tests branch November 1, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant