Skip to content

test: make network-dependent unit tests hermetic - #3695

Merged
migmartri merged 1 commit into
mainfrom
fix/hermetic-network-tests
Oct 22, 2026
Merged

migmartri merged 1 commit into
mainfrom
fix/hermetic-network-tests

Conversation

@matiasinsaurralde

@matiasinsaurralde matiasinsaurralde commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Refs PFM-7940

Summary

Two unit tests made live outbound HTTP calls, so they failed on any runner without internet egress (air-gapped CI, outages, rate limits). This makes them not need the network at all, reusing loopback patterns already present in the repo.

  • rego (pkg/policies/engine/rego): replace the two "allowed network requests" subtests that dialed www.chainloop.dev and github.com with TestRego_AllowedHostnames (asserts allow-list membership) and TestRego_AllowedHostIsReachable (reaches an allowed host on a loopback httptest server). The forbidden functions/forbidden network requests subtests are unchanged. Drops the now-unused restricted_mode_networking_allowed_host.rego testfile.
  • materials (pkg/attestation/crafter/materials): replace the non-existent path OCI case that reached Docker Hub for its UNAUTHORIZED response with TestOCIImageCraft_UnresolvableRemoteReference against an in-memory loopback registry, asserting the deterministic NAME_UNKNOWN error.

No production behavior changes. The engine's host allow-list, netguard ranges, and http.send gating are untouched. The fix lives entirely in test code.

View guided diff

@matiasinsaurralde
matiasinsaurralde requested a review from a team October 22, 2026 01:44
@chainloop-platform

chainloop-platform Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — ⏭️ bypassed by label

AI Coding Session Check Bypassed

This PR carries the skip-ai-session label, so the AI coding session check was bypassed.

Learn more about Chainloop Trace.

Security Checks — ✅ 5 passing

✅ secret-scan

Status Policy Messages
✅ Passed secrets-detection -

✅ sast-scan

Status Policy Messages
✅ Passed owasp-top10-2025 -
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -
Scans not applied (3)
Scan Reason
vulnerability-scan no manifest/lockfile changed
github-actions-scan no workflow files changed
iac-scan no IaC files changed

View attestation ↗

Security context

✅ Nothing this change touches has a recorded security-fix history.

View in Chainloop ↗ · How this works ↗


Powered by Chainloop and Chainloop Trace

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

View guided diff | Re-trigger cubic

@matiasinsaurralde
matiasinsaurralde force-pushed the fix/hermetic-network-tests branch from bc1dd3c to a1a933f Compare October 22, 2026 02:46
Two unit tests made live outbound HTTP calls and failed on any runner
without egress (air-gapped CI, outages, rate limits). Make them not need
the network at all, reusing loopback patterns already present in the repo.

- rego: replace the two "allowed network requests" subtests (which dialed
  www.chainloop.dev and github.com) with TestRego_AllowedHostnames, which
  asserts allow-list membership, and TestRego_AllowedHostIsReachable, which
  reaches an allowed host on a loopback httptest server. Drop the now-unused
  restricted_mode_networking_allowed_host.rego testfile. The forbidden
  functions/network subtests are unchanged.
- materials: replace the "non-existent path" OCI case (which reached Docker
  Hub for its UNAUTHORIZED response) with TestOCIImageCraft_UnresolvableRemoteReference
  against an in-memory loopback registry, asserting the deterministic
  NAME_UNKNOWN error.

No production behavior changes.

Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
@matiasinsaurralde
matiasinsaurralde force-pushed the fix/hermetic-network-tests branch from a1a933f to f38c39f Compare October 22, 2026 02:47
@migmartri
migmartri merged commit a51569e into main Oct 22, 2026
17 checks passed
@migmartri
migmartri deleted the fix/hermetic-network-tests branch October 22, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants