Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anodos325 committed Jul 8, 2024
1 parent 69f921e commit 8faa720
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/middlewared/middlewared/plugins/smb_/groupmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from middlewared.service import Service, job, private
from middlewared.service_exception import CallError
from middlewared.utils.sid import (
BASE_RID_USER,
db_id_to_rid,
get_domain_rid,
lsa_sidtype,
sid_is_valid,
BASE_RID_USER,
DomainRid
)
from middlewared.utils.tdb import (
Expand Down Expand Up @@ -288,6 +289,16 @@ def groupmap_list(self):

return rv

@private
def groupmap_listmem(self, sid):
if not sid_is_valid(sid):
raise ValueError(f'{sid}: not a valid SID')

data = list_foreign_group_memberships(GroupmapFile.DEFAULT, sid)
assert data.sid == sid

return data.members

@private
def sync_builtins(self, to_add):
idmap_backend = self.middleware.call_sync("smb.getparm", "idmap config * : backend", "GLOBAL")
Expand Down Expand Up @@ -334,9 +345,7 @@ def synchronize_group_mappings(self, job, bypass_sentinel_check=False):

groupmap = self.groupmap_list()

groups = self.middleware.call_sync('group.query', [
('builtin', '=', False), ('local', '=', True), ('smb', '=', True)
])
groups = self.middleware.call_sync('group.query', [('local', '=', True), ('smb', '=', True)])
groups.append(self.middleware.call_sync('group.query', [('gid', '=', 545), ('local', '=', True)], {'get': True}))
gid_set = {x["gid"] for x in groups}

Expand Down
11 changes: 9 additions & 2 deletions tests/api2/test_smb_groupmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
assert rid == expected_rid

groupmap = call('smb.groupmap_list')
assert str(entry['gid']) in groupmap['local_builtins']
assert groupmap['local_builtins'][str(entry['gid'])]['sid'] == entry['sid']

members = call('smb.groupmap_listmem', expected_memberof)
assert entry['sid'] in members


test__builtin_users_account():
Expand All @@ -24,6 +29,9 @@
rid = int(entry['sid'].split('-')[-1])
assert rid == entry['id'] + BASE_RID_GROUP

members_dom_users = call('smb.groupmap_listmem', 'S-1-5-32-545')
assert entry['sid'] in members_dom_users


test__new_group():
with group({"name": "group1"}) as g:
Expand Down Expand Up @@ -51,6 +59,5 @@
new = call('group.get_instance', g['id'])
assert new['sid'] == g['sid']

#
groupmap = call('smb.groupmap_list')
assert new['gid'] in groupmap['local']
assert str(new['gid']) in groupmap['local']

0 comments on commit 8faa720

Please sign in to comment.