Skip to content

Add failing tests for #449: auth logout misleading message#461

Merged
gltanaka merged 4 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-449
Feb 6, 2026
Merged

Add failing tests for #449: auth logout misleading message#461
gltanaka merged 4 commits intopromptdriven:mainfrom
Serhan-Asad:fix/issue-449

Conversation

@Serhan-Asad
Copy link
Contributor

@Serhan-Asad Serhan-Asad commented Feb 4, 2026

Summary

Fixes the bug reported in #449 where pdd auth logout displays a misleading success message when the user is not authenticated.

Changes

  • Fixed: pdd/commands/auth.py - Added authentication check before logout
  • Added: pdd/prompts/commands/auth_python.prompt - Prompt specification for auth module
  • Added: Comprehensive test suite (4 unit + 5 E2E tests)

Test Files

  • Unit tests: tests/test_commands_auth.py (TestLogoutCommand class)
  • E2E tests: tests/test_e2e_issue_449_auth_logout_message.py

The Fix

Added authentication status check at the start of logout_cmd():

# Check if user is actually logged in first
auth_status = get_auth_status()

if not auth_status.get("authenticated"):
    console.print("[yellow]Not authenticated.[/yellow]")
    return

Test Results ✅

All tests now pass:

Unit Tests (tests/test_commands_auth.py)

  • test_logout_when_not_authenticated_should_display_appropriate_message - PASSES (bug fixed)
  • test_logout_when_authenticated_with_valid_jwt_succeeds - PASSES (regression test)
  • test_logout_when_authenticated_with_refresh_token_only_succeeds - PASSES (regression test)
  • test_logout_handles_service_errors_gracefully - PASSES (regression test)

E2E Tests (tests/test_e2e_issue_449_auth_logout_message.py)

  • test_logout_when_not_authenticated_should_display_appropriate_message - PASSES (bug fixed)
  • test_logout_and_clear_cache_consistency - PASSES (consistency verified)
  • test_clear_cache_when_no_cache_shows_appropriate_message - PASSES (documents correct behavior)
  • test_logout_with_authentication_shows_success_message - PASSES (regression test)
  • test_status_when_not_authenticated_shows_not_authenticated - PASSES (documents status command)

Root Cause (Fixed)

The bug occurred because logout_cmd() unconditionally displayed "Logged out of PDD Cloud." without checking authentication status first. The fix adds a check using get_auth_status() to display "Not authenticated." when the user is not logged in, making the behavior consistent with the clear-cache command.

Fixes #449


Generated by PDD agentic bug workflow + PDD agentic fix

…message

Add unit and E2E tests that detect the bug where `pdd auth logout`
displays "Logged out of PDD Cloud." even when not authenticated.

Unit test (tests/test_commands_auth.py):
- TestLogoutCommand class with 4 tests
- Primary bug test: test_logout_when_not_authenticated_should_display_appropriate_message
- 3 regression tests to ensure fix doesn't break existing functionality

E2E test (tests/test_e2e_issue_449_auth_logout_message.py):
- Subprocess-based tests exercising full CLI path
- Verifies inconsistency between logout and clear-cache commands
- 5 tests total: 2 failing (detecting bug), 3 passing (regression)

Tests verified to:
- FAIL on current buggy code (as expected)
- Will PASS once fix is applied

Related to promptdriven#449
@Serhan-Asad Serhan-Asad marked this pull request as ready for review February 4, 2026 15:39
@gltanaka gltanaka requested a review from Copilot February 5, 2026 02:12
Copy link
Contributor

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 fixes issue #449 where pdd auth logout displays a misleading success message when the user is not authenticated, making it inconsistent with the pdd auth clear-cache command's behavior.

Changes:

  • Added authentication check in logout_cmd() to display "Not authenticated." when user is not logged in
  • Added comprehensive test suite with 4 unit tests and 5 E2E tests to verify the fix and prevent regressions
  • Tests verify both the bug fix and ensure normal logout functionality remains intact

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
pdd/commands/auth.py Added authentication status check before logout to prevent misleading success message
tests/test_commands_auth.py Added 4 unit tests for logout command behavior with mocked dependencies
tests/test_e2e_issue_449_auth_logout_message.py Added 5 E2E subprocess-based tests verifying the fix in real CLI scenarios

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

- Fix capitalization: "Subprocess-based" → "subprocess-based" for consistency
- Extract duplicated `_run_pdd_command` to module-level function (DRY)
- Shorten test method names for better readability:
  - test_logout_when_not_authenticated_should_display_appropriate_message → test_logout_not_authenticated_displays_message
  - test_logout_when_authenticated_with_valid_jwt_succeeds → test_logout_with_valid_jwt_succeeds
  - test_logout_when_authenticated_with_refresh_token_only_succeeds → test_logout_with_refresh_token_succeeds

All tests pass after refactoring.
@Serhan-Asad
Copy link
Contributor Author

Serhan-Asad commented Feb 5, 2026

Addressed copilot comments

@gltanaka gltanaka merged commit 64df84a into promptdriven:main Feb 6, 2026
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.

Auth logout shows success message when not authenticated (inconsistent with clear-cache)

2 participants