Skip to content

fix(auth): run generic entity E2E tests as a service principal#845

Open
anastasia-nesterenko wants to merge 2 commits into
mainfrom
anesterenko/aircore-771-entity-rbac-returns-403-for-authenticated-users-on-nmpdev
Open

fix(auth): run generic entity E2E tests as a service principal#845
anastasia-nesterenko wants to merge 2 commits into
mainfrom
anesterenko/aircore-771-entity-rbac-returns-403-for-authenticated-users-on-nmpdev

Conversation

@anastasia-nesterenko

@anastasia-nesterenko anastasia-nesterenko commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Updates the direct Entities API E2E tests to authenticate as an internal service principal, matching how feature services access the entity store in production.

This is a test-only behavior correction. It does not change runtime authorization: generic Entities API CRUD remains service-only, and authenticated user principals continue to receive 403 Forbidden.

Changes

  • Adds a module-scoped entity_store_sdk fixture using as_service_for.
  • Uses the service-authenticated SDK for entity CRUD, listing, filtering, sorting, renaming, and cleanup.
  • Keeps user-facing project operations on the existing caller SDK.
  • Uses the SDK's absolute base URL for the /cluster-info E2E request.
  • Clarifies the existing Rego comments describing workspace sub-resource authorization. No Rego rule or permission behavior changes.

Why

These E2E tests were calling the internal generic Entities API with user credentials. Because that API is intentionally service-only, the calls correctly returned 403.

Feature services access the entity store using a service:* principal. The tests now use the same authentication model so they validate entity-store behavior without weakening access controls.

Runtime impact

None. This PR does not change authorization policies, role definitions, or endpoint behavior.

Validation

To rerun on the final PR head:

  • uv run --frozen pytest e2e/test_entities.py -v --run-e2e
  • uv run --frozen ruff check e2e/test_entities.py
  • git diff --check

Summary by CodeRabbit

  • Tests
    • Updated entity end-to-end coverage to validate internal entity-store CRUD and related flows using service credentials, including project association checks and search/sort/rename scenarios.
    • Improved the cluster information E2E test to build requests from the configured base URL with trailing-slash normalization.
  • Documentation
    • Clarified authorization behavior for workspace sub-resources, explaining how permission-based checks apply without changing effective access controls.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 53e1cc48-9b9a-4ca7-9c62-0e9d576f82f6

📥 Commits

Reviewing files that changed from the base of the PR and between 764ac00 and 7b0d4b4.

📒 Files selected for processing (2)
  • e2e/test_entities.py
  • services/core/auth/src/nmp/core/auth/app/policies/authz.rego
🚧 Files skipped from review as they are similar to previous changes (2)
  • services/core/auth/src/nmp/core/auth/app/policies/authz.rego
  • e2e/test_entities.py

📝 Walkthrough

Walkthrough

Entity E2E tests now authenticate entity-store operations with a service-principal client while retaining caller credentials for projects. The cluster-info URL uses the SDK base URL, and authorization comments clarify workspace sub-resource handling.

Changes

Internal entities E2E coverage

Layer / File(s) Summary
Internal entity client setup
e2e/test_entities.py, services/core/auth/.../authz.rego
Adds the internal SDK fixture, normalizes the cluster-info URL, and clarifies authorization comments.
CRUD and project association
e2e/test_entities.py
Routes entity lifecycle and project-association operations through the internal client while retaining caller credentials for projects.
Listing, sorting, and filtering
e2e/test_entities.py
Routes entity listing, sorting, search, filtering, and cleanup through the internal client.
Rename and generated-name flows
e2e/test_entities.py
Routes rename and auto-generated-name coverage through the internal client, including retrieval and cleanup assertions.

Suggested labels: test

Suggested reviewers: ironcommit, mckornfield

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: entity E2E tests now run with a service principal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch anesterenko/aircore-771-entity-rbac-returns-403-for-authenticated-users-on-nmpdev

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 27149/34858 77.9% 62.2%
Integration Tests 15966/33570 47.6% 20.0%

@mckornfield mckornfield 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.

is the fix just a test only fix, specifically using a different principal sdk?

Comment thread services/core/auth/src/nmp/core/auth/app/policies/authz.rego
@anastasia-nesterenko
anastasia-nesterenko added this pull request to the merge queue Jul 22, 2026
@anastasia-nesterenko
anastasia-nesterenko removed this pull request from the merge queue due to a manual request Jul 22, 2026

@ironcommit ironcommit 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.

Need some clarification on what is changing in the PR

@anastasia-nesterenko anastasia-nesterenko changed the title fix(auth): enforce service-only access for generic entity CRUD fix(auth): run generic entity E2E tests as a service principal Jul 23, 2026
Signed-off-by: anastasia-nesterenko <anesterenko@nvidia.com>
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-771-entity-rbac-returns-403-for-authenticated-users-on-nmpdev branch from 764ac00 to 7b0d4b4 Compare July 23, 2026 21:11

@ironcommit ironcommit 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.

LGTM

@anastasia-nesterenko
anastasia-nesterenko added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 23, 2026
@anastasia-nesterenko
anastasia-nesterenko added this pull request to the merge queue Jul 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants