Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test to cover JIRA token and password authentication. #424

Merged
merged 5 commits into from
Apr 25, 2022

Conversation

mpryc
Copy link
Collaborator

@mpryc mpryc commented Apr 19, 2022

Added test which checks for the deprecated password authentication.

JIRA uses same method to authenticate in the cloud jira instance for both deprecated password authentication and token based auth.

This may lead to the situation where wrong API key is actually considered password and then failure exporter is presenting deprecation error.

This change also moves connection func to separate private one for easy testing and readibility + may in the future include more sophisticated auth methods.

Added proper headers to the files which were modified.

resolves #423

@redhat-cop/mdt

@mpryc
Copy link
Collaborator Author

mpryc commented Apr 19, 2022

@KevinMGranger I was wondering if we should actually catch the JIRAError and then tell that this may be as well wrong api key instead of just passing original JIRAError with:

JIRAError('Basic authentication with passwords is deprecated.  For more information, see: https://developer.atlassian.com/cloud/confluence/deprecation-notice-basic-auth/

Note that I have created test pelorus atlassian.net that is used in the connection tests, they require valid token (even if it's not active) to create api key to communicate with JIRA instance and I am using it in test.

@mpryc mpryc marked this pull request as draft April 19, 2022 14:29
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 19, 2022
@mpryc mpryc force-pushed the issue_423 branch 2 times, most recently from 78668be to f8d2fdf Compare April 19, 2022 16:02
Added test which checks for the deprecated password authentication.

JIRA uses same method to authenticate in the cloud jira instance
for both deprecated password authentication and token based auth.

This may lead to the situation where wrong API key is actually
considered password and then failure exporter is presenting
deprecation error.

This change also moves connection func to separate private
one for easy testing and readibility + may in the future
include more sophisticated auth methods.

Added proper headers to the files which were modified.
@mpryc mpryc marked this pull request as ready for review April 20, 2022 11:54
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 20, 2022
@openshift-ci openshift-ci bot requested a review from etsauer April 20, 2022 11:54
Copy link
Collaborator

@KevinMGranger KevinMGranger left a comment

Choose a reason for hiding this comment

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

I've got some small notes, which I've modified locally and can push if you wish.

Overall:

  • What does each test do? Can we document them?
  • JIRA failure exporter should not use basic auth with username/password #423 says the deprecation should be documented. So we either need documentation in this PR or to not mark it as resolved with this PR.
  • I'm confused by a deprecation raising an exception -- shouldn't it let you keep going but warn you?
  • If we're switching to insisting on an email address, should we change the envionment variable as well?

exporters/failure/collector_jira.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
def mock_search_issues(self):
return []

monkeypatch = MonkeyPatch()
Copy link
Collaborator

Choose a reason for hiding this comment

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

The preferred way to use monkeypatch is as a fixture-- we can just make a parameter named monkeypatch and it will work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I had troubles with fixture here, but will play with it.

#

import pytest
from _pytest.monkeypatch import MonkeyPatch
Copy link
Collaborator

Choose a reason for hiding this comment

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

MonkeyPatch is exposed within pytest, no need to look for it in a private module.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@KevinMGranger normally yes by fixture, but for some reason pytest was failing that the module was not found.

@KevinMGranger
Copy link
Collaborator

The small changes I made are here: https://github.com/kevinmgranger/pelorus/tree/issue_423

@KevinMGranger KevinMGranger merged commit b4f875c into dora-metrics:master Apr 25, 2022
@mpryc mpryc deleted the issue_423 branch April 26, 2022 08:01
@mpryc mpryc added the compatibility A compatibility issue (versioning, exporter backends, etc.) label Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility A compatibility issue (versioning, exporter backends, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIRA failure exporter should not use basic auth with username/password
2 participants