Skip to content

Commit

Permalink
add test for token_auth= updating header (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
adehad authored Sep 4, 2022
1 parent 354bdf7 commit d0e5d4c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import mock

import pytest
import requests.sessions

import jira.client
from jira.exceptions import JIRAError
Expand Down Expand Up @@ -203,6 +204,21 @@ def test_token_auth(cl_admin: jira.client.JIRA):
assert cl_admin.myself() == new_jira_client.myself()


def test_bearer_token_auth():
my_token = "cool-token"
token_auth_jira = jira.client.JIRA(
server="https://what.ever",
token_auth=my_token,
get_server_info=False,
validate=False,
)
method_send = token_auth_jira._session.send
with mock.patch.object(token_auth_jira._session, method_send.__name__) as mock_send:
token_auth_jira._session.get(token_auth_jira.server_url)
prepared_req: requests.sessions.PreparedRequest = mock_send.call_args[0][0]
assert prepared_req.headers["Authorization"] == f"Bearer {my_token}"


def test_cookie_auth(test_manager: JiraTestManager):
"""Test Cookie based authentication works.
Expand Down

0 comments on commit d0e5d4c

Please sign in to comment.