File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 2
2
from unittest import mock
3
3
4
4
import pytest
5
+ import requests .sessions
5
6
6
7
import jira .client
7
8
from jira .exceptions import JIRAError
@@ -203,6 +204,21 @@ def test_token_auth(cl_admin: jira.client.JIRA):
203
204
assert cl_admin .myself () == new_jira_client .myself ()
204
205
205
206
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
+
206
222
def test_cookie_auth (test_manager : JiraTestManager ):
207
223
"""Test Cookie based authentication works.
208
224
You can’t perform that action at this time.
0 commit comments