Describe the bug
You aren't handling Unauthorized Token Access properly. Your api raises a TypeError when it should be raising an UnauthorizedTokenException.
To Reproduce
Try to access the api with invalid credentials. A TypeError will occur.
Expected behavior
An UnauthorizedTokenException should be raised.
Screenshots
I am too lazy for screenshots.
Desktop (please complete the following information):
- OS: MacOS
- Browser: Not Browser Related
- Version: Version of what?
Additional context
The bug actually happens here.
|
headers['Authorization'] = 'Bearer ' + self.__token |
core.py
headers['Authorization'] = 'Bearer ' + self.__token
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
because self.__token is defaulted to None here
core.py
self.__token = None
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
This requests.post will respond without raising a 400 because the request processed, it just processed and returned Unauthorized. But you don’t raise an exception.
|
response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify) |
core.py
response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify)
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
And instead just log it
|
py_jama_rest_client_logger.error('Failed to retrieve OAuth Token') |
core.py
py_jama_rest_client_logger.error('Failed to retrieve OAuth Token')
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
resulting in the method completing without updating the token
And allowing for the type error to occur.
Describe the bug
You aren't handling Unauthorized Token Access properly. Your api raises a TypeError when it should be raising an UnauthorizedTokenException.
To Reproduce
Try to access the api with invalid credentials. A TypeError will occur.
Expected behavior
An UnauthorizedTokenException should be raised.
Screenshots
I am too lazy for screenshots.
Desktop (please complete the following information):
Additional context
The bug actually happens here.
py-jama-rest-client/py_jama_rest_client/core.py
Line 149 in d03cb91
core.py
headers['Authorization'] = 'Bearer ' + self.__token
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
because self.__token is defaulted to None here
py-jama-rest-client/py_jama_rest_client/core.py
Line 43 in d03cb91
core.py
self.__token = None
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
This requests.post will respond without raising a 400 because the request processed, it just processed and returned Unauthorized. But you don’t raise an exception.
py-jama-rest-client/py_jama_rest_client/core.py
Line 129 in d03cb91
core.py
response = requests.post(self.__token_host, auth=self.__credentials, data=data, verify=self.__verify)
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
And instead just log it
py-jama-rest-client/py_jama_rest_client/core.py
Line 143 in d03cb91
core.py
py_jama_rest_client_logger.error('Failed to retrieve OAuth Token')
https://github.com/jamasoftware-ps/py-jama-rest-client|jamasoftware-ps/py-jama-rest-clientjamasoftware-ps/py-jama-rest-client | Added by GitHub
resulting in the method completing without updating the token
And allowing for the type error to occur.