-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly filter for local admins emails
Originally the mail.local_administrators only returned users who were members of the default builtin local administrators privilege by virtue of auxiliary group membership. This commit makes the logic more generic. Since the method was originally written we expanded user.query output to include information about the user's roles and so we can select all users with FULL_ADMIN privileges (which may be granted by non-default privilege sets).
- Loading branch information
Showing
2 changed files
with
32 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
|
||
from middlewared.test.integration.assets.account import user | ||
from middlewared.test.integration.utils import call | ||
|
||
MAILUSER = 'wilbur' | ||
MAILADDR = '[email protected]' | ||
PASSWD = 'abcd1234' | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def full_admin_user(): | ||
ba_id = call('group.query', [['gid', '=', 544]], {'get': True})['id'] | ||
with user({ | ||
'username': MAILUSER, | ||
'full_name': MAILUSER, | ||
'group_create': False, | ||
'email': '[email protected]', | ||
'group': ba_id, | ||
'password': PASSWD | ||
}, get_instance=True) as u: | ||
yield u | ||
|
||
|
||
def test_mail_administrators(full_admin_user): | ||
emails = call('mail.local_administrators_emails') | ||
assert MAILADDR in emails |