Skip to content

Replace hardcoded password strings with secrets.token_hex in tests#188

Draft
Copilot wants to merge 10 commits intomainfrom
copilot/sub-pr-185
Draft

Replace hardcoded password strings with secrets.token_hex in tests#188
Copilot wants to merge 10 commits intomainfrom
copilot/sub-pr-185

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Applicable spec: N/A

Overview

Replace all hardcoded password strings in test files with dynamically generated tokens using secrets.token_hex(16).

Rationale

Addresses review feedback from #185. Hardcoded test passwords ("HELLO", "WORLD", "test_value", etc.) flagged by Bandit are replaced with cryptographically secure random tokens, improving test security posture without changing functionality.

Juju Events Changes

None

Module Changes

None - test-only changes

Library Changes

None

Implementation

Updated test files and factories:

  • Unit tests: Direct replacement of string literals with secrets.token_hex(16) calls
  • Factories: Use factory.LazyFunction(lambda: secrets.token_hex(16)) to generate unique tokens per instance
  • Integration tests: Same approach as unit tests

Example change:

# Before
script_secrets={"TEST_SECRET_ONE": "HELLO"}  # nosec: hardcoded_password_string

# After  
script_secrets={"TEST_SECRET_ONE": secrets.token_hex(16)}

Checklist

Documentation, changelog, and version updates not applicable - test-only changes with no user-facing impact.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 21, 2026 04:13
Co-authored-by: yanksyoon <37652070+yanksyoon@users.noreply.github.com>
Co-authored-by: yanksyoon <37652070+yanksyoon@users.noreply.github.com>
Copilot AI changed the title [WIP] Update hardcoded password strings to use secrets.token_hex Replace hardcoded password strings with secrets.token_hex in tests Jan 21, 2026
Copilot AI requested a review from yanksyoon January 21, 2026 04:17
Base automatically changed from ISD-3652-aproxy2 to main February 17, 2026 10:00
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.

3 participants