@@ -788,7 +788,7 @@ def test_coll_name():
788
788
def test_indexing_permissions__81 (self ):
789
789
with session .make_session_for_existing_admin () as admin_session ,\
790
790
indexing_plugin__installed (indexing_config = {'minimum_delay_time' :'1' , 'maximum_delay_time' :'3' }):
791
- List_Active_Task_IDs = lambda : self . active_task_ids ( admin_session , self )
791
+ # - Define collections to be used for test.
792
792
path_to_home = '/{0.zone_name}/home/{0.username}' .format (admin_session )
793
793
test_path = path_to_home + "/" + self .test_coll_name ()
794
794
# STRUCTURE: (HOME)-->test_dir/
@@ -802,11 +802,15 @@ def test_indexing_permissions__81(self):
802
802
data_1 = sub_path1 + "/data1"
803
803
data_2 = sub_path2 + "/data2"
804
804
data_3 = sub_path3 + "/data3"
805
+ # - Define another index.
805
806
INDEX_2 = DEFAULT_METADATA_INDEX + "_2"
806
807
try :
808
+
807
809
# use two indices, to test that multiple index indicators are respected in recursive (-r) ichmod
808
810
create_metadata_index (DEFAULT_METADATA_INDEX )
809
811
create_metadata_index (INDEX_2 )
812
+
813
+ # - Set up a test environment.
810
814
objects = [
811
815
('create' , ['-C' ,{'path' :test_path , 'delete_tree_when_done' : True }]),
812
816
('create' , ['-C' ,{'path' :sub_path1 }]), #--> for ichmod user0 without '-r', on data_1 object only
@@ -821,33 +825,43 @@ def test_indexing_permissions__81(self):
821
825
('sleep_for' , ['' ,{'seconds' :5 }]),
822
826
('wait_for' , [self .delay_queue_is_empty , {'num_iter' :45 ,'interval' :2.125 ,'threshold' :2 }]),
823
827
]
828
+
829
+ # - Enact test environment.
824
830
with self .logical_filesystem_for_indexing (objects ,admin_session ):
831
+
832
+ # - Convenience functions.
825
833
expected_condition = lambda string : (operator .ge ,1 ) if string != 'null' else (operator .eq ,0 )
826
834
num_hits_multiplier = lambda string : 1 if string != 'null' else 0
827
835
828
- for R_perm ,W_perm in [('read' ,'write' ),('null' ,'null' )]: # Test once for setting ACLs and once for enulling them.
836
+ # - On first pass, add ACLs; on the second, enull them. Index and test each time.
837
+
838
+ for R_perm ,W_perm in [('read' ,'write' ),('null' ,'null' )]:
829
839
830
840
hits_ = ([],[],[])
831
841
842
+ # - Non-recursive ichmod and wait for results.
832
843
admin_session .assert_icommand ('ichmod {0} {1} {2}' .format (R_perm ,self .user0 .username ,data_1 ))
833
844
rep_result_0 = repeat_until (* expected_condition (R_perm ), transform = make_number_of_hits_fcn (hits_ [0 ])
834
845
) (search_index_for_userPermissions_user_name ) (DEFAULT_METADATA_INDEX ,self .user0 .username )
835
846
847
+ # - Recursive ichmod and wait for results.
836
848
admin_session .assert_icommand ('ichmod -r {0} {1} {2}' .format (W_perm ,self .user1 .username ,sub_path2 ))
837
849
rep_result_1 = repeat_until (* expected_condition (W_perm ), transform = make_number_of_hits_fcn (hits_ [1 ])
838
850
) (search_index_for_userPermissions_user_name ) (INDEX_2 ,self .user1 .username )
839
851
rep_result_2 = repeat_until (* expected_condition (W_perm ), transform = make_number_of_hits_fcn (hits_ [2 ])
840
852
) (search_index_for_userPermissions_user_name ) (DEFAULT_METADATA_INDEX ,self .user1 .username )
841
853
842
- self .assertTrue (all ([rep_result_0 , rep_result_1 , rep_result_2 ])) # Assert all conditions waited on were met.
854
+ # - Assert all conditions waited on were met.
855
+ self .assertTrue (all ([rep_result_0 , rep_result_1 , rep_result_2 ]))
843
856
857
+ # - Assert the expected number of index hits.
844
858
nhits = lambda array ,user : len (list (filter ((lambda _ :any (e for e in _ ['_source' ]['userPermissions' ] if e ['user' ] == user )),
845
859
array [0 ]['hits' ]['hits' ] )))
846
-
847
860
self .assertEqual ( num_hits_multiplier (R_perm )* 1 , nhits (hits_ [0 ], self .user0 .username ) )
848
861
self .assertEqual ( num_hits_multiplier (W_perm )* 4 , nhits (hits_ [1 ], self .user1 .username ) )
849
862
self .assertEqual ( num_hits_multiplier (W_perm )* 2 , nhits (hits_ [2 ], self .user1 .username ) )
850
863
finally :
864
+ # - Clean up
851
865
delete_metadata_index (DEFAULT_METADATA_INDEX )
852
866
delete_metadata_index (INDEX_2 )
853
867
0 commit comments