Skip to content

Commit 74b98b9

Browse files
authored
Merge pull request #28 from stax-labs/feat/auth_errors
feat (auth) fix error messages
2 parents 9b466ca + 5314ec5 commit 74b98b9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

staxapp/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def id_token_from_cognito(self, username=None, password=None, client=None):
6262
try:
6363
tokens = aws.authenticate_user()
6464
except ClientError as e:
65-
if e.response["Error"]["Code"] == "UserNotFoundException":
65+
if e.response["Error"]["Code"] == "NotAuthorizedException":
6666
raise InvalidCredentialsException(
6767
message=str(e), detail="Please check your Secret Key is correct"
6868
)
69-
elif e.response["Error"]["Code"] == "NotAuthorizedException":
69+
elif e.response["Error"]["Code"] == "UserNotFoundException":
7070
raise InvalidCredentialsException(
7171
message=str(e),
7272
detail="Please check your Access Key, that you have created your Api Token and that you are using the right STAX REGION",

tests/test_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def testCredentialErrors(self):
6767

6868
sa = StaxAuth("ApiAuth")
6969
# Test with invalid username password
70-
self.stub_aws_srp(sa, "bad_password", "UserNotFoundException")
70+
self.stub_aws_srp(sa, "bad_password", "NotAuthorizedException")
7171
user_not_found_success = False
7272
try:
7373
sa.id_token_from_cognito(
@@ -79,7 +79,7 @@ def testCredentialErrors(self):
7979
self.assertTrue(user_not_found_success)
8080

8181
# Test with no access
82-
self.stub_aws_srp(sa, "no_access", "NotAuthorizedException")
82+
self.stub_aws_srp(sa, "no_access", "UserNotFoundException")
8383
no_access_success = False
8484
try:
8585
sa.id_token_from_cognito(

0 commit comments

Comments
 (0)