Skip to content

test: Phase 5 - Add comprehensive unit tests for Auth, Migration, and CLI E2E tests#106

Merged
joshsmithxrm merged 20 commits intomainfrom
feature/testing-phase5-unit-tests
Jan 3, 2026
Merged

test: Phase 5 - Add comprehensive unit tests for Auth, Migration, and CLI E2E tests#106
joshsmithxrm merged 20 commits intomainfrom
feature/testing-phase5-unit-tests

Conversation

@joshsmithxrm
Copy link
Copy Markdown
Owner

Summary

Completes Phase 5 of Issue #55 (Integration Testing Infrastructure) by adding comprehensive unit tests for PPDS.Auth and PPDS.Migration packages, plus CLI E2E tests for auth, env, and schema commands.

What's Included

New Test Projects

Project Tests Coverage
PPDS.Auth.Tests 282 Profiles, credentials, discovery, cloud, pooling
PPDS.Migration.Tests 200 Models, formats, analysis, import/export, progress
CLI E2E (LiveTests/Cli) 27 auth, env, data schema commands

Test Breakdown

PPDS.Auth.Tests (282 tests):

  • Profiles: ProfileCollection, AuthProfile, ProfileStore, ProfileEncryption, ProfilePaths, EnvironmentInfo
  • Credentials: CredentialProviderFactory, JwtClaimsParser, AuthenticationException
  • Discovery: EnvironmentResolver, DiscoveredEnvironment
  • Cloud: CloudEndpoints
  • Pooling: ConnectionResolver

PPDS.Migration.Tests (200 tests):

  • Models: EntitySchema, FieldSchema, RelationshipSchema, MigrationSchema, MigrationData, DependencyGraph, ExecutionPlan, IdMapping, UserMapping
  • Formats: CmtSchemaReader/Writer, CmtDataReader/Writer, UserMappingReader
  • Analysis: DependencyGraphBuilder, ExecutionPlanBuilder
  • Import/Export: Options, Results
  • Progress: ProgressEventArgs, MigrationResult

CLI E2E Tests (27 tests):

  • AuthCommandE2ETests - list, who, create, delete, select, clear, validation
  • EnvCommandE2ETests - list, who, select, org alias
  • DataSchemaCommandE2ETests - schema generation, options, errors

Infrastructure

  • .env.example and scripts/Load-TestEnv.ps1 for local integration test setup
  • scripts/Test-NewCodeCoverage.ps1 for pre-PR validation
  • Updated .gitignore for .env.local

Documentation

Test Results

Total: 1,147 unit tests (excluding integration)
- PPDS.Plugins.Tests: 77
- PPDS.Dataverse.Tests: 351
- PPDS.Cli.Tests: 210
- PPDS.Auth.Tests: 282
- PPDS.Migration.Tests: 200
- CLI E2E: 27

All tests passing across net8.0, net9.0, net10.0.

Test plan

  • dotnet build -c Release --warnaserror passes
  • dotnet test --filter "Category!=Integration" passes
  • No TODOs/FIXMEs in test code
  • No Console.WriteLine in library test code
  • Documentation updated

Related Issues

🤖 Generated with Claude Code

