Skip to content

Fix critical credential file extension bug affecting beta customers#5

Open
james-s-anderson wants to merge 2 commits intomainfrom
fix/credential-file-extension-bug
Open

Fix critical credential file extension bug affecting beta customers#5
james-s-anderson wants to merge 2 commits intomainfrom
fix/credential-file-extension-bug

Conversation

@james-s-anderson
Copy link
Collaborator

Summary

Fixes a critical bug where persisted credentials are never discovered, breaking the core credential persistence feature for beta customers.

Problem

The credential persistence system has a file extension mismatch:

  • New-NctApiCredential -persist saves credentials as username.dat
  • Test-NctSession searches for *.txt files
  • Result: Saved credentials are never found

Impact on Beta Customers

  • ❌ Users who persist credentials must re-enter passwords every session
  • ❌ The advertised feature "removal of the need to store passwords in scripts" appears broken
  • ❌ Creates user confusion - credential files exist but aren't detected
  • ❌ Affects 100% of users who use persisted credentials

Changes Made

1. Added Comprehensive Tests (20 new tests)

  • CredentialPersistence.Tests.ps1: Unit tests for credential file persistence, encryption, and .dat file validation
  • SessionCredentialDiscovery.Tests.ps1: Integration tests for credential discovery logic with bug regression tests
  • Tests/README.md: Updated documentation

These tests demonstrate the bug and validate the fix works correctly.

2. Fixed File Extension Bug

File: Functions/Test-NctSession.ps1:47

- $files = Get-ChildItem -Path "$env:USERPROFILE\.nct client library" -Filter "*.txt"
+ $files = Get-ChildItem -Path "$env:USERPROFILE\.nct client library" -Filter "*.dat"

Testing

✅ All 19 credential discovery tests pass
✅ Validates .dat files are now found correctly
✅ Confirms .txt files are properly ignored

Priority

🔴 CRITICAL - Highest priority fix for beta customers as it restores core functionality

Remaining Issues

This PR addresses the most critical bug. Additional non-critical issues identified during code review:

  • Property typo in Get-NctDevices.ps1 (IsProxiedl)
  • Unreachable code cleanup
  • HttpClient disposal improvements

These can be addressed in follow-up PRs if needed.

🤖 Generated with Claude Code

james-s-anderson and others added 2 commits February 13, 2026 17:29
This commit adds two new test files to validate credential persistence
functionality and expose a critical bug affecting beta customers.

New test files:
- CredentialPersistence.Tests.ps1: Unit tests for credential file
  persistence, encryption/decryption, and .dat file extension validation
- SessionCredentialDiscovery.Tests.ps1: Integration tests for credential
  file discovery logic in Test-NctSession, including regression tests
  for the file extension mismatch bug

Key tests added:
- Validates credentials are saved with .dat extension
- Confirms .dat files are discoverable with correct filter
- Demonstrates bug: .txt filter fails to find .dat files
- Tests username extraction from filenames
- Validates DPAPI encryption security
- Tests edge cases and multi-user scenarios

These tests expose a critical bug where Test-NctSession searches for
*.txt files but New-NctApiCredential saves *.dat files, causing
persisted credentials to never be discovered.

Total: 20 new tests (19 passing, demonstrating bug exists)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes the file extension mismatch where credentials are saved as .dat
files but the discovery logic searched for .txt files, causing persisted
credentials to never be found.

Issue:
- New-NctApiCredential saves credentials as: username.dat
- Test-NctSession searched for: *.txt files
- Result: Persisted credentials were never discovered

Impact on beta customers:
- Users who persisted credentials had to re-enter passwords every session
- The main feature (removing need to store passwords in scripts) appeared broken
- Created confusion as credential files existed but weren't detected

Fix:
- Changed filter in Test-NctSession.ps1 line 47 from "*.txt" to "*.dat"
- Updated comment to say "credential files" instead of "text files"

Testing:
- All 11 credential discovery tests pass
- Validates .dat files are now found correctly
- Confirms .txt files are properly ignored

This is the highest priority fix for beta customers as it restores core
functionality for credential persistence.

Fixes: Test-NctSession.ps1:47

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

1 participant