Closed balloob closed 6 years ago
@bjinwright anything I can do to help this PR get merged?
Can you add tests?
I get two failing tests.
======================================================================
ERROR: test_admin_get_user (warrant.tests.tests.CognitoAuthTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/brian/workspace/warrant/warrant/tests/tests.py", line 119, in test_admin_get_user
u = self.user.admin_get_user()
File "/home/brian/workspace/warrant/warrant/__init__.py", line 492, in admin_get_user
Username=self.username)
File "/home/brian/.virtualenvs/warrant/local/lib/python2.7/site-packages/botocore/client.py", line 251, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/brian/.virtualenvs/warrant/local/lib/python2.7/site-packages/botocore/client.py", line 537, in _make_api_call
raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (MissingAuthenticationTokenException) when calling the AdminGetUser operation: Missing Authentication Token
and
======================================================================
ERROR: test_admin_authenticate (warrant.tests.tests.CognitoAuthTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/brian/workspace/warrant/warrant/tests/tests.py", line 167, in test_admin_authenticate
self.user.admin_authenticate(self.password)
File "/home/brian/workspace/warrant/warrant/__init__.py", line 370, in admin_authenticate
AuthParameters=auth_params,
File "/home/brian/.virtualenvs/warrant/local/lib/python2.7/site-packages/botocore/client.py", line 251, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/brian/.virtualenvs/warrant/local/lib/python2.7/site-packages/botocore/client.py", line 537, in _make_api_call
raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (MissingAuthenticationTokenException) when calling the AdminInitiateAuth operation: Missing Authentication Token
Please create another PR with the tests fixed.
I think that the way those 2 tests worked before is that they rely on the credentials in ~/.aws
of the user running the tests because I did not change the if-statement that is responsible for adding the keys.
Not all requests to Cognito require requests to be signed in. Examples of these are register, authenticate, forgot password, confirm forgot password.
This PR will make sure that request signing is disabled when no auth is passed in. Without this change, botocore will blow up with a
NoCredentialsError
exception: