Skip to content

[Expense tests] Re-enable Expense Agent API tests - #12675

Merged
Prangshuman Das (t-prda) merged 1 commit into
features/646383-stack-a-webkey-authfrom
features/646383-stack-b-expense
Oct 15, 2026
Merged

Prangshuman Das (t-prda) merged 1 commit into
features/646383-stack-a-webkey-authfrom
features/646383-stack-b-expense

Conversation

@t-prda

@t-prda Prangshuman Das (t-prda) commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review focus: the Expense test changes and the auth-helper deletion; the enableCleanTestCodeunitExecution line. The large JSON diffs are temporary disables, undone in C.

Re-enables the Expense Agent API tests on top of the default web service key auth. No Key Vault password and no auth subscriber.

Related: AB#646383, AB#653393

Stack (each PR shows only its own layer; merge bottom first)

  1. [API tests] Default to web service key authentication #12674 A: web service key auth (base: main)
  2. [Expense tests] Re-enable Expense Agent API tests #12675 B: Expense API tests + clean test codeunit execution
  3. [API tests] Re-enable APIV1 and APIV2 API tests #12676 C: re-enable APIV1/APIV2 API tests
  4. [API tests] Simplify API test web service key handling #12890 Review fixes for A: simplify web service key handling
  5. Area fixes: [API tests] Ensure VAT posting setup in API document fixtures #12677 D1 VAT fixtures → [API tests] Ensure cancellation reason codes in API sales document tests #12678 D2 cancellation reasons → [API tests] Handle localized purchase invoice payment discounts in APIV1 tests #12679 D3 localized discounts → [API tests] Set sales quote document and posting dates in API tests #12680 D4 quote dates → [API tests] Assign a number series to API vendor payment journals #12681 D5 journal numbering → [API tests] Ignore localized fields in API document comparisons #12682 D6 field comparison → [API tests] Return shipment PDF selection and pdfDocument test isolation #12683 D7 PDF documents → [API tests] Improve APIV1 fixture and verification reliability #12684 D8 APIV1 reliability

Experiments (on D8, do not merge): #12685 E single tenant, #12686 F no clean execution. Combined validation (do not merge): #12687, same tree as D8.

Platform: main already pins BCPlatform 30.0.56112.0, which includes the SQL connection-pool fix (AB#653457).

Note for CI: AL-Go's new-warning check needs a CI/CD baseline from the base branch, and features/* bases have none, so a PR build there fails with a 404. The current CI runs were triggered while these PRs targeted main, so their results are valid for the cumulative change.

@github-actions github-actions Bot added Build: Automation Workflows and other setup in .github folder AL: Apps (W1) Add-on apps for W1 labels Oct 12, 2026
@github-actions github-actions Bot added the Team: Finance GitHub request for Finance area label Oct 12, 2026
@t-prda
Prangshuman Das (t-prda) changed the base branch from features/646383-stack-a-webkey-auth to main October 12, 2026 11:12
@github-actions github-actions Bot added the Build: scripts & configs Build scripts and configuration files label Oct 12, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Oct 12, 2026
@t-prda
Prangshuman Das (t-prda) force-pushed the features/646383-stack-b-expense branch from 8a5a5ad to 6dd7533 Compare October 12, 2026 11:28
@t-prda
Prangshuman Das (t-prda) changed the base branch from main to features/646383-stack-a-webkey-auth October 12, 2026 12:28
@t-prda
Prangshuman Das (t-prda) added this pull request to stack #12697 October 12, 2026 15:38
@t-prda
Prangshuman Das (t-prda) marked this pull request as ready for review October 13, 2026 08:57
@t-prda
Prangshuman Das (t-prda) requested review from a team October 13, 2026 08:57
@t-prda
Prangshuman Das (t-prda) requested a review from a team as a code owner October 13, 2026 08:57
@t-prda
Prangshuman Das (t-prda) force-pushed the features/646383-stack-b-expense branch from 9524556 to 71cca5b Compare October 14, 2026 09:47
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟠\ High\ Severity\ —\ Testing}$

