Skip to content

Commit ae30422

Browse files
committed
Tweak dummy user provisioning a bit more to pick up more samples in tested
functions and increase basic coverage.
1 parent ee2837f commit ae30422

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

tests/test_mig_shared_vgridaccess.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
load_resource_map, load_user_map, load_vgrid_map, mark_vgrid_modified, \
4040
refresh_resource_map, refresh_user_map, refresh_vgrid_map, \
4141
res_vgrid_access, reset_vgrids_modified, resources_using_re, unmap_vgrid, \
42-
user_vgrid_access, vgrid_inherit_map
42+
user_allowed_res_confs, user_vgrid_access, user_visible_res_confs, \
43+
user_visible_user_confs, vgrid_inherit_map
4344
from tests.support import MigTestCase, ensure_dirs_exist, testmain
4445

4546

@@ -108,7 +109,10 @@ def _create_resource(self, res_name, owners, config=None):
108109
self.assertTrue(saved)
109110
if config is None:
110111
# Make sure conf has one valid field
111-
config = {'HOSTURL': res_name}
112+
config = {'HOSTURL': res_name,
113+
'EXECONFIG': [{'name': 'exe', 'vgrid': ['Generic']}],
114+
'STORECONFIG': [{'name': 'exe', 'vgrid': ['Generic']}]
115+
}
112116
saved = pickle(config, res_config_path, self.logger)
113117
self.assertTrue(saved)
114118

@@ -554,6 +558,38 @@ def test_general_vgrid_access(self):
554558
self.TEST_OUTSIDER_DN)
555559
self.assertFalse(self.test_vgrid in allowed_vgrids)
556560

561+
def test_user_allowed_res_confs(self):
562+
"""Minimal test for user_allowed_res_confs"""
563+
# Create test user and add test resource to vgrid
564+
self._provision_test_user(self, self.TEST_OWNER_DN)
565+
self._create_resource(self.TEST_RESOURCE_ID, [self.TEST_OWNER_DN])
566+
self._create_vgrid(self.test_vgrid, owners=[self.TEST_OWNER_DN],
567+
resources=[self.TEST_RESOURCE_ID])
568+
force_update_vgrid_map(self.configuration)
569+
force_update_resource_map(self.configuration)
570+
# Owner should be allowed access
571+
allowed = user_allowed_res_confs(self.configuration,
572+
self.TEST_OWNER_DN)
573+
self.assertIn(self.TEST_RESOURCE_ALIAS, allowed)
574+
575+
def test_user_visible_res_confs(self):
576+
"""Minimal test for user_visible_res_confs"""
577+
# Owner should see owned resources even without vgrid access
578+
self._create_resource(self.TEST_RESOURCE_ID, [self.TEST_OWNER_DN])
579+
force_update_resource_map(self.configuration)
580+
visible = user_visible_res_confs(
581+
self.configuration, self.TEST_OWNER_DN)
582+
self.assertIn(self.TEST_RESOURCE_ALIAS, visible)
583+
584+
def test_user_visible_user_confs(self):
585+
"""Minimal test for user_visible_user_confs"""
586+
# Owner should see themselves in auto map
587+
self._provision_test_user(self, self.TEST_OWNER_DN)
588+
force_update_user_map(self.configuration)
589+
visible = user_visible_user_confs(
590+
self.configuration, self.TEST_OWNER_DN)
591+
self.assertIn(self.TEST_OWNER_UUID, visible)
592+
557593
def test_get_re_provider_map(self):
558594
"""Test RE provider map includes test resource"""
559595
test_re = 'Python'

0 commit comments

Comments
 (0)