Skip to content

test: External PDP#39913

Merged
KevLehman merged 12 commits intofeat/externalpdpfrom
test/externalpdp
Mar 30, 2026
Merged

test: External PDP#39913
KevLehman merged 12 commits intofeat/externalpdpfrom
test/externalpdp

Conversation

@KevLehman
Copy link
Copy Markdown
Member

@KevLehman KevLehman commented Mar 27, 2026

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

The tests here don't connect directly to Virtru or touch any virtru config. That's a black box for us.

The goal is to test our decision enforcement. If server returns DENY, then we act. If it's permit, we do as well.

Further comments

Summary by CodeRabbit

  • Tests
    • Added comprehensive testing infrastructure for ABAC (Attribute-Based Access Control) with external PDP support, including mock server and end-to-end test scenarios covering permit/deny decisions, invites, and dynamic configuration.
    • Implemented test helper utilities for managing mock server endpoints and seeding test data.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 27, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

⚠️ No Changeset found

Latest commit: b01afe4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a482b161-79c1-42f5-b29a-20e58d4c5bf4

📥 Commits

Reviewing files that changed from the base of the PR and between 92947cd and b01afe4.

📒 Files selected for processing (7)
  • apps/meteor/tests/data/mock-server.helper.ts
  • apps/meteor/tests/e2e/config/constants.ts
  • apps/meteor/tests/end-to-end/api/abac.ts
  • development/mockServer/Dockerfile
  • development/mockServer/go.mod
  • development/mockServer/main.go
  • docker-compose-ci.yml

Walkthrough

A new mock HTTP server infrastructure is introduced for testing authorization decisions. The system includes a Go-based server application that manages mock response rules, a health endpoint, and dynamic bulk decision generation. TypeScript test helpers provide type-safe functions to interact with the mock server. An end-to-end test suite for ABAC with external PDP is added, demonstrating the infrastructure in action with various authorization scenarios.

Changes

Cohort / File(s) Summary
Mock Server Core
development/mockServer/main.go, development/mockServer/go.mod, development/mockServer/Dockerfile
Complete HTTP mock server in Go that registers, matches, and serves HTTP mocks with configurable response codes, headers, and bodies. Supports dynamic bulk decision generation based on entity identifiers, request logging, and health checks. Multi-stage Docker build for minimal runtime image.
Test Infrastructure
apps/meteor/tests/data/mock-server.helper.ts, apps/meteor/tests/e2e/config/constants.ts
TypeScript utilities to interact with the mock server: functions to register individual and bulk mocks, reset state, check health, and seed common test scenarios (authorization decisions, default endpoints). Configuration constant for mock server URL with localhost fallback.
ABAC E2E Test Suite
apps/meteor/tests/end-to-end/api/abac.ts
New comprehensive test suite for ABAC with external PDP via mock server. Covers PERMIT/DENY authorization behavior, invite handling, fail-closed behavior on unavailability, selective denial by entity, and attribute tightening scenarios. Includes setup/teardown lifecycle management.
CI Configuration
docker-compose-ci.yml
Added mock-server service to CI Docker Compose, exposing port 4000 and configured with health check using the built-in healthcheck mode.

Sequence Diagram

sequenceDiagram
    actor Test
    participant App as Application
    participant MockServer as Mock Server
    
    Test->>MockServer: POST /__mock/set-bulk-decision<br/>(permit_values, default_decision)
    MockServer-->>Test: Registered dynamic bulk rule
    
    Test->>App: Make authorized request<br/>(with user identity)
    activate App
    App->>MockServer: POST /GetDecisionBulk<br/>(decision request with user email)
    activate MockServer
    MockServer->>MockServer: Inspect email against<br/>permit_values
    MockServer-->>App: Return DECISION_PERMIT<br/>or DECISION_DENY
    deactivate MockServer
    App-->>Test: Response (403 if denied,<br/>200 if permitted)
    deactivate App
    
    Test->>MockServer: DELETE /__mock/reset
    MockServer-->>Test: State cleared
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested Labels

