Skip to content

test(integration): authenticate Integration tests with Minter using user token - #670

Open
amrit-agarwal-1 wants to merge 7 commits into
mainfrom
test/minter-user-token-auth
Open

test(integration): authenticate Integration tests with Minter using user token#670
amrit-agarwal-1 wants to merge 7 commits into
mainfrom
test/minter-user-token-auth

Conversation

@amrit-agarwal-1

@amrit-agarwal-1 amrit-agarwal-1 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Six suites - Agents, Agent Memory, Agent Traces, Governance, Notifications, Subscriptions , were permanently describe.skip-ed: their APIs reject PAT and client-credentials tokens with 401 regardless of scopes, and the required scopes aren't available to external applications.

CI now mints a user access token with Minter (Portal team's headless-login image, pulled from ACR with a scoped token) and writes it to UIPATH_USER_TOKEN. Those six suites run under it.

Suites are declared with describeIntegration(name, requirement, modes, body), which expands them over init modes × credentials and names each cell [initMode][authMode], so a failure says which credential failed. The requirement is stated once and drives the credential, the host and the collection-time skip guard — declaring the guard separately let the two disagree.

'both' — the default — runs a suite once per configured credential. 23 suites run under PAT and the user token: the PAT exercises the external-application scope model most SDK consumers use, the user token exercises the API surface generally. Neither subsumes the other.

User-token cells use MINTER_BASE_URL (the platform host). The default host is a CORS proxy whose path whitelist must name every service a suite touches.

Also in here:

getActiveAuth() gives the four raw-fetch call sites the credential and host of the cell actually running; config.userToken ?? config.secret was correct only while a suite ran under one credential.
Folder-filter tests use INTEGRATION_TEST_FOLDER_KEY instead of fabricated GUIDs — folderKeys is authorized before it's applied, so an inaccessible folder returns 403, an assumption these tests documented but had never run to verify.
Fixtures are created and owned by the suites that read them.
Five tests are skipped with the blocker named: a notification-service $filter stall, topic groups absent from the tenant, and three agent-activity data gaps.

Local runs are unchanged — with only UIPATH_SECRET, 'both' suites run PAT-only and user suites skip. Minter stays optional.

Verified against alpha procodeapps/integrationtest.

@amrit-agarwal-1
amrit-agarwal-1 requested a review from a team August 13, 2026 12:39
@claude

claude Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

2 similar comments
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@sonarqubecloud

Copy link
Copy Markdown

Comment thread .github/workflows/coverage.yml Outdated
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding: shell quoting in the Minter docker run command (see inline comment on .github/workflows/coverage.yml).

Everything else looks good — the dual-auth cache keying, hasUserToken() reading env directly to avoid config-load timing issues, the describe.skipIf(!hasUserToken()) gate pattern, folder-key fix from fabricated GUIDs to INTEGRATION_TEST_FOLDER_KEY, and the continue-on-error: true degradation path are all correct.

@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

1 similar comment
@claude

claude Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

Comment thread tests/integration/shared/agents/feedback.integration.test.ts Outdated
@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding: double-cleanup in the getById fixture path in feedback.integration.test.ts (see inline comment).

Everything else looks correct — the dual-key cache (mode + authMode), resolveAuthMode() reading process.env directly so describe.skipIf and beforeAll always agree, hasUserToken() short-circuiting config load, the NOTIFICATION_TENANT_ID/TENANT_ID split for the notification vs subscription services, recentWindow() replacing stale hardcoded date literals, TRACES_TEST_TRACE_ID wired through config, and config.userToken ?? config.secret applied consistently to raw-fetch credential calls in attachments and jobs.

@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@amrit-agarwal-1
amrit-agarwal-1 force-pushed the test/minter-user-token-auth branch from 17c621e to da239c9 Compare August 24, 2026 06:42
@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding: missing guard in the getById cleanup block of attachments.integration.test.ts (see inline comment at line 34). If create() throws, afterAll runs with attachmentId still undefined at runtime and issues a spurious DELETE .../Attachments(undefined).

Everything else looks correct: the dual-key service cache (mode + authMode), resolveAuthMode reading process.env directly so describe.skipIf and setup always agree, hasUserToken() short-circuiting config load, the NOTIFICATION_TENANT_ID/TENANT_ID split, recentWindow() replacing stale hardcoded date literals, the TRACES_TEST_TRACE_ID config field, INTEGRATION_TEST_FOLDER_KEY wired through the folder-filter tests, and config.userToken ?? config.secret applied consistently to raw-fetch credential calls.

@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@amrit-agarwal-1
amrit-agarwal-1 force-pushed the test/minter-user-token-auth branch from 37dd36d to fe21be3 Compare August 24, 2026 08:15
@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

Comment thread tests/integration/shared/observability/traces.integration.test.ts Outdated
@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding: null-dereference in the pageSize test in traces.integration.test.ts (see inline comment at line 106). getByIdOptions is undefined on the happy path and getByIdOptions.includeExpiredSpans throws before ctx.skip can run — fix with getByIdOptions?.includeExpiredSpans.

Three prior threads remain open (coverage.yml quoting, feedback double-cleanup, attachments afterAll guard) — no change to their status this run.

Comment thread .github/workflows/coverage.yml Outdated
@claude

claude Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding: the second docker run in the "Mint user access token" step (coverage.yml line 224) has the same shell-quoting issue flagged in the open thread at line 184 — -u '$MINTER_USERNAME', -n '$ORG_NAME', -t '$TENANT_NAME' are host-expanded before single-quoting. The fix is the same: pass via -e VAR and reference with \"$VAR\" inside the container shell.

Three prior threads remain open (line 184 quoting, feedback double-cleanup, attachments afterAll guard, traces null dereference) — no change to their status this run.

Comment thread tests/integration/config/test-config.ts Outdated
@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review summary

One new finding: orphaned JSDoc comment in tests/integration/config/test-config.ts at line 283 (see inline comment). The /** Whether any configured credential can satisfy the requirement. */ block is intended for canAuthenticate() but sits before resolveBaseUrl()'s own JSDoc, so TypeScript attaches it to nothing — canAuthenticate() ends up undocumented.

Four prior threads remain open (coverage.yml shell quoting ×2, feedback double-cleanup, attachments afterAll guard, traces null-dereference) — no change to their status this run.

@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

4 similar comments
@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@amrit-agarwal-1 amrit-agarwal-1 changed the title test(integration): authenticate insightsrtm_ suites with Minter using user token test(integration): authenticate Integration tests with Minter using user token Sep 2, 2026
@Sarath1018

Copy link
Copy Markdown
Collaborator

we are running vo mode with PAT then user token and again v1 mode with PAT and user all serially. This will double our integration tests run time. I dont see a way to run them parallel without redesigning the entire integration tests. I would suggest to increase the runner cpu from 2 to 4 and increase workercount to 4 which will increase the concurrence between different test suits and improve the time

Comment thread tests/integration/shared/maestro/processes.integration.test.ts Outdated
Comment thread tests/integration/config/test-config.ts Outdated
Comment thread tests/integration/config/unified-setup.ts Outdated
Comment thread .github/workflows/coverage.yml
Comment thread tests/.env.integration.example Outdated
@claude

claude Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

1 similar comment
@claude

claude Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@amrit-agarwal-1
amrit-agarwal-1 force-pushed the test/minter-user-token-auth branch from 4778f72 to 1e779ce Compare September 8, 2026 21:01
@claude

claude Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

1 similar comment
@claude

claude Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

Comment thread .github/workflows/coverage.yml Outdated
Comment on lines +220 to +223
# Network-bound suite, but the tenant is the bottleneck, not the runner.
# 4 workers bought 13% wall clock (1292s -> 1120s) and cost a wave of 504s,
# 503s and request timeouts that tripled the failing files. Stay at 2.
run: npm run test:integration:coverage -- --run --maxWorkers=2

@Sarath1018 Sarath1018 Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There will be no improvement by increasing maxWorkers without increasing cpu. check if we can increase cpu to 4 from 2. Also keep the comment in 1 line or remove it all together

@amrit-agarwal-1
amrit-agarwal-1 force-pushed the test/minter-user-token-auth branch from 1e779ce to 5701539 Compare September 9, 2026 08:24
@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

1 similar comment
@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

amrit-agarwal-1 and others added 5 commits September 9, 2026 18:50
… under both

Squashed from 25 commits (kept on backup/minter-pre-rebase).

- Mint a user access token with Minter in CI (ACR scoped token, masked, written
  into tests/.env.integration) so suites whose APIs reject PATs can run at all:
  insightsrtm_ (Agents, Memory, Agent Traces, Governance) and the notification
  service, all previously describe.skip.
- describeIntegration(name, requirement, modes, body, options?) declares a suite
  once and expands it over init modes x credentials, naming cells
  [initMode][authMode]. 'any' runs under every configured credential — PAT and
  user token both, per the decision that neither subsumes the other.
- User-token cells resolve MINTER_BASE_URL when set; PAT cells keep
  UIPATH_BASE_URL. getActiveAuth() gives the raw-fetch call sites the credential
  and host of the cell actually running.
- Fixture ownership: suites create and own what they read rather than depending
  on tenant state; rolling time windows replace hardcoded dates; the traces
  suite falls back to expired spans when the pinned trace ages out.
- Five tests skipped with the blocker named: the notification $filter server
  stall, topic groups absent from the tenant, and three agent-activity data gaps.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…mments

'any' read as 'either one will do' when it means 'run under every configured
credential' — the suite executes once per credential, not once. 'both' says
that. Type, call sites, and docs renamed together; no behaviour change.

Also trimmed the comment blocks that had grown past their value, including a
JSDoc citing a specific CI run number that would not age well.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…drop unused helpers

- Unskip the 18 insightsrtm_ describe blocks in maestro processes/cases/case-instances
  and gate them on the user-token cell instead; they were skipped only because PAT
  is rejected there.
- Remove the unused canAuthenticate() helper.
- Make initializeServices' authMode required — every caller passes it.
- Delete tests/.env.integration after the run so the minted token does not outlive
  the job on a reused runner.
The env var the tests read is now UIPATH_TENANT_ID. The GitHub secret keeps the
UIPATH_TENANT_ID_DEV || UIPATH_TENANT_ID override pair, matching every other
secret in the workflow.
15 of the 18 unskipped insightsrtm_ blocks pass under the user token. The three
that do not fail on tenant data, not auth: getInstanceStats' duration fields are
undefined with no completed instances in the window, and getSlaSummary's
slaDueTime is empty.

Also drops the worker-count comment on the integration step, per review.
@amrit-agarwal-1
amrit-agarwal-1 force-pushed the test/minter-user-token-auth branch from d4f2bca to b3991cb Compare September 9, 2026 13:21
@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

2 similar comments
@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@amrit-agarwal-1
amrit-agarwal-1 force-pushed the test/minter-user-token-auth branch from 285d4ae to b3991cb Compare September 9, 2026 16:30
@claude

claude Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

The pat and user cells ran back-to-back in one job, so the run cost the sum of
both credentials. Each leg now runs on its own runner via INTEGRATION_AUTH_MODE,
which needs SonarCloud out of the test job: it must see both lcov reports and
must run once, so it moves to a job that downloads and merges them.
@claude

claude Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

Its reads stall past the default 30s on the shared tenant — 18 timeouts in the
last run, spread across the whole file. Same class and remedy as the schema
suite's hooks in #723: budget headroom, not failure tolerance.
@claude

claude Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

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.

3 participants