Skip to content

Add more tests for initial/migration/auto-adoption wizards#2340

Merged
t-aleksander merged 4 commits into
devfrom
add-wizard-tests
Mar 13, 2026
Merged

Add more tests for initial/migration/auto-adoption wizards#2340
t-aleksander merged 4 commits into
devfrom
add-wizard-tests

Conversation

@t-aleksander
Copy link
Copy Markdown
Contributor

No description provided.

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 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);
Comment thread crates/defguard_setup/Cargo.toml Outdated
tonic.workspace = true

[dev-dependencies]
ipnetwork = { workspace = true }

assert_auto_adoption_step(&pool, AutoAdoptionWizardStep::VpnSettings).await;

let settings = Settings::get_current_settings();
@t-aleksander t-aleksander merged commit 443d643 into dev Mar 13, 2026
3 checks passed
@t-aleksander t-aleksander deleted the add-wizard-tests branch March 13, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants