Add more tests for initial/migration/auto-adoption wizards#2340
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands integration test coverage around Defguard’s setup wizards (initial setup, migration, and auto-adoption) and adjusts wizard-state behavior to better match what the UI/tests expect.
Changes:
- Add new test suites covering wizard initialization, wizard state endpoints, session-info behavior, migration wizard flow/auth, and auto-adoption flow/auth.
- Introduce shared test utilities (
tests/common) to standardize spinning up setup/migration webapps in tests. - Update wizard-state API and wizard initialization to (a) only return step-state for the currently active wizard and (b) seed the auto-adoption wizard state when that wizard is started.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/defguard_setup/tests/wizard_state.rs | New tests asserting /api/v1/wizard state for initial vs auto-adoption flows. |
| crates/defguard_setup/tests/wizard_init.rs | New tests for Wizard::init selection/idempotency and requires_auth behavior. |
| crates/defguard_setup/tests/session_info.rs | New tests validating /api/v1/session-info across setup/auto-adoption/migration servers. |
| crates/defguard_setup/tests/migration_wizard.rs | New end-to-end migration wizard flow tests + auth enforcement checks. |
| crates/defguard_setup/tests/auto_adoption_wizard.rs | New end-to-end auto-adoption tests including auth enforcement and missing-network handling. |
| crates/defguard_setup/tests/initial_setup.rs | Refactor to reuse common test client helper rather than inline client boilerplate. |
| crates/defguard_setup/tests/common/mod.rs | New shared test helpers for setup/migration webapp clients and seeding. |
| crates/defguard_setup/src/handlers/initial_wizard.rs | Change /api/v1/wizard response to only include the active wizard’s step state. |
| crates/defguard_setup/Cargo.toml | Add ipnetwork to dev-dependencies (but it’s already a normal dependency). |
| crates/defguard_common/src/db/models/wizard.rs | Seed AutoAdoptionWizardState::default() when starting AutoAdoption wizard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+143
to
+146
| let mut config = DefGuardConfig::new_test_config(); | ||
| config.cookie_insecure = true; | ||
| config.initialize_post_settings(); | ||
| let _ = SERVER_CONFIG.set(config); |
| tonic.workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| ipnetwork = { workspace = true } |
|
|
||
| assert_auto_adoption_step(&pool, AutoAdoptionWizardStep::VpnSettings).await; | ||
|
|
||
| let settings = Settings::get_current_settings(); |
jakub-tldr
approved these changes
Mar 13, 2026
filipslezaklab
approved these changes
Mar 13, 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.
No description provided.