mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Test suite enhancements:
1. The user will specify the tablespace path in test_config.json.in 2. If tablespace path not found, skip the test cases for that server(Only tablespace test cases) 3. Add the skipped test summary in the test result. (Now it's showing on console + in log file, but need to update in a final enhanced test summary report. Which is research point we will work on that after finishing all nodes API test cases) 4. Removed the test_ prefix from the values in the config files. 5. Add tablespace and roles tests
This commit is contained in:
committed by
Dave Page
parent
2b13d55016
commit
81e2bc1e80
@@ -8,9 +8,12 @@
|
||||
# ##########################################################################
|
||||
|
||||
import uuid
|
||||
import json
|
||||
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression.test_setup import config_data
|
||||
from regression import test_utils as utils
|
||||
from utils import change_password
|
||||
|
||||
|
||||
class ChangePasswordTestCase(BaseTestGenerator):
|
||||
@@ -24,9 +27,9 @@ class ChangePasswordTestCase(BaseTestGenerator):
|
||||
# This testcase validates invalid confirmation password
|
||||
('TestCase for Validating Incorrect_New_Password', dict(
|
||||
password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
['login_password']),
|
||||
new_password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_new_password']),
|
||||
['new_password']),
|
||||
new_password_confirm=str(uuid.uuid4())[4:8],
|
||||
respdata='Passwords do not match')),
|
||||
|
||||
@@ -34,7 +37,7 @@ class ChangePasswordTestCase(BaseTestGenerator):
|
||||
# minimum length
|
||||
('TestCase for Validating New_Password_Less_Than_Min_Length',
|
||||
dict(password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
['login_password']),
|
||||
new_password=str(uuid.uuid4())[4:8],
|
||||
new_password_confirm=str(uuid.uuid4())[4:8],
|
||||
respdata='Password must be at least 6 characters')),
|
||||
@@ -42,7 +45,7 @@ class ChangePasswordTestCase(BaseTestGenerator):
|
||||
# This testcase validates if both password fields are left blank
|
||||
('TestCase for Validating Empty_New_Password', dict(
|
||||
password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
['login_password']),
|
||||
new_password='', new_password_confirm='',
|
||||
respdata='Password not provided')),
|
||||
|
||||
@@ -50,57 +53,66 @@ class ChangePasswordTestCase(BaseTestGenerator):
|
||||
('TestCase for Validating Incorrect_Current_Password', dict(
|
||||
password=str(uuid.uuid4())[4:8],
|
||||
new_password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_new_password']),
|
||||
['new_password']),
|
||||
new_password_confirm=(
|
||||
config_data['pgAdmin4_login_credentials']
|
||||
['test_new_password']),
|
||||
['new_password']),
|
||||
respdata='Invalid password')),
|
||||
|
||||
# This testcase checks for valid password
|
||||
# This test case checks for valid password
|
||||
('TestCase for Changing Valid_Password', dict(
|
||||
password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
new_password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_new_password']),
|
||||
valid_password='reassigning_password',
|
||||
username=(config_data['pgAdmin4_test_user_credentials']
|
||||
['login_username']),
|
||||
password=(config_data['pgAdmin4_test_user_credentials']
|
||||
['login_password']),
|
||||
new_password=(config_data['pgAdmin4_test_user_credentials']
|
||||
['new_password']),
|
||||
new_password_confirm=(
|
||||
config_data['pgAdmin4_login_credentials']
|
||||
['test_new_password']),
|
||||
respdata='You successfully changed your password.')),
|
||||
('Reassigning_Password', dict(
|
||||
test_case='reassigning_password',
|
||||
password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_new_password']),
|
||||
new_password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
new_password_confirm=(
|
||||
config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
config_data['pgAdmin4_test_user_credentials']
|
||||
['new_password']),
|
||||
respdata='You successfully changed your password.'))
|
||||
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
def runTest(self):
|
||||
"""This function will check change password functionality."""
|
||||
|
||||
# Check for 'test_case' exists in self For reassigning the password.
|
||||
# Password gets change in change password test case.
|
||||
if 'test_case' in dir(self):
|
||||
email = \
|
||||
config_data['pgAdmin4_login_credentials'][
|
||||
'test_login_username']
|
||||
password = \
|
||||
config_data['pgAdmin4_login_credentials'][
|
||||
'test_new_password']
|
||||
# Check for 'valid_password' exists in self to test 'valid password'
|
||||
# test case
|
||||
if 'valid_password' in dir(self):
|
||||
response = self.tester.post('/user_management/user/', data=dict(
|
||||
email=self.username, newPassword=self.password,
|
||||
confirmPassword=self.password, active=1, role="2"),
|
||||
follow_redirects=True)
|
||||
user_id = json.loads(response.data.decode('utf-8'))['id']
|
||||
|
||||
# Logout the Administrator before login normal user
|
||||
utils.logout_tester_account(self.tester)
|
||||
|
||||
response = self.tester.post('/login', data=dict(
|
||||
email=email, password=password), follow_redirects=True)
|
||||
email=self.username, password=self.password),
|
||||
follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = self.tester.get('/change', follow_redirects=True)
|
||||
self.assertIn('pgAdmin 4 Password Change', response.data.decode(
|
||||
'utf-8'))
|
||||
# test the 'change password' test case
|
||||
change_password(self)
|
||||
|
||||
response = self.tester.post('/change', data=dict(
|
||||
password=self.password,
|
||||
new_password=self.new_password,
|
||||
new_password_confirm=self.new_password_confirm),
|
||||
follow_redirects=True)
|
||||
self.assertIn(self.respdata, response.data.decode('utf-8'))
|
||||
# Delete the normal user after changing it's password
|
||||
utils.logout_tester_account(self.tester)
|
||||
|
||||
# Login the Administrator before deleting normal user
|
||||
utils.login_tester_account(self.tester)
|
||||
response = self.tester.delete(
|
||||
'/user_management/user/' + str(user_id),
|
||||
follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
else:
|
||||
change_password(self)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
utils.login_tester_account(cls.tester)
|
||||
|
||||
@@ -24,20 +24,20 @@ class LoginTestCase(BaseTestGenerator):
|
||||
# This test case validates the invalid/incorrect password
|
||||
('TestCase for Checking Invalid_Password', dict(
|
||||
email=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_username']),
|
||||
['login_username']),
|
||||
password=str(uuid.uuid4())[4:8],
|
||||
respdata='Invalid password')),
|
||||
|
||||
# This test case validates the empty password field
|
||||
('Empty_Password', dict(
|
||||
email=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_username']), password='',
|
||||
['login_username']), password='',
|
||||
respdata='Password not provided')),
|
||||
|
||||
# This test case validates blank email field
|
||||
('Empty_Email', dict(
|
||||
email='', password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
['login_password']),
|
||||
respdata='Email not provided')),
|
||||
|
||||
# This test case validates empty email and password
|
||||
@@ -49,7 +49,7 @@ class LoginTestCase(BaseTestGenerator):
|
||||
('Invalid_Email', dict(
|
||||
email=str(uuid.uuid4())[1:6] + '@xyz.com',
|
||||
password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
['login_password']),
|
||||
respdata='Specified user does not exist')),
|
||||
|
||||
# This test case validates invalid email and password
|
||||
@@ -62,21 +62,22 @@ class LoginTestCase(BaseTestGenerator):
|
||||
# to login pgAdmin 4
|
||||
('Valid_Credentials', dict(
|
||||
email=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_username']),
|
||||
['login_username']),
|
||||
password=(config_data['pgAdmin4_login_credentials']
|
||||
['test_login_password']),
|
||||
['login_password']),
|
||||
respdata='Gravatar image for %s' %
|
||||
config_data['pgAdmin4_login_credentials']
|
||||
['test_login_username']))
|
||||
['login_username']))
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""
|
||||
We need to logout the test client as we are testing scenarios of
|
||||
logging in the client like invalid password, invalid emails,
|
||||
empty credentials etc.
|
||||
"""
|
||||
utils.logout_tester_account(self.tester)
|
||||
utils.logout_tester_account(cls.tester)
|
||||
|
||||
def runTest(self):
|
||||
"""This function checks login functionality."""
|
||||
@@ -86,9 +87,10 @@ class LoginTestCase(BaseTestGenerator):
|
||||
follow_redirects=True)
|
||||
self.assertIn(self.respdata, response.data.decode('utf8'))
|
||||
|
||||
def tearDown(self):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""
|
||||
We need to again login the test client as soon as test scenarios
|
||||
finishes.
|
||||
"""
|
||||
utils.login_tester_account(self.tester)
|
||||
utils.login_tester_account(cls.tester)
|
||||
|
||||
@@ -24,7 +24,8 @@ class LogoutTest(BaseTestGenerator):
|
||||
('Logging Out', dict(respdata='Redirecting...'))
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
def runTest(self):
|
||||
@@ -33,9 +34,10 @@ class LogoutTest(BaseTestGenerator):
|
||||
response = self.tester.get('/logout')
|
||||
self.assertIn(self.respdata, response.data.decode('utf8'))
|
||||
|
||||
def tearDown(self):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
"""
|
||||
We need to again login the test client as soon as test scenarios
|
||||
finishes.
|
||||
"""
|
||||
utils.login_tester_account(self.tester)
|
||||
utils.login_tester_account(cls.tester)
|
||||
|
||||
@@ -34,11 +34,12 @@ class ResetPasswordTestCase(BaseTestGenerator):
|
||||
# This test case validates the valid email id
|
||||
('TestCase for Validating Valid_Email', dict(
|
||||
email=config_data['pgAdmin4_login_credentials']
|
||||
['test_login_username'], respdata='pgAdmin 4'))
|
||||
['login_username'], respdata='pgAdmin 4'))
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
logout_tester_account(self.tester)
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
logout_tester_account(cls.tester)
|
||||
|
||||
def runTest(self):
|
||||
"""This function checks reset password functionality."""
|
||||
@@ -51,5 +52,6 @@ class ResetPasswordTestCase(BaseTestGenerator):
|
||||
follow_redirects=True)
|
||||
self.assertIn(self.respdata, response.data.decode('utf-8'))
|
||||
|
||||
def tearDown(self):
|
||||
login_tester_account(self.tester)
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
login_tester_account(cls.tester)
|
||||
|
||||
21
web/pgadmin/browser/tests/utils.py
Normal file
21
web/pgadmin/browser/tests/utils.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# ##########################################################################
|
||||
#
|
||||
# #pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# #Copyright (C) 2013 - 2016, The pgAdmin Development Team
|
||||
# #This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# ##########################################################################
|
||||
|
||||
|
||||
def change_password(self):
|
||||
response = self.tester.get('/change', follow_redirects=True)
|
||||
self.assertIn('pgAdmin 4 Password Change', response.data.decode(
|
||||
'utf-8'))
|
||||
|
||||
response = self.tester.post('/change', data=dict(
|
||||
password=self.password,
|
||||
new_password=self.new_password,
|
||||
new_password_confirm=self.new_password_confirm),
|
||||
follow_redirects=True)
|
||||
self.assertIn(self.respdata, response.data.decode('utf-8'))
|
||||
Reference in New Issue
Block a user