Skip to content

Commit d0e5d4c

Browse files
authored
add test for token_auth= updating header (#1476)
1 parent 354bdf7 commit d0e5d4c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest import mock
33

44
import pytest
5+
import requests.sessions
56

67
import jira.client
78
from jira.exceptions import JIRAError
@@ -203,6 +204,21 @@ def test_token_auth(cl_admin: jira.client.JIRA):
203204
assert cl_admin.myself() == new_jira_client.myself()
204205

205206

207+
def test_bearer_token_auth():
208+
my_token = "cool-token"
209+
token_auth_jira = jira.client.JIRA(
210+
server="https://what.ever",
211+
token_auth=my_token,
212+
get_server_info=False,
213+
validate=False,
214+
)
215+
method_send = token_auth_jira._session.send
216+
with mock.patch.object(token_auth_jira._session, method_send.__name__) as mock_send:
217+
token_auth_jira._session.get(token_auth_jira.server_url)
218+
prepared_req: requests.sessions.PreparedRequest = mock_send.call_args[0][0]
219+
assert prepared_req.headers["Authorization"] == f"Bearer {my_token}"
220+
221+
206222
def test_cookie_auth(test_manager: JiraTestManager):
207223
"""Test Cookie based authentication works.
208224

0 commit comments

Comments
 (0)