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

Fall-back to credentials from DB if settings.EXTERNAL_ISSUE_RPC_CREDE… #3392

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tcms/issuetracker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def rpc_credentials(self):
credentials_function = _function_from_path(
settings.EXTERNAL_ISSUE_RPC_CREDENTIALS
)
return credentials_function(self)
result = credentials_function(self)

# if result is None or not a tuple then fallback
if result and isinstance(result, tuple):
return result

return (self.bug_system.api_username, self.bug_system.api_password)
4 changes: 4 additions & 0 deletions tcms/issuetracker/tests/redmine_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ def change_assignee(rpc, new_issue, execution, user):

def rpc_creds(issue_tracker):
return ("tester", "test-me")


def rpc_no_creds(issue_tracker):
return None
10 changes: 10 additions & 0 deletions tcms/issuetracker/tests/test_redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,13 @@ def test_overriden_credentials_are_returned(self):
# not admin:admin as defined above
self.assertEqual(rpc_username, "tester")
self.assertEqual(rpc_password, "test-me")

@override_settings(
EXTERNAL_ISSUE_RPC_CREDENTIALS="tcms.issuetracker.tests.redmine_post_processing.rpc_no_creds"
)
def test_overriden_credentials_fallback(self):
(rpc_username, rpc_password) = self.integration.rpc_credentials

# admin:admin as defined above b/c rpc_no_creds() returns None
self.assertEqual(rpc_username, "admin")
self.assertEqual(rpc_password, "admin")
Loading