Allow admins to disable the use of Gravatar if they choose. Fixes #3037

This commit is contained in:
Murtuza Zabuawala
2018-03-07 16:35:33 +00:00
committed by Dave Page
parent ae5c13188d
commit abf0b1a7ae
8 changed files with 122 additions and 21 deletions

View File

@@ -0,0 +1,68 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import config
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from regression.test_setup import config_data as tconfig
class TestLoginUserImage(BaseTestGenerator):
"""
This class checks for user image after successful login.
- If SHOW_GRAVATAR_IMAGE config option is set to True then we will show
Gravatar on the Page.
- If SHOW_GRAVATAR_IMAGE config option is set to False then we will show
Static image on the Page.
"""
scenarios = [
(
'Verify gravatar image on the page', dict(
email=(
tconfig['pgAdmin4_login_credentials']['login_username']
),
password=(
tconfig['pgAdmin4_login_credentials']['login_password']
),
respdata='Gravatar image for %s' %
tconfig['pgAdmin4_login_credentials']
['login_username'],
)
)
]
@classmethod
def setUpClass(cls):
"Logout first if already logged in"
utils.logout_tester_account(cls.tester)
def runTest(self):
# Login and check type of image in response
response = self.tester.post(
'/login', data=dict(
email=self.email,
password=self.password
),
follow_redirects=True
)
# Should have gravatar image
if config.SHOW_GRAVATAR_IMAGE:
self.assertIn(self.respdata, response.data.decode('utf8'))
# Should not have gravatar image
else:
self.assertNotIn(self.respdata, response.data.decode('utf8'))
@classmethod
def tearDownClass(cls):
"""
We need to again login the test client as soon as test scenarios
finishes.
"""
utils.login_tester_account(cls.tester)

View File

@@ -62,13 +62,15 @@ class LoginTestCase(BaseTestGenerator):
# This test case validates the valid/correct credentials and allow user
# to login pgAdmin 4
('Valid_Credentials', dict(
email=(config_data['pgAdmin4_login_credentials']
['login_username']),
password=(config_data['pgAdmin4_login_credentials']
['login_password']),
respdata='Gravatar image for %s' %
config_data['pgAdmin4_login_credentials']
['login_username']))
email=(config_data[
'pgAdmin4_login_credentials'
]['login_username']),
password=(config_data[
'pgAdmin4_login_credentials'
]['login_password']),
respdata='%s' % config_data['pgAdmin4_login_credentials']
['login_username'])
)
]
@classmethod