Repository navigation
Refactor Native Auth V2 state inheritance, Fixes AB#3739969 - #2614
Silviu Petrescu (spetrescu84) merged 4 commits into
Conversation
Separate shared correlation metadata from the V1 raw-token contract. Remove V2 token placeholders and their parcel slot without changing authentication flows or the opaque Common continuation state. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Refactors Native Auth V2 state inheritance to remove the legacy V1 raw continuation-token contract from V2 states while preserving V1 behavior, and updates unit tests to validate the new parcel layout and saved-state restoration behavior.
Changes:
- Introduces a correlation-only
NativeAuthStatebase and moves V2 states offBaseState(V1 raw-token contract). - Removes the V2 raw-token placeholder from constructors/parcels and updates V2 state Parcelable read/write expectations.
- Expands/updates tests to verify V2 parcel prefix, round-trip parcelability for all V2 states, and Bundle saved-instance-state restoration with configuration reinitialization.
| File | Description |
|---|---|
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/BaseStates.kt | Adds NativeAuthState and updates V1 BaseState to extend it (shared correlation metadata). |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/NativeAuthBaseStateV2.kt | Removes legacy continuation-token placeholder from V2 base state and updates parcel write order/documentation. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/CodeRequiredStateV2.kt | Updates V2 state constructor/parcel ctor to match new V2 base-state contract. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/PasswordRequiredStateV2.kt | Same: removes raw-token plumbing from V2 state construction/parceling. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/NewPasswordRequiredStateV2.kt | Same: aligns with new V2 base-state contract. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/AttributesRequiredStateV2.kt | Same: aligns with new V2 base-state contract. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/AttributesInvalidStateV2.kt | Same: aligns with new V2 base-state contract. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/MFARequiredStateV2.kt | Same: removes raw-token placeholder and updates parcel constructor ordering. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/MFAVerificationRequiredStateV2.kt | Same: aligns state parceling with new V2 base write order. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/ResetPasswordMethodRequiredStateV2.kt | Same: removes raw-token placeholder from V2 state plumbing. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/SignInAfterResetPasswordStateV2.kt | Same: removes raw-token placeholder and updates parcel ctor ordering. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/SignInAfterSignUpStateV2.kt | Same: removes raw-token placeholder and updates parcel ctor ordering. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/StrongAuthRegistrationRequiredStateV2.kt | Same: removes raw-token placeholder and updates parcel ctor ordering. |
| msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/StrongAuthVerificationRequiredStateV2.kt | Same: removes raw-token placeholder and updates parcel ctor ordering. |
| msal/src/test/java/com/microsoft/identity/nativeauth/v2/NativeAuthV2StatesTest.kt | Adds/updates regression tests for V2 inheritance and parcel prefix/order; expands V2 parcel round-trip checks. |
| msal/src/test/java/com/microsoft/identity/nativeauth/v2/NativeAuthV2ResultsTest.kt | Updates result tests to construct V2 next-states without legacy continuation token. |
| msal/src/test/java/com/microsoft/identity/nativeauth/v2/NativeAuthV2SignInTest.kt | Removes V2 continuation-token assertions and updates Parcel round-trip helper to marshall/unmarshall. |
| msal/src/test/java/com/microsoft/identity/nativeauth/v2/NativeAuthV2SignUpTest.kt | Removes V2 continuation-token assertions consistent with refactor. |
| msal/src/test/java/com/microsoft/identity/nativeauth/v2/NativeAuthV2InterfaceKotlinTest.kt | Updates invalid-state test construction and adds Bundle restore + config reinit coverage. |
| msal/src/test/java/com/microsoft/identity/nativeauth/v2/NativeAuthV2InterfaceJavaTest.java | Updates Java API tests to construct V2 states without legacy continuation token. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
❌ Work item link check failed. Description contains AB#3739969 but the Bot could not link it to an Azure Boards work item. Click here to learn more. |
Update assertion for continuation state string to check for redacted content and ensure scope is not included. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
Leave V1 BaseState unchanged and let NativeAuthBaseStateV2 own its correlation metadata without a shared superclass. Add a hierarchy regression assertion. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
✅ Work item link check complete. Description contains link AB#3739969 to an Azure Boards work item. |

Summary
Refactor Native Auth V2 state inheritance so V2 states do not inherit the V1 continuation-token placeholder, addressing
BaseStateunchanged, including its hierarchy, constructor, declared virtual getters, continuation-token behavior, and parcel prefix.NativeAuthBaseStateV2implementStateandParcelabledirectly, owning its correlation ID and opaque continuation state without introducing a shared V1/V2 superclass.NativeAuthV2ContinuationStateunchanged.Compatibility and scope
V2 has not shipped, so the V2 hierarchy and parcel layout are intentionally updated without a legacy-format reader or token placeholder. V1
BaseStates.ktis identical to the merge-base version. No new shared public abstraction is introduced.This is an MSAL-only change. No Common changes or submodule updates are required. Azure Boards linking and work-item updates are intentionally deferred at the author's request.
Coverage
BaseStateandNativeAuthBaseStateV2both extendObjectdirectly.Validation
Latest simplification (
2905a5bb4)git diff --checkpassed, and V1BaseStates.ktwas verified unchanged relative to the merge base.The new hierarchy test and the scoped V2/command-parameter suite were attempted locally, but dependency resolution blocked compilation: the NewAndroid Maven feed returned HTTP 401 for AndroidX and AAPT2 dependencies. An offline retry also failed because those dependencies were not cached. No passing test result is claimed for this commit; the new hierarchy assertion has not been executed.
Earlier refactor validation (before the latest simplification)
The previous PR description recorded 210 targeted tests passed with zero failures using:
The earlier scoped code review found no correctness, API, or Parcelable regressions. These results predate
2905a5bb4and do not validate the latest simplification.Earlier local live Native Auth V2 E2E verification
On October 5, 2026, the exact test sources from PR 2601 (commit
d579ac981b1740987fa3a57e187d1af80a6fda1f) were temporarily overlaid onto this PR's refactor commit5c9a56871e78dacaf4d98e4f0755cbecc7f06d88and run locally against live services, not the mock API.SignUpV2EmailOTPTest)SignUpV2EmailPasswordTest)SSPRV2Test)NativeAuthRequestRecorderTest)All 20 live E2E scenarios and all 4 recorder unit tests passed, with zero failures, errors, or skipped tests. Counts were verified from fresh JUnit XML reports, not just the Gradle exit code.
The local run used
:msal:testLocalDebugUnitTestwith explicit selectors for the four suites above,-Plabtestto enable network tests, and-PuseMockApiForNativeAuth=false. The existing local Native Auth configuration was used;emailProviderPasswordfrom local Gradle properties was supplied to the test worker asEMAIL_PROVIDER_PASSWORDwithout exposing the value.This is historical local verification, not a claim that these tests ran in the pipeline or on the latest simplification. The temporary test overlay and local credential bridge were removed afterward; this PR includes no additional E2E test files or credentials.
Existing limitations, unchanged by this refactor
NativeAuthPublicClientApplicationConfigurationserializes its own fields, but its non-serializable superclass configuration fields, Android Context, and token cache are not retained. The saved-state continuation test explicitly reinitializes these dependencies and does not claim automatic recovery of runtime configuration. The opaque continuation DTO itself is restored rather than replaced.AB#3739969