Fixed server mode api test case failure.

This commit is contained in:
Ashesh Vashi 2021-06-24 19:41:58 +05:30 committed by Akshay Joshi
parent 9574f43f87
commit cfb68d73a0
6 changed files with 15 additions and 13 deletions

View File

@ -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(

View File

@ -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

View File

@ -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'))

View File

@ -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'))

View File

@ -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(

View File

@ -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):