Repository navigation
[API tests] Default to web service key authentication - #12674
Prangshuman Das (t-prda) wants to merge 1 commit into
Conversation
e8e2b21 to
3a7dc6e
Compare
Good Sense Reviewer - Round 1Recommendation: Request ChangesWhat this PR doesThis change makes API test requests use the current user's web service key for NavUserPassword containers, removes the pipeline-managed password files, and allows calls to the container's local endpoint. The key reuse and expiry checks match the authentication goal, but the provider commits the caller's transaction and the enum update removes public symbols, so the current implementation can give wrong test results and break dependent test apps. Problem-solution fitFit: Partial The change removes the external credential dependency and covers key creation and renewal. The transaction side effect and compatibility break mean it does not yet provide a safe default for all existing API tests. SuggestionsS1 (🔴 High): Preserve the existing enum values S2 (🔴 High): Move key creation outside request transactions S3 (🟠 Moderate): Avoid persisting current user key changes Risk assessment and necessityRisk: The default provider is used by every Necessity: Removing the pipeline-managed password and making API authentication self-contained is needed to restore reliable API coverage. The core direction is sound, but the key must be provisioned without committing arbitrary test work and the existing public enum surface should remain compatible.
|
3a7dc6e to
541d2af
Compare
|
Thanks for the review. Replies per suggestion: S1 (enum values) — Not a compatibility break in practice. S2 (Commit during key creation) — Agreed this is a real concern; discussing the approach and will follow up here. S3 (current user key) — In CI, CU 139494 runs with |
541d2af to
715f638
Compare
715f638 to
ee1c82a
Compare
|
S2 (Commit during key creation): addressed in ee1c82a. S3: the three test comments now say "current user" instead of "disposable test user". No restore logic, as discussed above. |
|
The public CreateTargetURLWithTwoSubpages procedure in the library codeunit has no XML documentation. Add a summary describing the URL construction and a param tag for each of its six parameters. 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 |
Good Sense Reviewer - Round 2Recommendation: Request ChangesWhat this PR doesThe update moves web service key creation to a separate background session, so it no longer commits the caller's transaction. That fixes the original transaction problem, but the default provider can now fail before the HTTP request when it is called from a normally isolated test codeunit. Status of previous suggestions
New observations (commits since round 1)S4 (🔴 High): Create the key before isolated tests run Risk assessment and necessityRisk: The default provider is shared by API test callers. Several callers use the normal test runner with codeunit isolation, while the new provider test disables isolation, so the added tests do not cover the failing caller context. The separate session otherwise removes the caller-transaction commit risk, and the enum values are not present in release branches. Necessity: Self-contained API authentication is needed to remove the pipeline credential dependency and restore API coverage. The key must be provisioned outside an isolated test transaction so the default works for existing API test codeunits.
|
Authenticate API test requests with the current user's web service key and remove the container password and Key Vault credential plumbing (ApiTestCredential, password cleanup, PipelineFinalize hooks). Containers disable NavHttpClient anti-SSRF so API tests can call the local server. Clean-tenant execution logic is unchanged. Adds the shared SetLicenseSafeWorkDate and AddFieldToIgnoreIfExists helpers to Library - Graph Mgt. AB#646383 AB#653393 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3952f078-a881-4da8-ad96-13b727e48a91
ee1c82a to
0bfb1b2
Compare
|
S4: agreed, and CI confirmed it:
On provisioning at the runner or clean-tenant boundary: each clean tenant is copied from a template taken before any test runs, so a key provisioned in the pipeline would remove the in-test creation in CI. I kept the library self-contained instead, so local runs and NAV need no pipeline setup. It can be added later as an optimization if wanted. |
Good Sense Reviewer - Round 3Recommendation: Request ChangesWhat this PR doesThe latest change handles the test-isolation Status of previous suggestions
New observations (commits since round 2)None - the latest change addresses S4 but reopens S2. Risk assessment and necessityRisk: The default provider is shared by API test codeunits, and several requests run inside Necessity: Self-contained API authentication is needed to remove pipeline credential handling and restore portable API coverage. Key creation must still avoid committing the caller's assertion transaction.
|
Review focus:
MicrosoftTestAuthProvider(about 60 lines) and the enum default; thebuild/changes are deletions plus the anti-SSRF line inNewBcContainer.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 Authenticationenum:DefaultImplementation=Microsoft Test Auth Provider. RemovesNo API Test Auth Providerand the explicitMicrosoft Test Environmentvalue.Microsoft Test Auth Provider: on-premises with NavUserPassword, sends Basic auth withUserId()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 theSetLicenseSafeWorkDateandAddFieldToIgnoreIfExistshelpers used by later layers.ApiTestCredential.psm1,Remove-ApiTestPassword.ps1,PipelineFinalizehooks and their tests). Keeps the clean-tenant execution logic. SetsNavHttpClientAntiSSRFEnabled=falsein the test container, as NAVRunALTests.ps1does: since Migrate API test libraries off Http Web Request Mgt. #12323, API tests call the container's own endpoint through ALHttpClient, which anti-SSRF blocks.API Test Auth Provider Tests: covers key creation and renewal. DeclaresTestHttpRequestPolicy = AllowAllOutboundRequests(NAV blocks outbound requests by default; Allow API tests to issue local HTTP requests #12694 covered the other API tests).Related: AB#646383, AB#653393
Stack (each PR shows only its own layer; merge bottom first)
main)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:
mainalready 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 targetedmain, so their results are valid for the cumulative change.