Skip to content

feat(jira): add cloud Jira authentication support#272

Merged
rnetser merged 1 commit intomainfrom
feat/cloud-jira-support
Mar 16, 2026
Merged

feat(jira): add cloud Jira authentication support#272
rnetser merged 1 commit intomainfrom
feat/cloud-jira-support

Conversation

@rnetser
Copy link
Copy Markdown
Collaborator

@rnetser rnetser commented Mar 16, 2026

Summary

Add support for cloud Jira authentication alongside existing server (on-premise) token auth.

Changes

  • Add --cloud CLI flag (tri-state: None/True/False) with config file fallback
  • Add --user CLI option with JIRA_USER env var and config file fallback
  • Branch JIRA connection: basic_auth(user, token) for cloud, token_auth for server
  • Validate that --user is required when cloud mode is enabled

Auth Matrix

Mode Required params JIRA constructor
Server (default) url, token JIRA(token_auth=token, options={"server": url})
Cloud (--cloud) url, user, token JIRA(server=url, basic_auth=(user, token))

Cloud flag resolution order

  1. CLI --cloud passed → True
  2. CLI not passed → check config file cloud key
  3. Config also missing → False (server mode)

Tests

Added 8 cloud-specific test cases covering:

  • Cloud with valid user (CLI explicit)
  • Cloud with missing user (exits)
  • Cloud from config when CLI not passed
  • Cloud defaults to False when not in config
  • Cloud from config but missing user (exits)
  • User fallback from config
  • Explicit cloud=False overrides config cloud: true
  • Server mode default behavior

Summary by CodeRabbit

Release Notes

  • New Features
    • Added Jira cloud authentication support
    • New configuration parameters for cloud mode and user credentials
    • User and cloud settings available via configuration files and CLI options with environment variable support

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
@redhat-qe-bot1
Copy link
Copy Markdown
Collaborator

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest python-module-install - Test Python package installation
  • /retest all - Run all available tests

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. Status Checks: All required status checks must pass
  3. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  4. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • dbasunag
  • myakove
  • rnetser

Reviewers:

  • dbasunag
  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 16, 2026

Walkthrough

Extended 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

Cohort / File(s) Summary
Jira Cloud Authentication Implementation
apps/jira_utils/jira_information.py
Added user (str) and cloud (bool | None) parameters to process_jira_command_line_config_file and get_jira_mismatch. Implemented cloud mode validation requiring user presence, plumbed parameters through config loading and CLI options, and updated JIRA client initialization with conditional basic_auth for cloud mode vs. token_auth for server mode. Public method signatures updated.
Configuration Schema
config.example.yaml, tests/jira_utils/test_jira_cfg_file.yaml
Added user and cloud configuration keys to Jira config schema in example and test configuration files, extending supported configuration keys without modifying existing entries.
Cloud Authentication Test Coverage
tests/jira_utils/test_jira_utils.py
Added comprehensive test cases validating cloud mode with explicit user and cloud flag, error handling when user missing in cloud mode, config/CLI value resolution logic, and default cloud value behavior. Tests cover fallback to config-provided user and config ignored when cloud is false.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat(jira): add cloud Jira authentication support' accurately and concisely summarizes the main change: adding cloud authentication support to the Jira utilities. The title is clear, specific, and reflects the primary objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cloud-jira-support
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 pylint.

@rnetser
Copy link
Copy Markdown
Collaborator Author

rnetser commented Mar 16, 2026

/verified

@myakove
Copy link
Copy Markdown
Collaborator

myakove commented Mar 16, 2026

/lgtm
/approve

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 in apps/jira_utils/jira_information.py Lines 276-285 could still swap the auth kwargs and the cloud suite would stay green. The jira.JIRA constructor exposes distinct basic_auth and token_auth paths, and the Cloud docs call for basic_auth=(email, api_token), so this feature is worth covering at the actual construction site with a mock. A small mocker.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

📥 Commits

Reviewing files that changed from the base of the PR and between 692865b and cbbf1be.

📒 Files selected for processing (4)
  • apps/jira_utils/jira_information.py
  • config.example.yaml
  • tests/jira_utils/test_jira_cfg_file.yaml
  • tests/jira_utils/test_jira_utils.py

Comment thread apps/jira_utils/jira_information.py
@rnetser rnetser merged commit dbb7226 into main Mar 16, 2026
6 checks passed
@rnetser rnetser deleted the feat/cloud-jira-support branch March 16, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants