Skip to content

Conversation

@kyhau
Copy link
Owner

@kyhau kyhau commented Sep 14, 2025

Added extensive unit tests for aws_login, file_io, saml2aws_helper, and selector modules to improve code coverage and reliability. Tests cover various edge cases, error handling, and expected behaviors for CLI commands, file operations, and helper functions.

Added extensive unit tests for aws_login, file_io, saml2aws_helper, and selector modules to improve code coverage and reliability. Tests cover various edge cases, error handling, and expected behaviors for CLI commands, file operations, and helper functions.
@amazon-q-developer
Copy link
Contributor

Code review in progress. Analyzing for code quality issues and best practices. Detailed findings will be posted upon completion.

Using Amazon Q Developer for GitHub

Amazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation.

Slash Commands

Command Description
/q <message> Chat with the agent to ask questions or request revisions
/q review Requests an Amazon Q powered code review
/q help Displays usage information

Features

Agentic Chat
Enables interactive conversation with Amazon Q to ask questions about the pull request or request specific revisions. Use /q <message> in comment threads or the review body to engage with the agent directly.

Code Review
Analyzes pull requests for code quality, potential issues, and security concerns. Provides feedback and suggested fixes. Automatically triggered on new or reopened PRs (can be disabled for AWS registered installations), or manually with /q review slash command in a comment.

Customization

You can create project-specific rules for Amazon Q Developer to follow:

  1. Create a .amazonq/rules folder in your project root.
  2. Add Markdown files in this folder to define rules (e.g., cdk-rules.md).
  3. Write detailed prompts in these files, such as coding standards or best practices.
  4. Amazon Q Developer will automatically use these rules when generating code or providing assistance.

Example rule:

All Amazon S3 buckets must have encryption enabled, enforce SSL, and block public access.
All Amazon DynamoDB Streams tables must have encryption enabled.
All Amazon SNS topics must have encryption enabled and enforce SSL.
All Amazon SNS queues must enforce SSL.

Feedback

To provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository.

For more detailed information, visit the Amazon Q for GitHub documentation.

Footnotes

  1. Amazon Q Developer uses generative AI. You may need to verify generated code before using it in your environment. See the AWS Responsible AI Policy.

@kyhau
Copy link
Owner Author

kyhau commented Sep 14, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Contributor

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is a well-structured addition of comprehensive unit tests that significantly improves the project's test coverage. The tests are well-organized and cover important functionality including edge cases.

Key observations:

  • Good coverage of core functionality in aws_login, file_io, saml2aws_helper, and selector modules
  • Effective use of mocking for external dependencies
  • Clear test organization using test classes

Suggestions for improvement:

  1. Add tests for invalid input handling and edge cases
  2. Include security-focused test cases for file operations
  3. Consider adding concurrency tests
  4. Add tests for international character support

Please address the inline comments to further strengthen the test suite. The changes look good to merge once the suggested improvements are implemented.

role_arn, account_alias, "RoleName"
)
assert result == "team-subteam-dev"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test cases for invalid role ARN formats to ensure the function handles malformed input gracefully. This would help catch potential issues with unexpected ARN formats.

def test_run_saml2aws_list_roles_parse_error(self, mock_popen, mock_getpass, mock_load_config):
mock_load_config.return_value = {"username": "testuser"}
mock_getpass.return_value = "testpass"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test cases for error handling when subprocess.Popen raises exceptions (e.g., command not found, permission denied). This would improve the robustness of the test suite.

f.write(" line1 \n line2 \n line3 \n")
temp_file = f.name

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: The test file operations should be performed in a secure temporary directory to prevent path traversal vulnerabilities1. Consider using tempfile.mkdtemp() with appropriate permissions.

Footnotes

  1. CWE-22: Path Traversal - https://cwe.mitre.org/data/definitions/22.html



class TestPromptProfileSelection:
@patch('saml2awsmulti.selector.inquirer')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test cases for handling special characters and Unicode in profile/role names. This would ensure the selector works correctly with international characters and special symbols.

assert len(result) == 2

@patch('saml2awsmulti.aws_login.exists')
@patch('saml2awsmulti.aws_login.read_csv')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test cases for concurrent access to the credentials file. This would help ensure thread safety when multiple processes try to access AWS credentials simultaneously.

Refactored test cases in test_aws_login.py to assert log messages using pytest's caplog fixture instead of checking result.output. Also updated a test in test_saml2aws_helper.py to expect KeyError instead of ValueError. Added junit.xml to .gitignore.
Replaces setup.py, requirements files, and tox.ini with pyproject.toml and Makefile for dependency management, testing, and building. Updates GitHub Actions workflow and README to use Makefile targets. This modernizes the project structure and simplifies development and CI processes.
Added explicit Python 3.13 setup to the GitHub Actions workflow and removed Python 3.10 from the test matrix. Updated Makefile to check for 'uv' before running commands and made dependency installation targets depend on 'check-uv'. Added 'coverage.xml' to .gitignore.
Removed the 'run' target from the Makefile as awslogin is an interactive CLI tool. Updated the README to clarify build, install, and run steps, and improved documentation for available Makefile targets and testing commands.
Replaced uv with Poetry for dependency management and updated related documentation, Makefile targets, and CI workflows. Added poetry.lock, removed MANIFEST.in and constraints.txt, and updated .gitignore. Enhanced Dependabot and GitHub Actions to support Poetry. Updated CHANGELOG and README to reflect the new build and install process.
Added yamllint as a development dependency in pyproject.toml and updated the Makefile and GitHub Actions workflow to use Poetry for installing and running yamllint. Also renamed the yamllint config file for consistency and made minor improvements to the linting process.
@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.92%. Comparing base (a074ae6) to head (c28a962).
⚠️ Report is 267 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #169       +/-   ##
===========================================
+ Coverage   33.17%   98.92%   +65.74%     
===========================================
  Files           4        8        +4     
  Lines         205      926      +721     
===========================================
+ Hits           68      916      +848     
+ Misses        137       10      -127     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kyhau kyhau merged commit 014f239 into main Oct 16, 2025
9 checks passed
@kyhau kyhau deleted the addtests branch October 16, 2025 08:15
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.

2 participants