public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: Ashesh Vashi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: Refactor: Registry Classes
Date: Thu, 24 Jun 2021 15:51:21 +0530
Message-ID: <CAFOhELfHp1DawtMyoD83oQC74zrU+rSsc2F2evyfsgHVLmawzA@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDcQtnsEt-koh8dFLznyQMkaVhkF-rerW+NtzvdqPEoB=Q@mail.gmail.com>
References: <CAG7mmoz=wOOc3QiZDZuSwonFue_sowcZRtZLK_M0o839ZPnJ_Q@mail.gmail.com>
<CAG7mmoxQfhVhGUC2ArMkCPUoWiBusu-z6=0PR8OiZfOMQpnWwg@mail.gmail.com>
<CANxoLDcUuG1+yO0nGjXvZGwxnpofwyfsBNjOimSbvr40-6UPFw@mail.gmail.com>
<CAG7mmow6uPDAhfELmyXjBziHti0dE6aYCM7ufJZS3VXYZoLT-A@mail.gmail.com>
<CANxoLDcQtnsEt-koh8dFLznyQMkaVhkF-rerW+NtzvdqPEoB=Q@mail.gmail.com>
Hi,
This patch introduced the server mode api test case failure, please find
the attached patch to fix those as well as some of the old issues in the
server mode.
Patch by: Ashesh Vashi
Thanks,
Khushboo
On Thu, Jun 24, 2021 at 11:31 AM Akshay Joshi <[email protected]>
wrote:
> Thanks, the patch applied.
>
> On Wed, Jun 23, 2021 at 7:54 PM Ashesh Vashi <
> [email protected]> wrote:
>
>> On Wed, Jun 23, 2021 at 1:22 PM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Hi Ashesh
>>>
>>> Following are the review comments:
>>>
>>> - Fixed PEP8 issues.
>>>
>>> Done.
>>
>>>
>>> - In "dynamic_registry/__init__.py" decorator @classmethod used for "
>>> *_get*" and "*_load_modules*" methods which are actually outside of
>>> the class. Even constructor also outside of the class.
>>>
>>> 'create_registry_metaclass' is not a class, but a method to create the
>> dynamic classes.
>> If I move these methods in 'create_registry_metaclass' method, SonarQube
>> raises issues about complexity of the functions, hence - they're best kept
>> outside of that method.
>>
>>>
>>> - Remove unused imports from "driver/registry.py"
>>>
>>> Done
>>
>>>
>>> -
>>> - Fixed sonarqube issues in
>>> "dynamic_registry/tests/registry/__init__.py"
>>>
>>> Done
>> As discussed, SonarQube is not able to understand that the result object
>> is a class, and not an object, hence - showing linter issues.
>> I've disabled them in those lines by adding the comment '# NOSNAR' at the
>> end.
>>
>> -- Thanks, Ashesh
>>
>>>
>>> On Sat, Jun 19, 2021 at 11:27 AM Ashesh Vashi <
>>> [email protected]> wrote:
>>>
>>>> On Sat, Jun 19, 2021 at 1:39 AM Ashesh Vashi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Akshay,
>>>>>
>>>>> We do have a couple of classes, which does automatic registration of
>>>>> the base classes,
>>>>> and which creates single-ton objects for these base classes, when
>>>>> needed.
>>>>>
>>>>> I would be working on a patch sooner, which will be using similar
>>>>> functionality for loading
>>>>> the multi-factor authentication.
>>>>>
>>>>> I realized - it will be a duplicate code at three places for the same
>>>>> functionalities.
>>>>> Hence - I worked on refactoring this registry class.
>>>>>
>>>>> Please find the patch for the same.
>>>>>
>>>> Found issues - some test files were using the old function
>>>> 'Driver.load_drivers(...)'.
>>>> They're fixed now.
>>>>
>>>> -- Thanks, Ashesh
>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Thanks & Regards,
>>>>>
>>>>> Ashesh Vashi
>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>> <http://www.enterprisedb.com;
>>>>>
>>>>>
>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>> <http://www.linkedin.com/in/asheshvashi;
>>>>>
>>>>
>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>> *pgAdmin Hacker | Principal Software Architect*
>>> *EDB Postgres <http://edbpostgres.com>*
>>>
>>> *Mobile: +91 976-788-8246*
>>>
>>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>
Attachments:
[application/octet-stream] test_cases_server_mode.patch (6.2K, 3-test_cases_server_mode.patch)
download | inline diff:
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):
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Refactor: Registry Classes
In-Reply-To: <CAFOhELfHp1DawtMyoD83oQC74zrU+rSsc2F2evyfsgHVLmawzA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox