diff --git a/web/pgadmin/browser/tests/test_change_password.py b/web/pgadmin/browser/tests/test_change_password.py index ffd499068..2d09c26bd 100644 --- a/web/pgadmin/browser/tests/test_change_password.py +++ b/web/pgadmin/browser/tests/test_change_password.py @@ -62,7 +62,7 @@ class ChangePasswordTestCase(BaseTestGenerator): new_password_confirm=( config_data['pgAdmin4_login_credentials'] ['new_password']), - respdata='Invalid password')), + respdata='Incorrect username or password')), # This test case checks for valid password ('TestCase for Changing Valid_Password', dict( diff --git a/web/pgadmin/browser/tests/test_kerberos_with_mocking.py b/web/pgadmin/browser/tests/test_kerberos_with_mocking.py index 6b61dc1d0..e67ced8c4 100644 --- a/web/pgadmin/browser/tests/test_kerberos_with_mocking.py +++ b/web/pgadmin/browser/tests/test_kerberos_with_mocking.py @@ -101,7 +101,7 @@ class KerberosLoginMockTestCase(BaseTestGenerator): del_crads = delCrads() - AuthSourceRegistry.registry['kerberos'].negotiate_start = MagicMock( + AuthSourceRegistry._registry['kerberos'].negotiate_start = MagicMock( return_value=[True, del_crads]) return del_crads diff --git a/web/pgadmin/browser/tests/test_ldap_with_mocking.py b/web/pgadmin/browser/tests/test_ldap_with_mocking.py index 30df7729e..92f5c70c7 100644 --- a/web/pgadmin/browser/tests/test_ldap_with_mocking.py +++ b/web/pgadmin/browser/tests/test_ldap_with_mocking.py @@ -57,13 +57,13 @@ class LDAPLoginMockTestCase(BaseTestGenerator): app_config.LDAP_BIND_USER = None app_config.LDAP_BIND_PASSWORD = None - @patch.object(AuthSourceRegistry.registry['ldap'], 'connect', + @patch.object(AuthSourceRegistry._registry['ldap'], 'connect', return_value=[True, "Done"]) - @patch.object(AuthSourceRegistry.registry['ldap'], 'search_ldap_user', + @patch.object(AuthSourceRegistry._registry['ldap'], 'search_ldap_user', return_value=[True, '']) def runTest(self, conn_mock_obj, search_mock_obj): """This function checks ldap login functionality.""" - AuthSourceRegistry.registry['ldap'].dedicated_user = False + AuthSourceRegistry._registry['ldap'].dedicated_user = False res = self.tester.login(self.username, self.password, True) respdata = 'Gravatar image for %s' % self.username self.assertTrue(respdata in res.data.decode('utf8')) diff --git a/web/pgadmin/browser/tests/test_login.py b/web/pgadmin/browser/tests/test_login.py index c7816156d..743d0099c 100644 --- a/web/pgadmin/browser/tests/test_login.py +++ b/web/pgadmin/browser/tests/test_login.py @@ -29,7 +29,7 @@ class LoginTestCase(BaseTestGenerator): ['login_username']), password=str(uuid.uuid4())[4:8], is_gravtar_image_check=False, - respdata='Invalid password')), + respdata='Incorrect username or password')), # This test case validates the empty password field ('Empty_Password', dict( @@ -45,13 +45,13 @@ class LoginTestCase(BaseTestGenerator): config_data['pgAdmin4_login_credentials'] ['login_password']), is_gravtar_image_check=False, - respdata='Email not provided')), + respdata='Email/Username is not valid')), # This test case validates empty email and password ('Empty_Credentials', dict( email='', password='', is_gravtar_image_check=False, - respdata='Email not provided')), + respdata='Email/Username is not valid')), # This test case validates the invalid/incorrect email id ('Invalid_Email', dict( @@ -60,14 +60,14 @@ class LoginTestCase(BaseTestGenerator): config_data['pgAdmin4_login_credentials'] ['login_password']), is_gravtar_image_check=False, - respdata='Specified user does not exist')), + respdata='Incorrect username or password')), # This test case validates invalid email and password ('Invalid_Credentials', dict( email=str(uuid.uuid4())[1:8] + '@xyz.com', password=str(uuid.uuid4())[4:8], is_gravtar_image_check=False, - respdata='Specified user does not exist')), + respdata='Incorrect username or password')), # This test case validates the valid/correct credentials and allow user # to login pgAdmin 4 @@ -106,8 +106,6 @@ class LoginTestCase(BaseTestGenerator): if self.is_gravtar_image_check: if app_config.SHOW_GRAVATAR_IMAGE: self.assertTrue(self.respdata in res.data.decode('utf8')) - else: - print(self.respdata_without_gravtar in res.data.decode('utf8')) else: self.assertTrue(self.respdata in res.data.decode('utf8')) diff --git a/web/pgadmin/browser/tests/test_reset_password.py b/web/pgadmin/browser/tests/test_reset_password.py index 1ce7ea69c..17af7c0b6 100644 --- a/web/pgadmin/browser/tests/test_reset_password.py +++ b/web/pgadmin/browser/tests/test_reset_password.py @@ -29,7 +29,7 @@ class ResetPasswordTestCase(BaseTestGenerator): # This test case validates the invalid/incorrect email field ('TestCase for Validating Invalid_Email', dict( email=str(uuid.uuid4())[1:8] + '@xyz.com', - respdata='Specified user does not exist')), + respdata='Incorrect username or password')), # This test case validates the valid email id ('TestCase for Validating Valid_Email', dict( diff --git a/web/regression/python_test_utils/csrf_test_client.py b/web/regression/python_test_utils/csrf_test_client.py index ca4120e18..5e5259014 100644 --- a/web/regression/python_test_utils/csrf_test_client.py +++ b/web/regression/python_test_utils/csrf_test_client.py @@ -76,6 +76,10 @@ class TestClient(testing.FlaskClient): b' value="([^"]*)">', res.data ) + if m is None: + # When login through Kerberos, we won't find the CSRF + return None + return m.group(1).decode("utf-8") def generate_csrf_token(self, *args, **kwargs):