Further test expansion#1035
Open
Avery-Dunn wants to merge 7 commits into
Open
Conversation
RyAuld
approved these changes
Jun 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR continues the systematic unit test expansion from Standardize and expand unit tests
, targeting the remaining coverage gaps identified in a second JaCoCo analysis. It adds ~150 new unit tests across 4 class groups covering response/error parsing, credentials, instance discovery, WS-Trust/federation, and miscellaneous gaps — bringing overall project coverage from 76.2% → 81.3% line and 63.0% → 67.7% branch.
Several pre-existing bugs were discovered and documented during testing (ErrorResponse.toJson double-start, RequestedClaim.toJson invalid write, OidcDiscoveryResponse.toJson missing issuer). Tests document current behavior without masking or fixing these bugs.
Test Results
Changes by Group
Group A: Response & Error Parsing (ResponseParsingTest.java — 47 tests total, 34 new)
Tests JSON-serializable response and claim classes: ErrorResponse, UserDiscoveryResponse, OidcDiscoveryResponse, RequestedClaimAdditionalInfo, RequestedClaim, ClientInfo, MsalServiceException, MsalServiceExceptionFactory.
Includes private
mockHttpResponse()andjsonContentTypeHeaders()helpers to reduce duplication in exception factory tests.Bugs documented:
ErrorResponse.toJson()— callswriteStartObject()twice, causingIllegalStateExceptionRequestedClaim.toJson()— writes raw string in object context (invalid JSON)OidcDiscoveryResponse.toJson()— omitsissuerfieldGroup B: Token Acquisition & Credentials (ClientCredentialTest.java — 35 tests, +29 new; ClientCertificateTest.java — 13 tests, +6 new)
Tests ClientAssertion (all 3 provider types), ClientSecret, ClientCredentialFactory, and ClientCertificate.
Covers: context-aware assertion providers, callable error paths, equals/hashCode contracts, factory validation, SHA-1/SHA-256 hashing, cert chain encoding, assertion generation.
Group C: Instance Discovery & Managed Identity Parsing (InstanceDiscoveryParsingTest.java — 11 new; ManagedIdentityParsingTest.java — 13 new)
Tests AadInstanceDiscoveryResponse, InstanceDiscoveryMetadataEntry, ManagedIdentityResponse, and ManagedIdentityErrorResponse JSON parsing.
Covers: all fields, partial/unknown fields, round-trip serialization, nested error object format, string error format.
Group D: WS-Trust & Federation (WsTrustFederationTest.java — 19 new; WSTrustRequestTest.java — +6 new)
Tests Credential, BindingPolicy, IntegratedWindowsAuthorizationGrant, IdToken, WSTrustVersion, and WSTrustRequest message building.
Covers: JSON serialization/round-trip, all getters/setters, IWA grant parameters, namespace URIs, security header, XML escaping.
Miscellaneous Coverage Gaps (distributed to existing test classes)
Tests for remaining low-coverage utility/helper classes, placed in contextually appropriate homes:
AcquireTokenSilentlyTestParameterBuilderTestWSTrustResponseTest.java — Expanded (1 → 9 tests)
Existing test expanded to cover token parsing, error handling, token type detection, and XML extraction.
Code Quality Improvements
@TestInstance(PER_CLASS)from 4 test classes that had no shared mutable state (ClientCertificateTest,ClientCertificatePkcs12Test,SovereignCloudInstanceDiscoveryTest,WSTrustRequestTest)import staticlines with wildcardimport static org.junit.jupiter.api.Assertions.*inAcquireTokenSilentlyTestjava.util.Base64,java.nio.charset.StandardCharsets,org.slf4j.Loggerto proper importsmockHttpResponse()andjsonContentTypeHeaders()inResponseParsingTesteliminate repetitive mock setupTestHelper.parseJson(),TestHelper.writeToJson(), andTestHelper.JsonParser<T>interface (added in this branch) used by 4+ test files