mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Resolve the log in issue for a user having a non-existing email id
1) Added CHECK_EMAIL_DELIVERABILITY & SECURITY_EMAIL_VALIDATOR_ARGS. 2) Added test cases for deliverability check. Fixes #6550
This commit is contained in:
committed by
Akshay Joshi
parent
ef67409d61
commit
9fdda038a9
82
web/pgadmin/utils/tests/test_validate_email.py
Normal file
82
web/pgadmin/utils/tests/test_validate_email.py
Normal file
@@ -0,0 +1,82 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2021, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from pgadmin.utils.validation_utils import validate_email
|
||||
from unittest.mock import patch
|
||||
import config
|
||||
|
||||
|
||||
class TestEmailValidate(BaseTestGenerator):
|
||||
""" This class will test the email validation utility with or without email
|
||||
deliverability. """
|
||||
|
||||
scenarios = [
|
||||
('Email validation (no deliverability)',
|
||||
dict(
|
||||
data=dict(
|
||||
email_list=['postgres@local.dev', 'pg@pgadminrocks.com',
|
||||
'me.pg@demo.dev', 'pg@123.pgcom',
|
||||
'pg@postgres.local', 'postgres@pg.blah',
|
||||
'john@doe.com', 'punster@tr.co',
|
||||
'admin@example.com'],
|
||||
check_deliverability=False,
|
||||
expected_data=dict(
|
||||
test_result=True
|
||||
)
|
||||
)
|
||||
)),
|
||||
('Email validation (with deliverability)',
|
||||
dict(
|
||||
data=dict(
|
||||
email_list=['postgres@local.dev', 'pg@pgadminrocks.com',
|
||||
'pg@postgres.local'],
|
||||
check_deliverability=True,
|
||||
expected_data=dict(
|
||||
test_result=False
|
||||
)
|
||||
)
|
||||
)),
|
||||
('Empty email validation (no deliverability)',
|
||||
dict(
|
||||
data=dict(
|
||||
email_list=[''],
|
||||
check_deliverability=False,
|
||||
expected_data=dict(
|
||||
test_result=False
|
||||
)
|
||||
)
|
||||
)),
|
||||
('Empty email validation (with deliverability)',
|
||||
dict(
|
||||
data=dict(
|
||||
email_list=[''],
|
||||
check_deliverability=True,
|
||||
expected_data=dict(
|
||||
test_result=False
|
||||
)
|
||||
)
|
||||
))
|
||||
]
|
||||
|
||||
def runTest(self):
|
||||
|
||||
if config.SERVER_MODE is False:
|
||||
self.skipTest(
|
||||
"Can not run email validation test cases in the DESKTOP mode."
|
||||
)
|
||||
config.CHECK_EMAIL_DELIVERABILITY = self.data['check_deliverability']
|
||||
|
||||
for e in self.data['email_list']:
|
||||
result = validate_email(e)
|
||||
# validate_email returns True if email is valid,
|
||||
# even if non-deliverable. False if email is not valid or
|
||||
# deliverability is turned ON.
|
||||
self.assertEqual(result,
|
||||
self.data['expected_data']['test_result'])
|
||||
Reference in New Issue
Block a user