From a2ce7d30bdd999c6daaa6f8c7637f4d6fd847ca3 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 3 Apr 2023 11:37:21 -0400 Subject: [PATCH] UT: Strengthen the assertion in __fails_if_token_invalid() --- .../test_authentication_service.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/authentication_service/test_authentication_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/authentication_service/test_authentication_service.py index bd6a7e650b4..cd1475f5fae 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/authentication_service/test_authentication_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/authentication_service/test_authentication_service.py @@ -11,7 +11,11 @@ AuthenticationFacade, ) from monkey_island.cc.services.authentication_service.setup import setup_authentication -from monkey_island.cc.services.authentication_service.token import TokenGenerator, TokenParser +from monkey_island.cc.services.authentication_service.token import ( + TokenGenerator, + TokenParser, + TokenValidationError, +) from monkey_island.cc.services.authentication_service.user import User USERNAME = "user1" @@ -157,9 +161,9 @@ def test_generate_new_token_pair__fails_if_token_invalid( user = User(username=USERNAME, password=PASSWORD, fs_uniquifier="a") user.save() refresh_token = authentication_facade.generate_refresh_token(user) - mock_token_parser.parse.side_effect = Exception() + mock_token_parser.parse.side_effect = TokenValidationError() - with pytest.raises(Exception): + with pytest.raises(TokenValidationError): authentication_facade.generate_new_token_pair(refresh_token)