-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not allow a Site Administrator user to add users to groups that have
the Manager role
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,20 @@ def setUp(self): | |
def tearDown(self): | ||
self.api_session.close() | ||
|
||
def set_siteadm(self): | ||
siteadm_username = "siteadm" | ||
siteadm_password = "siteadmpassword" | ||
api.user.create( | ||
email="[email protected]", | ||
roles=["Site Administrator"], | ||
username=siteadm_username, | ||
password=siteadm_password, | ||
) | ||
self.api_session = RelativeSession(self.portal_url, test=self) | ||
self.api_session.headers.update({"Accept": "application/json"}) | ||
self.api_session.auth = (siteadm_username, siteadm_password) | ||
transaction.commit() | ||
|
||
def test_list_groups(self): | ||
response = self.api_session.get("/@groups") | ||
|
||
|
@@ -173,3 +187,14 @@ def test_delete_non_existing_group(self): | |
transaction.commit() | ||
|
||
self.assertEqual(response.status_code, 404) | ||
|
||
def test_siteadm_not_add_user_to_group_with_manager_role(self): | ||
self.set_siteadm() | ||
payload = { | ||
"users": {TEST_USER_ID: True, SITE_OWNER_NAME: False}, | ||
} | ||
self.api_session.patch("/@groups/Administrators", json=payload) | ||
transaction.commit() | ||
|
||
ploneteam = self.gtool.getGroupById("Administrators") | ||
self.assertNotIn(TEST_USER_ID, ploneteam.getGroupMemberIds()) |