Repository navigation
Add opt-in API test authentication providers #10085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
174 commits
Select commit
Hold shift + click to select a range
870b4f4
Fix API test authentication in BCApps
t-prda dedb354
Clarify credential file path parameter
t-prda 16f3424
Avoid sensitive parameter name false positive
t-prda 2ec8094
Scope API test authentication explicitly
t-prda 0193a4f
Place Graph auth bindings after test properties
t-prda 41fbc83
Fix E-Document Graph auth trigger placement
t-prda 11c5ec5
Declare Graph library for E-Document test binding
t-prda 3e3eacb
Resolve W1 warning failures
t-prda 44b1d30
Propagate prepayment warning suppression
t-prda e2cdd65
Qualify Graph auth helper namespace
t-prda ed5f78c
Import Graph auth helper dependencies
t-prda c025edb
Scope Graph password file check to OnPrem
t-prda 7488f41
Import System dotnet aliases for Graph auth
t-prda 5e670d6
Remove unused Graph auth namespace import
t-prda a412589
Address API auth review findings
t-prda aacaea5
Fix resumed PR validation failures
t-prda f63a482
Keep build optimization baseline unchanged
t-prda 0e9f2da
Update E-Document dependency count
t-prda 624b437
Restore E-Document Graph helper variable
t-prda 1aa001d
Narrow API test re-enablement
t-prda 6677c1e
Run Expense API tests with disabled isolation
t-prda fac14d9
Revert "Run Expense API tests with disabled isolation"
t-prda 16b5b9e
Enable Expense Agent API integration tests
t-prda 89f8d6b
Keep stateful capability API tests disabled
t-prda 9b063ea
Temporarily limit PR validation to W1
t-prda 5131fb6
Fix temporary W1 project paths
t-prda ad2b38e
Make capability API assertions row-specific
t-prda d88a833
Use baseline artifacts for W1-only validation
t-prda 74b131b
Benchmark test tenant refresh
t-prda 77997bb
Fix tenant refresh benchmark cleanup
t-prda c60eb68
Remove temporary tenant refresh benchmark
t-prda 59fc283
Run disabled-isolation tests on clean tenants
t-prda d809629
Enable APIV2 disabled-isolation tests
t-prda 26ef27f
Stub test discovery in PowerShell tests
t-prda ed3be0c
Run all APIV1 and APIV2 tests with disabled isolation
t-prda 3d3a6c1
Preauthenticate Graph API test requests
t-prda e9e26c3
Fix APIV2 test dates for CI license
t-prda 0cebd0e
Reuse APIV2 sales credit memo ERM library
t-prda b09233c
Scope clean tenant tests to configured apps
t-prda a180779
Initialize API test work dates consistently
t-prda 27bdffe
Fix purchase return shipment PDF report selection
t-prda e393e10
Fix isolated API test assertions
t-prda de891a8
Fix Automation RS Package clean runs
t-prda 2f478c8
Match APIV2 enablement to NAV web service bucket
t-prda 7f86625
Match all NAV API execution paths
t-prda 3612c1f
Validate clean tenants for required-isolation apps
t-prda 33c3f62
Build multitenant-safe API test URLs
t-prda f95a1c6
Use a license-safe API test work date
t-prda 8dabd83
Enable scheduler for clean API tests
t-prda 54d8180
Build nested API paths before tenant queries
t-prda 9c6b299
Remove unused API test library variable
t-prda f4f819b
Fix final API test record matching
t-prda 4ede6a1
Match APIV1 lines by composite identifiers
t-prda 7c32c28
Identify created APIV1 lines by description
t-prda c005c68
Use GUID descriptions for APIV1 line tests
t-prda 27f60fb
Scan document lines for APIV1 test records
t-prda c4eaac1
Reserve default tenant during clean test runs
t-prda d0114f5
Keep quality management integration ordering
t-prda a319973
Restore normal pull request validation
t-prda e5df951
Pin clean test retries to tenant results
t-prda 04a6a7e
Use localized-safe API test setup
t-prda 38cff89
Initialize localized API posting setup
t-prda a65ab83
Satisfy API test library analyzer
t-prda 128cc1a
Stabilize localized API test setup
t-prda 3cad877
Reuse graph journal test library variable
t-prda a8646da
Trigger API test validation
t-prda 9c5c023
Merge remote-tracking branch 'origin/main' into prdas/646383-api-test…
t-prda 1d98cc5
Merge latest main into API test branch
t-prda 5036be5
Migrate new expense activity API tests
t-prda fed7972
Create exact localized VAT setup keys
t-prda 74af994
Initialize localized API line setup
t-prda 691ee7c
Initialize API item charge posting setup
t-prda 962693f
Merge current API test exclusions
t-prda 37dc3cf
Stabilize remaining API test setup
t-prda 5513615
Run expense API tests on clean tenants
t-prda 6d38d5b
Exclude clean codeunits from normal test passes
t-prda 6a42664
Rebind activity API test authentication
t-prda 1a26ef4
Restore cleared API auth subscriptions
t-prda 5811206
Merge latest scheduler warmup changes
t-prda 10dfcdf
Bind activity API auth after cleanup
t-prda e0f0fe4
Refresh API auth before each request
t-prda 4e9af97
Apply API authentication directly
t-prda 5cde7a2
Persist shared API authentication state
t-prda 399810e
Apply environment-aware Graph authentication
t-prda 0fdaea9
Build tenant-safe activity API URLs
t-prda b4d6ba6
Disable regressed expense capability API test
t-prda f033391
Scope disabled tests by country
t-prda c627dfb
Track second India capability regression
t-prda ec8404a
Address API test review comments
t-prda 5fd8861
Document parallel test helpers
t-prda 3340b9f
Scope India capability cold-start exclusion
t-prda 8c22364
Remove obsolete API initialization state
t-prda b6c33c9
Merge latest test rerun infrastructure
t-prda 4775979
Migrate new expense policy API tests
t-prda 3955c2e
Fix newly enabled expense API tests
t-prda 4ee01ad
Load activity event type for API records
t-prda 3d08c14
Initialize activity API currency setup
t-prda aae2e00
Load activity fields before API trigger logic
t-prda 6cc8c30
Create valid submitted activity fixture
t-prda 48eb1d5
Unify clean and app retry state handling
t-prda 79fa9b6
Enable Task Scheduler before test execution
t-prda 7f83dd9
Address final API test review findings
t-prda 556ec6f
Migrate remaining Graph auth caller
t-prda 3b9bc36
Create reason codes for invoice cancellation tests
t-prda 90d2f99
Update E-Document dependency count
t-prda 450f5b2
Retry transient clean tenant database copies
t-prda 1938bb2
Use docker exec for clean tenant database copies
t-prda 0dc3ec8
Stub container script command in scheduler tests
t-prda e835162
Retry source tenant resolution for clean templates
t-prda f8fc045
Reuse known database name for clean template
t-prda 31a0526
Isolate task scheduler to clean test phase
t-prda d220a68
Restore clean tenants before normal tests
t-prda d3ff48d
Clarify background job variable scope
t-prda 2811a3e
Merge main into API test auth branch
t-prda 874c98a
Retrigger validation after main merge
t-prda fdfb2e1
Retrigger validation after Actions recovery
t-prda 51ba60b
Merge 30.0 obsolete-tag fixes from main
t-prda 43fb2db
Retry test metadata selection races
t-prda 89f74e8
Serialize clean tenant database resets
t-prda 16a4e42
Propagate test metadata race markers
t-prda ae60ea9
Batch clean tenant restores before tests
t-prda 7e6cb40
Retry clean API cold-start failures
t-prda 3ada2aa
Address final automated review findings
t-prda 6dcc9b6
Scope API test auth to current service
t-prda 19c741b
Address latest automated review findings
t-prda 8007e4e
Cache API auth outside request events
t-prda 4008dc4
Retrigger final validation
t-prda 8af221f
Merge latest main into API test auth branch
t-prda 0253fc0
Set license-safe date for assembly API tests
t-prda 700977d
Make API test authentication extensible
t-prda cb8753a
Merge latest main into API test auth branch
t-prda 65414f7
Remove stale API auth import
t-prda 68fa7ff
Fix API auth provider compilation
t-prda ae2cb7e
Align API auth interface syntax
t-prda 69c4289
Remove invalid global using directive
t-prda f817ae3
Fix API auth test compilation
t-prda 0904cab
Suppress legacy namespace warnings
t-prda a6fac87
Validate API authentication scheme
t-prda 6846d5c
Discover Disabled-isolation tests without an app allowlist
t-prda 04028c1
Remove unused country-specific test exclusions
t-prda 47551e7
Enable all Expense Agent test methods for parity validation
t-prda 921e890
Keep unrelated Expense Agent failures out of scope
t-prda c988cd4
Simplify API authentication and initialize providers per test instance
t-prda f47888c
Register Dimension Lines initialization regression during test discovery
t-prda 2a553ac
Avoid event-parameter shadowing in API provider tests
t-prda 6cd9bf1
Bound clean discovery and close API credential lifetime
t-prda 65d56fb
Use platform-neutral paths in credential cleanup tests
t-prda 396c38c
Refresh API auth branch while preserving deferred Expense tests
t-prda 1916826
Initialize auth once and reapply license-safe dates before fixtures
t-prda a4ed3c3
Fix Travel Request action-result assertions for runtime compilation
t-prda 2028f76
Bring in independently reviewed Travel Request compilation prerequisite
t-prda 86497ab
Compare formatted web service action results using the supported intr…
t-prda b05ed58
Refresh the independently reviewable action-result prerequisite
t-prda 6d1663c
Preserve fixture state and configured task scheduling during clean tests
t-prda 06308e1
Enable background tasks explicitly for Uncategorized API tests
t-prda 9b196da
Make Czech advance-payment posting fixtures self-contained
t-prda b85fcfb
Include the separately reviewable Czech fixture prerequisite
t-prda 25916ae
Avoid shadowing the automatic PROFILE variable in profile tests
t-prda 8d55682
Merge latest main before reassessing Expense test failures
t-prda 76d18ba
Temporarily defer confirmed Expense failures for dedicated stacked fixes
t-prda fd79dbd
Merge latest main and preserve scoped Expense test deferrals
t-prda 4c4b30f
Address API authentication and test-runner review feedback
t-prda 59c60a4
Use the declared web-service option type in URL test fixtures
t-prda 2f1a5d9
Keep work-date fixes limited to the agreed failure scope
t-prda f516524
Avoid immutable plaintext copies in API credential materialization
t-prda ae9265e
Merge current main and reconcile Expense test deferrals
t-prda 86ae50b
Construct synthetic credentials without the plaintext conversion flag
t-prda 9eede3e
Remove empty triggers and misleading AI-test feature labels
t-prda 303c0bf
Separate authentication core from pipeline and API uptake
t-prda 9e9365c
Use test-owned auth recording and isolate container credential lookup
t-prda 595eda2
Merge current main baseline into the API auth core
t-prda e766fc8
Name the mock auth event after its publisher position
t-prda 01dc1b9
Import test-library DotNet alias for private auth credential reader
t-prda 4a76bb7
Restore typed conversion for mock authentication credential
t-prda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
204 changes: 204 additions & 0 deletions
204
src/Layers/W1/Tests/Misc/APITestAuthProviderTests.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AA0247 | ||
|
|
||
| codeunit 139494 "API Test Auth Provider Tests" | ||
| { | ||
| EventSubscriberInstance = Manual; | ||
| Subtype = Test; | ||
| TestPermissions = Disabled; | ||
|
|
||
| trigger OnRun() | ||
| begin | ||
| // [FEATURE] [API Test Authentication] | ||
| end; | ||
|
|
||
| var | ||
| Assert: Codeunit Assert; | ||
| LibraryVariableStorage: Codeunit "Library - Variable Storage"; | ||
| APITestAuthProviderTests: Codeunit "API Test Auth Provider Tests"; | ||
| LibraryGraphMgt: Codeunit "Library - Graph Mgt"; | ||
| SecondLibraryGraphMgt: Codeunit "Library - Graph Mgt"; | ||
| FirstHttpWebRequestMgt: Codeunit "Http Web Request Mgt."; | ||
| SecondHttpWebRequestMgt: Codeunit "Http Web Request Mgt."; | ||
| IsInitialized: Boolean; | ||
| TargetURLTok: Label 'http://127.0.0.1/', Locked = true; | ||
| ProviderCallTok: Label 'Provider|%1', Locked = true, Comment = '%1 - Provider invocation number'; | ||
| EventCallTok: Label 'Event', Locked = true; | ||
| UnexpectedCallErr: Label 'Unexpected authentication call.'; | ||
|
|
||
| [Test] | ||
| procedure DefaultAuthenticationDoesNotConfigureRequest() | ||
| begin | ||
| // [SCENARIO] The default API test authentication does not configure the request | ||
| Initialize(); | ||
|
|
||
| // [GIVEN] A Graph library instance without an explicitly selected provider | ||
|
|
||
| // [WHEN] A web request is initialized | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(FirstHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [THEN] Only the final request event is raised | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNoRemainingCalls(); | ||
| end; | ||
|
|
||
| [Test] | ||
|
t-prda marked this conversation as resolved.
|
||
| procedure ExtendedAuthenticationProviderRunsBeforeFinalEvent() | ||
| begin | ||
| // [SCENARIO] An enum extension can provide API test authentication | ||
| Initialize(); | ||
|
|
||
| // [GIVEN] A Graph library instance using the mock authentication provider | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::Mock); | ||
|
|
||
| // [WHEN] A web request is initialized | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(FirstHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [THEN] The selected provider configures authentication | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 1)); | ||
|
|
||
| // [THEN] The final request event runs after the provider | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNoRemainingCalls(); | ||
| end; | ||
|
|
||
| [Test] | ||
| procedure AuthenticationProviderInstanceIsReused() | ||
| begin | ||
| // [SCENARIO] A selected authentication provider instance is reused across requests | ||
| Initialize(); | ||
|
|
||
| // [GIVEN] A Graph library instance using the mock authentication provider | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::Mock); | ||
|
|
||
| // [WHEN] Two web requests are initialized through the same Graph library instance | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(FirstHttpWebRequestMgt, TargetURLTok); | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(SecondHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [THEN] The same provider instance handles both requests | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 1)); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 2)); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNoRemainingCalls(); | ||
| end; | ||
|
|
||
| [Test] | ||
| procedure AuthenticationProviderSelectionIsInstanceScoped() | ||
| begin | ||
| // [SCENARIO] Authentication provider selection is scoped to a Graph library instance | ||
| Initialize(); | ||
|
|
||
| // [GIVEN] Two Graph library instances where only the first uses the mock provider | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::Mock); | ||
|
|
||
| // [WHEN] Each Graph library instance initializes a web request | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(FirstHttpWebRequestMgt, TargetURLTok); | ||
| SecondLibraryGraphMgt.InitializeWebRequestWithURL(SecondHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [THEN] Only the first request uses the mock provider | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 1)); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNoRemainingCalls(); | ||
| end; | ||
|
|
||
| [Test] | ||
| procedure RepeatedProviderSelectionPreservesInstance() | ||
| begin | ||
| // [SCENARIO] Repeated initialization with the same provider preserves its state | ||
| Initialize(); | ||
|
|
||
| // [GIVEN] A request has used the selected provider | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::Mock); | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(FirstHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [WHEN] Initialization selects the same provider before another request | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::Mock); | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(SecondHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [THEN] The provider instance retains its invocation count | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 1)); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 2)); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNoRemainingCalls(); | ||
| end; | ||
|
|
||
| [Test] | ||
| procedure SelectingNoneStopsConfiguringRequests() | ||
| begin | ||
| // [SCENARIO] Selecting None replaces the previously selected provider | ||
| Initialize(); | ||
|
|
||
| // [GIVEN] A request has used the mock provider | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::Mock); | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(FirstHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [WHEN] Authentication is deselected before another request | ||
| LibraryGraphMgt.SetAuthenticationProvider(Enum::"API Test Authentication"::None); | ||
| LibraryGraphMgt.InitializeWebRequestWithURL(SecondHttpWebRequestMgt, TargetURLTok); | ||
|
|
||
| // [THEN] Only the first request invokes the mock provider | ||
| VerifyNextCall(StrSubstNo(ProviderCallTok, 1)); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNextCall(EventCallTok); | ||
| VerifyNoRemainingCalls(); | ||
| end; | ||
|
|
||
| local procedure Initialize() | ||
|
t-prda marked this conversation as resolved.
t-prda marked this conversation as resolved.
|
||
| begin | ||
| Clear(LibraryGraphMgt); | ||
| Clear(SecondLibraryGraphMgt); | ||
| Clear(FirstHttpWebRequestMgt); | ||
| Clear(SecondHttpWebRequestMgt); | ||
| // The manually bound instance owns both recording and verification, including cleanup after a failed test. | ||
| APITestAuthProviderTests.ClearRecordedCalls(); | ||
| if IsInitialized then | ||
| exit; | ||
|
|
||
| BindSubscription(APITestAuthProviderTests); | ||
|
t-prda marked this conversation as resolved.
|
||
| IsInitialized := true; | ||
| end; | ||
|
|
||
| local procedure VerifyNextCall(ExpectedCall: Text) | ||
| begin | ||
| APITestAuthProviderTests.VerifyRecordedCall(ExpectedCall); | ||
| end; | ||
|
|
||
| local procedure VerifyNoRemainingCalls() | ||
| begin | ||
| APITestAuthProviderTests.VerifyRecordedCallsEmpty(); | ||
| end; | ||
|
|
||
| internal procedure ClearRecordedCalls() | ||
| begin | ||
| LibraryVariableStorage.Clear(); | ||
| end; | ||
|
|
||
| internal procedure VerifyRecordedCall(ExpectedCall: Text) | ||
| begin | ||
| Assert.AreEqual(ExpectedCall, LibraryVariableStorage.DequeueText(), UnexpectedCallErr); | ||
| end; | ||
|
|
||
| internal procedure VerifyRecordedCallsEmpty() | ||
| begin | ||
| LibraryVariableStorage.AssertEmpty(); | ||
| end; | ||
|
|
||
| [EventSubscriber(ObjectType::Codeunit, Codeunit::"Mock API Test Auth Provider", OnAfterConfigureAuthentication, '', false, false)] | ||
| local procedure RecordProviderInvocation(InvocationNumber: Integer) | ||
| begin | ||
| LibraryVariableStorage.Enqueue(StrSubstNo(ProviderCallTok, InvocationNumber)); | ||
| end; | ||
|
|
||
| [EventSubscriber(ObjectType::Codeunit, Codeunit::"Library - Graph Mgt", OnAfterInitializeWebRequestWithURL, '', false, false)] | ||
| local procedure RecordFinalRequestEvent(var HttpWebRequestMgt: Codeunit "Http Web Request Mgt.") | ||
| begin | ||
| LibraryVariableStorage.Enqueue(EventCallTok); | ||
| end; | ||
| } | ||
14 changes: 14 additions & 0 deletions
14
src/Layers/W1/Tests/Misc/APITestAuthenticationTest.EnumExt.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AA0247 | ||
|
|
||
| enumextension 139492 "API Test Authentication Test" extends "API Test Authentication" | ||
| { | ||
| value(139492; Mock) | ||
| { | ||
| Implementation = "API Test Auth Provider" = "Mock API Test Auth Provider"; | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/Layers/W1/Tests/Misc/MockAPITestAuthProvider.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AA0247 | ||
|
|
||
| codeunit 139493 "Mock API Test Auth Provider" implements "API Test Auth Provider" | ||
| { | ||
| Access = Internal; | ||
|
|
||
| var | ||
| InvocationCount: Integer; | ||
| PasswordTxt: Label 'Password', Locked = true; | ||
|
|
||
| /// <summary> | ||
| /// Records an invocation and configures Basic authentication for the request. | ||
| /// </summary> | ||
| /// <param name="Authentication">The authentication context to configure.</param> | ||
| procedure ConfigureAuthentication(var Authentication: Codeunit "API Test Auth Context") | ||
| var | ||
| Password: SecretText; | ||
|
t-prda marked this conversation as resolved.
|
||
| PasswordText: Text; | ||
| begin | ||
| InvocationCount += 1; | ||
| PasswordText := PasswordTxt; | ||
| Password := PasswordText; | ||
| Authentication.SetBasicAuthentication('User', Password); | ||
| OnAfterConfigureAuthentication(InvocationCount); | ||
| end; | ||
|
|
||
| [IntegrationEvent(false, false)] | ||
| local procedure OnAfterConfigureAuthentication(InvocationNumber: Integer) | ||
| begin | ||
| end; | ||
| } | ||
39 changes: 39 additions & 0 deletions
39
src/Layers/W1/Tests/TestLibraries/APITestAuthContext.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AA0247 | ||
|
|
||
| /// <summary> | ||
| /// Stores authentication configuration for an API test request. | ||
| /// </summary> | ||
| codeunit 131023 "API Test Auth Context" | ||
| { | ||
| var | ||
| BasicUserName: Text; | ||
| BasicPassword: SecretText; | ||
| BasicAuthenticationConfigured: Boolean; | ||
|
|
||
| /// <summary> | ||
| /// Configures Basic authentication for the API test request. | ||
| /// </summary> | ||
| /// <param name="UserName">The user name used for Basic authentication.</param> | ||
| /// <param name="Password">The password used for Basic authentication.</param> | ||
| procedure SetBasicAuthentication(UserName: Text; Password: SecretText) | ||
| begin | ||
| BasicUserName := UserName; | ||
| BasicPassword := Password; | ||
| BasicAuthenticationConfigured := true; | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// Applies the configured authentication to the API test request. | ||
| /// </summary> | ||
| /// <param name="HttpWebRequestMgt">The request to authenticate.</param> | ||
| internal procedure Apply(var HttpWebRequestMgt: Codeunit "Http Web Request Mgt.") | ||
| begin | ||
| if BasicAuthenticationConfigured then | ||
| HttpWebRequestMgt.AddBasicAuthentication(BasicUserName, BasicPassword); | ||
| end; | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/Layers/W1/Tests/TestLibraries/APITestAuthProvider.Interface.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AA0247 | ||
|
|
||
| /// <summary> | ||
| /// Provides authentication configuration for API test requests. | ||
| /// </summary> | ||
| interface "API Test Auth Provider" | ||
| { | ||
| /// <summary> | ||
| /// Configures authentication for an API test request. | ||
| /// </summary> | ||
| /// <param name="Authentication">The authentication context to configure.</param> | ||
| procedure ConfigureAuthentication(var Authentication: Codeunit "API Test Auth Context"); | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/Layers/W1/Tests/TestLibraries/APITestAuthentication.Enum.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| #pragma warning disable AA0247 | ||
|
|
||
| /// <summary> | ||
| /// Specifies the authentication provider used for API test requests. | ||
| /// </summary> | ||
| enum 131023 "API Test Authentication" implements "API Test Auth Provider" | ||
|
t-prda marked this conversation as resolved.
|
||
| { | ||
| Extensible = true; | ||
| DefaultImplementation = "API Test Auth Provider" = "No API Test Auth Provider"; | ||
|
|
||
| value(0; None) | ||
| { | ||
| Caption = 'None'; | ||
| Implementation = "API Test Auth Provider" = "No API Test Auth Provider"; | ||
| } | ||
| value(1; "Microsoft Test Environment") | ||
|
t-prda marked this conversation as resolved.
|
||
| { | ||
| Caption = 'Microsoft Test Environment'; | ||
| Implementation = "API Test Auth Provider" = "Microsoft Test Auth Provider"; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.