joshsmithxrm and others added 10 commits January 2, 2026 18:46
- Update project structure to include integration test projects
- Update testing table to show unit vs integration test status
- Add LiveTests section documenting existing coverage
- Mark Auth/Migration unit tests and CLI E2E as pending

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add .env.example template for test credentials
- Add Load-TestEnv.ps1 script to load .env.local into session
- Update .gitignore to exclude .env.local files
- Document local integration test setup in CLAUDE.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update project structure to include integration test projects
- Update testing table to show unit vs integration test status
- Add LiveTests section documenting existing coverage
- Mark Auth/Migration unit tests and CLI E2E as pending

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add .env.example template for test credentials
- Add Load-TestEnv.ps1 script to load .env.local into session
- Update .gitignore to exclude .env.local files
- Document local integration test setup in CLAUDE.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Test-NewCodeCoverage.ps1 to check new code has tests
- Compares branch to main, finds new .cs files in src/
- Checks for corresponding test files in tests/
- Excludes interfaces, exceptions, options (don't need tests)
- Update /pre-pr command to reference the script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Codecov badge to README
- Create docs/COVERAGE_BASELINE.md with per-package baseline
- Documents current coverage vs targets from Issue #55

Closes #84

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 5 completion for Issue #55:

PPDS.Auth.Tests (282 tests):
- ProfileCollection, AuthProfile, ProfileStore, ProfileEncryption, ProfilePaths
- CredentialProviderFactory, JwtClaimsParser, AuthenticationException
- EnvironmentResolver, DiscoveredEnvironment
- CloudEndpoints, ConnectionResolver

PPDS.Migration.Tests (200 tests):
- All model classes (EntitySchema, FieldSchema, etc.)
- Format readers/writers (CmtSchemaReader, CmtSchemaWriter, etc.)
- Analysis (DependencyGraphBuilder, ExecutionPlanBuilder)
- Import/Export options and results
- Progress reporters

CLI E2E Tests (PPDS.LiveTests/Cli):
- AuthCommandE2ETests - auth list, who, create, delete, select
- EnvCommandE2ETests - env list, who, select
- DataSchemaCommandE2ETests - data schema generation

Updated CLAUDE.md testing table with all packages at ✅ status.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update baseline table with actual test counts (1,147 total tests)
- Mark Phase 5 checkboxes complete (Auth.Tests, Migration.Tests, CLI E2E)
- Add CLI E2E coverage matrix showing current vs pending coverage
- Add Future Work section with plan for data migration E2E tests
- Link to Issue #104 for E2E expansion tracking
- Add test project summary table

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Git history is the source of truth for document timestamps.
Manual dates create maintenance burden and can become misleading.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 3, 2026 03:07
@joshsmithxrm joshsmithxrm self-assigned this Jan 3, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @joshsmithxrm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request marks the successful completion of Phase 5 of the integration testing infrastructure initiative. It significantly bolsters the project's test suite by introducing extensive unit tests for the PPDS.Auth and PPDS.Migration packages, alongside critical end-to-end tests for the CLI. These additions aim to improve code quality, prevent regressions, and provide a more reliable development experience. The PR also includes new tooling and documentation to support and track ongoing testing efforts.

Highlights

  • Expanded Test Coverage for Auth Package: Introduced 282 new unit tests for the PPDS.Auth package, comprehensively covering profiles, credentials, discovery, cloud, and connection pooling functionalities to ensure robust authentication mechanisms.
  • Migration Module Unit Tests: Added 200 new unit tests for the PPDS.Migration package, focusing on models, data formats, dependency analysis, import/export options, and progress reporting, significantly enhancing the reliability of data migration processes.
  • CLI End-to-End (E2E) Tests: Implemented 27 new E2E tests for the command-line interface (CLI), specifically validating the auth, env, and data schema commands to ensure their correct behavior in live environments.
  • Enhanced Testing Infrastructure: Introduced new PowerShell scripts (Load-TestEnv.ps1, Test-NewCodeCoverage.ps1) and an .env.example file to streamline local integration test setup, manage environment variables, and enforce pre-PR code coverage validation.
  • Updated Documentation and Future Planning: Updated CLAUDE.md and created docs/COVERAGE_BASELINE.md to reflect the expanded test coverage, outline current status, and detail future plans for CLI E2E expansion (Issues CLI E2E Test Expansion: Data Migration and Plugin Commands #104, CLI E2E Tests: Plugin Commands (extract, list, deploy, diff, clean) #105).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes Phase 5 of Issue #55 by adding comprehensive test coverage across three major areas: PPDS.Auth (282 tests), PPDS.Migration (200 tests), and CLI E2E tests (27 tests). The total test count now reaches 1,147 tests across the SDK, bringing the overall estimated coverage to ~58%.

Key Changes:

  • Added PPDS.Auth.Tests project covering profiles, credentials, discovery, cloud endpoints, and pooling
  • Added PPDS.Migration.Tests project covering models, formats, analysis, and import/export options
  • Extended PPDS.LiveTests with CLI E2E tests for auth, env, and data schema commands
  • Created test infrastructure with .env.example, Load-TestEnv.ps1, and Test-NewCodeCoverage.ps1
  • Updated documentation in CLAUDE.md, COVERAGE_BASELINE.md, and README.md

Reviewed changes

Copilot reviewed 50 out of 51 changed files in this pull request and generated 26 comments.

Show a summary per file
File Description
tests/PPDS.Auth.Tests/PPDS.Auth.Tests.csproj New test project targeting net8.0/9.0/10.0 with xunit 2.9.3 and FluentAssertions 8.8.0
tests/PPDS.Migration.Tests/PPDS.Migration.Tests.csproj New test project with identical dependencies and structure
tests/PPDS.Auth.Tests/Profiles/* 282 tests covering ProfileCollection, AuthProfile, ProfileStore, ProfileEncryption, ProfilePaths, EnvironmentInfo
tests/PPDS.Migration.Tests/Models/* 200 tests covering schema models, execution plans, dependency graphs, ID/user mappings
tests/PPDS.LiveTests/Cli/* 27 E2E tests for auth, env, and data schema CLI commands
scripts/Load-TestEnv.ps1 PowerShell script to load .env.local for integration tests
scripts/Test-NewCodeCoverage.ps1 Pre-PR validation script checking test coverage for new code
docs/COVERAGE_BASELINE.md Comprehensive coverage tracking with targets per package
CLAUDE.md Updated testing requirements and local setup instructions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is an excellent pull request that significantly boosts the project's test coverage. The addition of comprehensive unit tests for the PPDS.Auth and PPDS.Migration packages, along with new CLI E2E tests, is a major step forward for the project's stability and maintainability. The new testing infrastructure, including the .env.example for local setup and the PowerShell scripts for loading test environments and checking coverage, is well-designed and will be very valuable for future development.

The tests themselves are thorough, well-structured, and cover a wide range of scenarios, including edge cases and error conditions. The quality of the new code is very high.

I have found one minor issue in the new code coverage script related to path handling that could make it brittle. My feedback includes a suggestion to improve its robustness. Overall, this is a fantastic contribution to the project.

Copy link
Copy Markdown

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

joshsmithxrm and others added 4 commits January 2, 2026 21:58
PPDS.Cli targets net8.0;net9.0;net10.0, so dotnet run requires
--framework to be specified. Use net8.0 (LTS) since CLI wrapper
behavior is framework-agnostic and libraries are already tested
per-TFM via LiveTests/Authentication/*, Pooling/*, etc.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add using statements for MemoryStream/StreamReader in test files
  (CmtSchemaReaderTests, CmtSchemaWriterTests, UserMappingReaderTests)
- Remove unused variable capture in IdMappingTests.ThreadSafety_ConcurrentAdds
- Add CERT to sensitive value masking pattern in Load-TestEnv.ps1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove (Preview) from GitHub/Azure DevOps federated auth options
- Remove PAC CLI references from code comments (ADR context retained)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use /comments/{id}/replies endpoint instead of base comments endpoint
with in_reply_to parameter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CI builds with Release configuration, but dotnet run --no-build
defaults to Debug. Must specify matching configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wrap client usage in try-catch to dispose on any exception, not just
IsReady failure. Fixes CodeQL cs/dispose-not-called-on-throw alerts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
joshsmithxrm and others added 2 commits January 2, 2026 23:00
Fixes:
- AuthList_JsonFormat: Fixed assertion to not require activeIndex
  (omitted from JSON when null due to WhenWritingNull serializer option)
- DataSchema_InvalidEntity: CLI now fails when no entities are found
  instead of silently returning empty schema with exit code 0
- EnvList timeout: Removed test that times out because Global Discovery
  Service doesn't support service principal authentication
- AuthDelete race condition: Added PPDS_CONFIG_DIR env var support and
  test isolation - each test instance uses unique config directory

The test isolation prevents race conditions when tests run in parallel
across multiple target frameworks (net8, net9, net10).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CLI E2E tests spawn the CLI with `--framework net8.0`, so running
them on net9.0 and net10.0 was testing the exact same CLI binary
3 times. This was also the source of the race condition where
multiple TFMs simultaneously wrote to the shared profile store.

Changes:
- Add CliE2EFactAttribute: skips on non-net8.0 runtimes
- Add CliE2EWithCredentialsAttribute: combines TFM + credential check
- Update all CLI test classes to use new attributes
- Tests now properly skip on net9/net10, run only on net8

Expected CI improvement: ~66% faster CLI E2E tests (1x instead of 3x)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EnvList_WithActiveProfile_ListsEnvironments times out because Global
Discovery Service does not support service principal authentication.
The CLI hangs waiting for a response that will never come.

This is the same issue as EnvList_JsonFormat_ReturnsValidJson which
was already removed. Both tests require interactive auth to work.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, when a service principal profile tried to use Global Discovery
(via `env list` or environment resolution by name), the CLI would hang
indefinitely waiting for device code authentication that would never complete.

Changes:
- GlobalDiscoveryService.FromProfile() now validates auth method upfront
  and throws NotSupportedException with clear guidance for unsupported methods
- CreateTokenProviderFunction() no longer falls back to device code
  automatically - auth method must be explicitly InteractiveBrowser or DeviceCode
- Added SupportsGlobalDiscovery() helper for consistent validation
- EnvironmentResolutionService now uses the centralized validation
- Added comprehensive unit tests for all auth method validation
- Restored EnvList E2E test with proper error expectations

The error message now clearly explains:
- Why Global Discovery requires interactive auth
- Which auth method the profile is using
- What alternatives are available (env select --environment, auth create)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@joshsmithxrm joshsmithxrm merged commit 7ec690f into main Jan 3, 2026
8 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in PPDS Roadmap Jan 3, 2026
@joshsmithxrm joshsmithxrm deleted the feature/testing-phase5-unit-tests branch January 3, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants