feat(jira): add cloud Jira authentication support#272
Conversation
Add --cloud flag and --user option to support cloud Jira instances using basic_auth (email + API token) alongside existing server token_auth. - Add --cloud CLI flag (tri-state: None/True/False) with config fallback - Add --user CLI option with JIRA_USER env var and config fallback - Branch JIRA connection: basic_auth for cloud, token_auth for server - Validate user is required when cloud mode is enabled - Add comprehensive tests covering all cloud scenarios
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
WalkthroughExtended Jira integration to support cloud authentication by adding user and cloud parameters throughout configuration pipeline, CLI options, and client initialization, with corresponding test coverage and example configuration updates. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use your project's `pylint` configuration to improve the quality of Python code reviews.Add a pylint configuration file to your project to customize how CodeRabbit runs |
|
/verified |
|
/lgtm |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/jira_utils/test_jira_utils.py (1)
82-262: Add one assertion around client construction.These cases stop at
apps.jira_utils.jira_information.process_jira_command_line_config_file, so a regression inapps/jira_utils/jira_information.pyLines 276-285 could still swap the auth kwargs and the cloud suite would stay green. Thejira.JIRAconstructor exposes distinctbasic_authandtoken_authpaths, and the Cloud docs call forbasic_auth=(email, api_token), so this feature is worth covering at the actual construction site with a mock. A smallmocker.patch("apps.jira_utils.jira_information.JIRA")assertion in cloud and server mode would lock that down. (jira.readthedocs.io)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/jira_utils/test_jira_utils.py` around lines 82 - 262, Patch and assert the actual JIRA client construction to lock down auth kwargs: in the cloud test (e.g., test_process_jira_command_line_config_file_cloud_valid) mock "apps.jira_utils.jira_information.JIRA" and assert it was called with basic_auth=(user, token) (or equivalent positional auth tuple) when cloud=True; likewise in the server-mode test (e.g., test_process_server_mode_default) mock the same JIRA symbol and assert it was invoked with the server/token auth form your code uses (token_auth or other server-specific param) to ensure the auth kwargs aren't accidentally swapped — add the mocker.patch for JIRA and a simple assert_called_with/assert_any_call against the expected auth kwarg in each relevant test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/jira_utils/jira_information.py`:
- Around line 238-243: Replace the single is_flag option for "cloud" with paired
boolean flags so the CLI can produce True, False, or None; specifically change
the click.option(...) that currently uses "--cloud" and is_flag=True to use the
paired flag syntax (e.g. "--cloud/--no-cloud") with default=None and an
appropriate help string so tests that pass cloud=False (server mode) can be
reached; update the option declaration where the current click.option for
"cloud" is defined (the decorator creating the --cloud flag).
---
Nitpick comments:
In `@tests/jira_utils/test_jira_utils.py`:
- Around line 82-262: Patch and assert the actual JIRA client construction to
lock down auth kwargs: in the cloud test (e.g.,
test_process_jira_command_line_config_file_cloud_valid) mock
"apps.jira_utils.jira_information.JIRA" and assert it was called with
basic_auth=(user, token) (or equivalent positional auth tuple) when cloud=True;
likewise in the server-mode test (e.g., test_process_server_mode_default) mock
the same JIRA symbol and assert it was invoked with the server/token auth form
your code uses (token_auth or other server-specific param) to ensure the auth
kwargs aren't accidentally swapped — add the mocker.patch for JIRA and a simple
assert_called_with/assert_any_call against the expected auth kwarg in each
relevant test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7b1c5215-7c56-40d5-a756-1ef7e1d55571
📒 Files selected for processing (4)
apps/jira_utils/jira_information.pyconfig.example.yamltests/jira_utils/test_jira_cfg_file.yamltests/jira_utils/test_jira_utils.py
Summary
Add support for cloud Jira authentication alongside existing server (on-premise) token auth.
Changes
--cloudCLI flag (tri-state:None/True/False) with config file fallback--userCLI option withJIRA_USERenv var and config file fallbackbasic_auth(user, token)for cloud,token_authfor server--useris required when cloud mode is enabledAuth Matrix
url,tokenJIRA(token_auth=token, options={"server": url})--cloud)url,user,tokenJIRA(server=url, basic_auth=(user, token))Cloud flag resolution order
--cloudpassed →TruecloudkeyFalse(server mode)Tests
Added 8 cloud-specific test cases covering:
Falsewhen not in configcloud=Falseoverrides configcloud: trueSummary by CodeRabbit
Release Notes