The change enables UnlinkedExpenseUserIsHiddenFromAPI, but its negative request still uses bare asserterror without checking the expected 404 error. Any unrelated request failure, including authentication or setup failure, can therefore make the newly enabled test pass; assert the expected response error (and code where available) after the call.

Knowledge:

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.50.6

@t-prda
Prangshuman Das (t-prda) force-pushed the features/646383-stack-b-expense branch from 71cca5b to 15f12fc Compare October 14, 2026 10:29
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 2

Recommendation: Accept

What this PR does

The change re-enables Expense API coverage on the shared web service key authentication, enables clean execution for disabled-isolation codeunits, and restores the related Expense fixes and regression tests.

Since round 1, the rebased change adds the outbound-request policy to the Expense API test codeunits and adds permission coverage for submit and reject flows. The policy matches the other API suites, and the new tests exercise indirect Spend Request modification under the Expense Agent role. The approver-filter implementation and the staged test exclusions remain consistent with the stack.

Status of previous suggestions
ID Title Status Author response
S1 Negative API test accepts unrelated failures Disputed The exact 404 assertion is handled in a follow-up, and this point was withdrawn for this PR.
New observations (commits since round 1)

None. The newly added request-policy and permission-test changes are consistent with the surrounding test infrastructure.

Risk assessment and necessity

Risk: The main regression surface is the repository-wide clean-codeunit setting and reliance on the shared authentication provider. The Expense API codeunits now explicitly allow their outbound requests, the indirect submit/reject paths have focused permission coverage, and the temporary APIV1/APIV2 exclusions are removed by the next stack layer. The current failed check is an artifact-service network timeout, not a code or test failure.

Necessity: The change is needed to restore Expense API coverage without a test-only credential helper and to run disabled-isolation codeunits in the intended clean lanes. The scope remains appropriate for the staged rollout.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=12675 round=2 by=alexei-dobriansky at=2026-10-14T13:15:46Z lastSha=15f12fc37b9ef10c254a23dc5c812863733b2a74 reviewKey=2b2114491984d4898b836ab7422111742bcdf7383c37571097da3515b7c27a88 suggestions=S1@77d8d452:disputed parentRound=1