type: feature, area: authentication


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@KevLehman KevLehman changed the title tests test: External PDP Mar 27, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.31%. Comparing base (92947cd) to head (b01afe4).
⚠️ Report is 1 commits behind head on feat/externalpdp.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           feat/externalpdp   #39913      +/-   ##
====================================================
- Coverage             70.34%   70.31%   -0.03%     
====================================================
  Files                  3247     3247              
  Lines                115559   115559              
  Branches              21056    21017      -39     
====================================================
- Hits                  81286    81252      -34     
- Misses                32209    32239      +30     
- Partials               2064     2068       +4     
Flag Coverage Δ
e2e 60.46% <ø> (-0.01%) ⬇️
e2e-api 48.13% <ø> (-1.05%) ⬇️
unit 70.73% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rc-layne
Copy link
Copy Markdown

rc-layne bot commented Mar 30, 2026

Layne — scan passed

No security issues found on latest push.

@KevLehman KevLehman marked this pull request as ready for review March 30, 2026 16:13
@KevLehman KevLehman requested review from a team as code owners March 30, 2026 16:13
@KevLehman KevLehman merged commit fc39e07 into feat/externalpdp Mar 30, 2026
45 checks passed
@KevLehman KevLehman deleted the test/externalpdp branch March 30, 2026 16:13
@coderabbitai coderabbitai bot added type: feature Pull requests that introduces new feature area: authentication labels Mar 30, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/tests/data/mock-server.helper.ts">

<violation number="1" location="apps/meteor/tests/data/mock-server.helper.ts:40">
P2: Check the reset response and fail when the mock-server reset request is unsuccessful; otherwise test runs can silently proceed with stale mocks.</violation>
</file>

<file name="apps/meteor/tests/end-to-end/api/abac.ts">

<violation number="1" location="apps/meteor/tests/end-to-end/api/abac.ts:2666">
P2: The suite mutates several global ABAC/PDP settings but does not restore them in teardown, which can leak state into later tests.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

};

export const mockServerReset = async (): Promise<void> => {
await fetch(`${MOCK_SERVER_URL}/__mock/reset`, { method: 'DELETE' });
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 30, 2026

Choose a reason for hiding this comment

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

P2: Check the reset response and fail when the mock-server reset request is unsuccessful; otherwise test runs can silently proceed with stale mocks.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/tests/data/mock-server.helper.ts, line 40:

<comment>Check the reset response and fail when the mock-server reset request is unsuccessful; otherwise test runs can silently proceed with stale mocks.</comment>

<file context>
@@ -0,0 +1,87 @@
+};
+
+export const mockServerReset = async (): Promise<void> => {
+	await fetch(`${MOCK_SERVER_URL}/__mock/reset`, { method: 'DELETE' });
+};
+
</file context>
Fix with Cubic

this.timeout(10000);

await mockServerReset();
await updateSetting('ABAC_PDP_Type', 'local');
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 30, 2026

Choose a reason for hiding this comment

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

P2: The suite mutates several global ABAC/PDP settings but does not restore them in teardown, which can leak state into later tests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/tests/end-to-end/api/abac.ts, line 2666:

<comment>The suite mutates several global ABAC/PDP settings but does not restore them in teardown, which can leak state into later tests.</comment>

<file context>
@@ -2614,3 +2623,424 @@ const addAbacAttributesToUserDirectly = async (userId: string, abacAttributes: I
+		this.timeout(10000);
+
+		await mockServerReset();
+		await updateSetting('ABAC_PDP_Type', 'local');
+		await updateSetting('ABAC_Enabled', false);
+	});
</file context>
Fix with Cubic

KevLehman added a commit that referenced this pull request Mar 31, 2026
KevLehman added a commit that referenced this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant