|
39 | 39 | load_resource_map, load_user_map, load_vgrid_map, mark_vgrid_modified, \ |
40 | 40 | refresh_resource_map, refresh_user_map, refresh_vgrid_map, \ |
41 | 41 | 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 |
43 | 44 | from tests.support import MigTestCase, ensure_dirs_exist, testmain |
44 | 45 |
|
45 | 46 |
|
@@ -108,7 +109,10 @@ def _create_resource(self, res_name, owners, config=None): |
108 | 109 | self.assertTrue(saved) |
109 | 110 | if config is None: |
110 | 111 | # 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 | + } |
112 | 116 | saved = pickle(config, res_config_path, self.logger) |
113 | 117 | self.assertTrue(saved) |
114 | 118 |
|
@@ -554,6 +558,38 @@ def test_general_vgrid_access(self): |
554 | 558 | self.TEST_OUTSIDER_DN) |
555 | 559 | self.assertFalse(self.test_vgrid in allowed_vgrids) |
556 | 560 |
|
| 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 | + |
557 | 593 | def test_get_re_provider_map(self): |
558 | 594 | """Test RE provider map includes test resource""" |
559 | 595 | test_re = 'Python' |
|
0 commit comments