Remove the Expense API Test Auth Helper (no Key Vault secret, no subscriber) and apply the
Expense app and test fixes. Keep only Expense disablements that NAV master also has.
Enable clean test codeunit execution; APIV1/APIV2 tests that this surfaces are temporarily
excluded (entries from #12325) and re-enabled by the following layers.

AB#646383
AB#653393

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3952f078-a881-4da8-ad96-13b727e48a91
@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

The re-enabled Expense Agent API tests no longer bind the only authentication subscriber: ExpenseAPITestAuthHelper was deleted and its BindSubscription calls were removed, while the corresponding disabled-test entries were removed. The HTTP calls, such as this Travel Requests POST, therefore run without the credentials that the deleted helper supplied and can fail with an authentication response instead of exercising the API contract. Retain an equivalent authenticated-request setup (or keep these scenarios excluded until the endpoint and test-company prerequisites are available).

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.50.6

@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 3

Recommendation: Request Changes

What this PR does

The rebased change re-enables the Expense API tests through the shared web service key authentication, enables clean execution for disabled-isolation codeunits, and restores the related approval, permission, and spend-request fixes.

The new travel-request filter correctly serializes each assigned user as an exact value, so compressed ranges and filter operators cannot expose another user's requests. The parallel pending expense-report collection still uses the old broad filter construction, so the ownership fix is incomplete.

Status of previous suggestions
ID Title Status Author response
S1 Negative API test accepts unrelated failures Disputed The exact 404 assertion is tracked in a follow-up, and this point was withdrawn for this PR.
New observations (commits since round 2)

S2 (🔴 High): Expense report approver filter still leaks records
Apply the same exact-value filter construction to Expense Reports API.GetSubmitterFilter and AppendDefaultSubmittersForDefaultApprover. That path still compresses setup rows, appends raw user numbers, and changes an overlong filter to *, so an approver can receive another user's pending expense reports and amounts.

Risk assessment and necessity

Risk: Both pending collections are exposed through the same approver view and use the same approval setup. The travel-request path now fails closed, but the expense-report path can still match a user between assigned rows, interpret filter characters in a user number, or broaden an overlong filter to every user. This can expose another approver's report descriptions, comments, and monetary amounts. The shared authentication dependency is present in the stacked base, and no public API or event signature changes are introduced.

Necessity: Restoring the Expense API coverage and removing the test-only credential helper are needed after the shared authentication and runtime fixes became available. The scope must also apply the same exact ownership rule to both child collections before merge.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=12675 round=3 by=alexei-dobriansky at=2026-10-14T20:09:52.4696689Z lastSha=baa93fcfc3ce0e0be53f137f2dc9260a5e6fcfc4 reviewKey=c424537864ea95ec1582e99bf66a60d2fd71185eda101544e803a7ac8780fce9 suggestions=S1@77d8d452:disputed,S2@54ddc552:new parentRound=2

@t-prda

Copy link
Copy Markdown
Contributor Author

alexei-dobriansky thanks, S2 is a valid finding, but it predates this PR. Expense Reports API.GetSubmitterFilter and AppendDefaultSubmittersForDefaultApprover are unchanged from main, and no layer in this stack touches them. The range from GetSelectionFilter can cover an expense user who has no approval setup row between two of the approver's users, and the default-approver path appends raw user numbers.

This PR only aligns the travel-request path, which the re-enabled Expense tests cover. We'll fix the expense-report path in a separate PR from main, mirroring the travel-request change and its tests, so it can be backported on its own.

@t-prda
Prangshuman Das (t-prda) added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit 078b418 Oct 15, 2026
334 of 338 checks passed
@t-prda
Prangshuman Das (t-prda) deleted the features/646383-stack-b-expense branch October 15, 2026 12:56
dominicstarkl pushed a commit to dominicstarkl/BCApps that referenced this pull request Oct 15, 2026
Review focus: ``MicrosoftTestAuthProvider`` (about 60 lines) and the
enum default; the ``build/`` changes are deletions plus the anti-SSRF
line in ``NewBcContainer.ps1``.

Defaults API test authentication (`Library - Graph Mgt`) to the current
user's web service key. API tests no longer need per-app auth uptake or
a container password.

- `API Test Authentication` enum: `DefaultImplementation` = `Microsoft
Test Auth Provider`. Removes `No API Test Auth Provider` and the
explicit `Microsoft Test Environment` value.
- `Microsoft Test Auth Provider`: on-premises with NavUserPassword,
sends Basic auth with `UserId()` and the web service key. When the key
is missing or expired, a background session (`API Test Web Service Key`,
CU 131025) creates it with a 24h expiry and commits it, because the API
request runs in a separate server session. The caller's transaction is
never committed; the provider waits up to 60 s for the session and then
re-reads the key.
- `Library - Graph Mgt`: adds the `SetLicenseSafeWorkDate` and
`AddFieldToIgnoreIfExists` helpers used by later layers.
- Build: removes the container password and Key Vault credential
plumbing (`ApiTestCredential.psm1`, `Remove-ApiTestPassword.ps1`,
`PipelineFinalize` hooks and their tests). Keeps the clean-tenant
execution logic. Sets `NavHttpClientAntiSSRFEnabled=false` in the test
container, as NAV `RunALTests.ps1` does: since microsoft#12323, API tests call
the container's own endpoint through AL `HttpClient`, which anti-SSRF
blocks.
- CU 139494 `API Test Auth Provider Tests`: covers key creation and
renewal. Declares `TestHttpRequestPolicy = AllowAllOutboundRequests`
(NAV blocks outbound requests by default; microsoft#12694 covered the other API
tests).

Related:
[AB#646383](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/646383),
[AB#653393](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/653393)

### Stack (each PR shows only its own layer; merge bottom first)
1. microsoft#12674 A: web service key auth (base: `main`)
2. microsoft#12675 B: Expense API tests + clean test codeunit execution
3. microsoft#12676 C: re-enable APIV1/APIV2 API tests
4. microsoft#12890 Review fixes for A: simplify web service key handling
5. Area fixes: microsoft#12677 D1 VAT fixtures → microsoft#12678 D2 cancellation reasons →
microsoft#12679 D3 localized discounts → microsoft#12680 D4 quote dates → microsoft#12681 D5
journal numbering → microsoft#12682 D6 field comparison → microsoft#12683 D7 PDF documents
→ microsoft#12684 D8 APIV1 reliability

Experiments (on D8, do not merge): microsoft#12685 E single tenant, microsoft#12686 F no
clean execution. Combined validation (do not merge): microsoft#12687, same tree
as D8.

Platform: `main` already pins BCPlatform 30.0.56112.0, which includes
the SQL connection-pool fix
([AB#653457](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/653457)).

Note for CI: AL-Go's new-warning check needs a CI/CD baseline from the
base branch, and `features/*` bases have none, so a PR build there fails
with a 404. The current CI runs were triggered while these PRs targeted
`main`, so their results are valid for the cumulative change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3952f078-a881-4da8-ad96-13b727e48a91
dominicstarkl pushed a commit to dominicstarkl/BCApps that referenced this pull request Oct 15, 2026
Review focus: mostly mechanical. ``Initialize`` sets a license-safe work
date in each API test, and the JSON deletions re-enable tests. A few
files have small fixture or isolation tweaks.

Re-enables the APIV1, APIV2, IRS 1099 and E-Document API tests that pass
without area-specific fixes. Aligned with NAV master: only tests that
NAV master also runs are re-enabled.

- API test `Initialize` sets a license-safe work date. Adds minimal
fixture and isolation adjustments.
- Removes the APIV1/APIV2 exclusions, keeping only the entries fixed in
the following area PRs and the two `139806` methods NAV master disables.
Removes E-Doc `135575`.

Related:
[AB#646383](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/646383),
[AB#653393](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/653393)

### Stack (each PR shows only its own layer; merge bottom first)
1. microsoft#12674 A: web service key auth (base: `main`)
2. microsoft#12675 B: Expense API tests + clean test codeunit execution
3. microsoft#12676 C: re-enable APIV1/APIV2 API tests
4. microsoft#12890 Review fixes for A: simplify web service key handling
5. Area fixes: microsoft#12677 D1 VAT fixtures → microsoft#12678 D2 cancellation reasons →
microsoft#12679 D3 localized discounts → microsoft#12680 D4 quote dates → microsoft#12681 D5
journal numbering → microsoft#12682 D6 field comparison → microsoft#12683 D7 PDF documents
→ microsoft#12684 D8 APIV1 reliability

Experiments (on D8, do not merge): microsoft#12685 E single tenant, microsoft#12686 F no
clean execution. Combined validation (do not merge): microsoft#12687, same tree
as D8.

Platform: `main` already pins BCPlatform 30.0.56112.0, which includes
the SQL connection-pool fix
([AB#653457](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/653457)).

Note for CI: AL-Go's new-warning check needs a CI/CD baseline from the
base branch, and `features/*` bases have none, so a PR build there fails
with a 404. The current CI runs were triggered while these PRs targeted
`main`, so their results are valid for the cumulative change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3952f078-a881-4da8-ad96-13b727e48a91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Build: Automation Workflows and other setup in .github folder Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants