---
phase: 26-add-oauth-support-to-load-testing
plan: 04
type: execute
wave: 3
depends_on: ["26-02", "26-03"]
files_modified:
  - cargo-pmcp/src/commands/loadtest/run.rs
autonomous: true
requirements:
  - OAUTH-06

must_haves:
  truths:
    - "cargo fmt across all modified crates passes --check"
    - "cargo clippy across all modified crates passes with -D warnings"
    - "cargo build for pmcp (with oauth), mcp-tester, and cargo-pmcp all succeed"
    - "All tests pass across pmcp, mcp-tester, and cargo-pmcp"
    - "Existing unauthenticated loadtest path works (no regression)"
    - "Auth type (OAuth/API-key/none) is shown in the loadtest output"
  artifacts:
    - path: "cargo-pmcp/src/commands/loadtest/run.rs"
      provides: "Auth type display in loadtest preamble, any clippy/fmt fixes"
      contains: "Authentication"
  key_links:
    - from: "cargo-pmcp/src/commands/loadtest/run.rs"
      to: "terminal output"
      via: "eprintln showing auth type before engine.run()"
      pattern: "Authentication"
---

<objective>
Quality gates and final polish for the OAuth loadtest integration across all three modified crates (pmcp, mcp-tester, cargo-pmcp). Verify full build, clippy, fmt, tests pass. Confirm the unauthenticated loadtest path still works (no regression).

Purpose: Ensure code from plans 01-03 meets project quality standards (zero clippy warnings, formatted, all tests pass) and does not regress existing unauthenticated loadtest behavior.

Output: Clean, production-ready OAuth integration that passes all quality gates across the entire workspace.
</objective>

<execution_context>
@./.claude/get-shit-done/workflows/execute-plan.md
@./.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/26-add-oauth-support-to-load-testing/26-CONTEXT.md
@.planning/phases/26-add-oauth-support-to-load-testing/26-01-SUMMARY.md
@.planning/phases/26-add-oauth-support-to-load-testing/26-02-SUMMARY.md
@.planning/phases/26-add-oauth-support-to-load-testing/26-03-SUMMARY.md
</context>

<tasks>

<task type="auto">
  <name>Task 1: Run quality gates across all three crates and fix any issues</name>
  <files>cargo-pmcp/src/commands/loadtest/run.rs</files>
  <action>
**Quality gates (fix any issues from plans 01-03):**

1. Run `cargo fmt` across all modified crates and fix any formatting issues:
   ```bash
   cargo fmt -p pmcp
   cargo fmt -p mcp-tester
   cargo fmt -p cargo-pmcp
   ```

2. Run `cargo clippy` across all modified crates and fix any warnings:
   ```bash
   cargo clippy -p pmcp --features oauth -- -D warnings
   cargo clippy -p mcp-tester -- -D warnings
   cargo clippy -p cargo-pmcp -- -D warnings
   ```
   Common issues to watch for: unused imports, unnecessary clones, missing docs on public items, `clippy::too_many_arguments` (add `#[allow]` where needed).

3. Run all tests:
   ```bash
   cargo test -p pmcp --features oauth -- --test-threads=1
   cargo test -p mcp-tester -- --test-threads=1
   cargo test -p cargo-pmcp -- --test-threads=1
   ```

4. Verify default build (no oauth feature) still works:
   ```bash
   cargo build -p pmcp
   ```

**Regression check (unauthenticated path):**
Verify that `test_engine_run_with_no_color_does_not_panic` engine test still passes -- this exercises the full engine flow with no auth (middleware_chain=None), confirming VUs still work without authentication.

**Auth type display verification:**
Confirm the auth type display added in plan 03 is present and correct in `execute_run` in run.rs. The display should appear after middleware resolution and before `engine.run()`:

```rust
match &http_middleware_chain {
    Some(_) if is_oauth => eprintln!("Authentication: OAuth 2.0 (token acquired)"),
    Some(_) => eprintln!("Authentication: API key"),
    None => eprintln!("Authentication: none"),
}
```

If it was not added in plan 03, add it here. Ensure `is_oauth` is captured before `oauth_client_id` is moved.

**Final full-workspace verification:**
```bash
cargo fmt --all -- --check
cargo clippy --workspace -- -D warnings
cargo test --workspace -- --test-threads=1
```

Note: The full workspace build may surface unrelated warnings in other crates. Focus on the three crates modified in this phase: pmcp, mcp-tester, cargo-pmcp. If other crates have pre-existing warnings, document but do not fix (out of scope).
  </action>
  <verify>
    <automated>cd /Users/guy/Development/mcp/sdk/rust-mcp-sdk && cargo fmt -p pmcp -- --check && cargo fmt -p mcp-tester -- --check && cargo fmt -p cargo-pmcp -- --check && cargo clippy -p pmcp --features oauth -- -D warnings && cargo clippy -p mcp-tester -- -D warnings && cargo clippy -p cargo-pmcp -- -D warnings && cargo test -p pmcp --features oauth -- --test-threads=1 2>&1 | tail -3 && cargo test -p mcp-tester -- --test-threads=1 2>&1 | tail -3 && cargo test -p cargo-pmcp -- --test-threads=1 2>&1 | tail -3</automated>
  </verify>
  <done>All quality gates pass: fmt check clean across pmcp/mcp-tester/cargo-pmcp, clippy zero warnings across all three, all tests pass. Unauthenticated loadtest path confirmed working (no regression). Auth type displayed before engine starts.</done>
</task>

</tasks>

<verification>
```bash
cd /Users/guy/Development/mcp/sdk/rust-mcp-sdk

# Format check
cargo fmt -p pmcp -- --check
cargo fmt -p mcp-tester -- --check
cargo fmt -p cargo-pmcp -- --check

# Clippy
cargo clippy -p pmcp --features oauth -- -D warnings
cargo clippy -p mcp-tester -- -D warnings
cargo clippy -p cargo-pmcp -- -D warnings

# All tests
cargo test -p pmcp --features oauth -- --test-threads=1
cargo test -p mcp-tester -- --test-threads=1
cargo test -p cargo-pmcp -- --test-threads=1

# Verify CLI help shows auth flags
cargo run -p cargo-pmcp -- pmcp loadtest run --help 2>&1 | grep -cE "oauth|api-key"
# Expected: 6 (one per flag)

# Verify unauthenticated path (engine test with no middleware)
cargo test -p cargo-pmcp --lib loadtest::engine::tests::test_engine_run_with_no_color_does_not_panic -- --test-threads=1

# Default build without oauth feature
cargo build -p pmcp
```
</verification>

<success_criteria>
1. `cargo fmt -p {pmcp,mcp-tester,cargo-pmcp} -- --check` all exit 0
2. `cargo clippy -p {pmcp,mcp-tester,cargo-pmcp} -- -D warnings` all exit 0
3. `cargo test -p {pmcp,mcp-tester,cargo-pmcp} -- --test-threads=1` all pass
4. `cargo build -p pmcp` (without oauth) still succeeds
5. Existing unauthenticated loadtest path works (test_engine_run passes)
6. Auth type feedback message is printed during loadtest run
</success_criteria>

<output>
After completion, create `.planning/phases/26-add-oauth-support-to-load-testing/26-04-SUMMARY.md`
</output>
