mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-12-25 08:21:04 -06:00
Fixed API test case for change password in the server mode. Fixes #7648
This commit is contained in:
parent
317a17337d
commit
7c729d5f0e
@ -27,3 +27,4 @@ Bug fixes
|
||||
| `Issue #7580 <https://redmine.postgresql.org/issues/7580>`_ - Fixed an issue where backup does not work due to parameter 'preexec_fn' no longer being supported.
|
||||
| `Issue #7644 <https://redmine.postgresql.org/issues/7644>`_ - Ensure that the dump servers functionality works from setup.py.
|
||||
| `Issue #7646 <https://redmine.postgresql.org/issues/7646>`_ - Ensure that the Import/Export server menu option is visible.
|
||||
| `Issue #7648 <https://redmine.postgresql.org/issues/7648>`_ - Fixed API test case for change password in the server mode.
|
||||
|
@ -93,18 +93,32 @@ class ChangePasswordTestCase(BaseTestGenerator):
|
||||
# test case
|
||||
if 'valid_password' in dir(self):
|
||||
response = self.tester.post(
|
||||
'/user_management/user/',
|
||||
data=json.dumps(dict(
|
||||
username=self.username,
|
||||
email=self.username,
|
||||
newPassword=self.password,
|
||||
confirmPassword=self.password,
|
||||
active=True,
|
||||
role="2"
|
||||
)),
|
||||
'/user_management/save',
|
||||
data=json.dumps({
|
||||
"added": [{
|
||||
"auth_source": "internal",
|
||||
"email": self.username,
|
||||
"role": "2",
|
||||
"active": True,
|
||||
"newPassword": self.password,
|
||||
"confirmPassword": self.password,
|
||||
"locked": False
|
||||
}]
|
||||
}),
|
||||
follow_redirects=True
|
||||
)
|
||||
user_id = json.loads(response.data.decode('utf-8'))['id']
|
||||
self.assertEqual(response.status_code, 200,
|
||||
'User creation is NOT successful')
|
||||
# Get usr id
|
||||
response = self.tester.get('/user_management/user/')
|
||||
users = json.loads(response.data.decode('utf-8'))
|
||||
user_id = None
|
||||
for user in users:
|
||||
if user['email'] == self.username:
|
||||
user_id = user['id']
|
||||
break
|
||||
self.assertIsNotNone(user_id,
|
||||
'User id for newly created user is None')
|
||||
# Logout the Administrator before login normal user
|
||||
self.tester.logout()
|
||||
response = self.tester.login(self.username, self.password, True)
|
||||
@ -115,8 +129,19 @@ class ChangePasswordTestCase(BaseTestGenerator):
|
||||
self.tester.logout()
|
||||
# Login the Administrator before deleting normal user
|
||||
test_utils.login_tester_account(self.tester)
|
||||
response = self.tester.delete(
|
||||
'/user_management/user/' + str(user_id),
|
||||
response = self.tester.post(
|
||||
'/user_management/save',
|
||||
data=json.dumps({
|
||||
"deleted": [{
|
||||
"id": user_id,
|
||||
"active": True,
|
||||
"auth_source": "internal",
|
||||
"username": self.username,
|
||||
"email": self.username,
|
||||
"role": "2",
|
||||
"locked": False
|
||||
}]
|
||||
}),
|
||||
follow_redirects=True
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
Loading…
Reference in New Issue
Block a user