def test_remove_acl_entries_recursive(azure): with setup_tree(azure): acluser = AZURE_ACL_TEST_APPID permission = "rwx" azure.modify_acl_entries(test_dir, acl_spec="user:"******":" + permission, recursive=True) files = list(azure.walk(test_dir)) directories = list(set([x[0] for x in map(os.path.split, files)])) for path in files + directories: current_acl = azure.get_acl_status(path) acl_user_entry = [ s for s in current_acl['entries'] if acluser in s ] assert acl_user_entry != [] azure.remove_acl_entries(test_dir, acl_spec="user:" + acluser, recursive=True) for path in files + directories: current_acl = azure.get_acl_status(path) acl_user_entry = [ s for s in current_acl['entries'] if acluser in s ] assert acl_user_entry == []
def test_remove_acl_entries(azure): with azure_teardown(azure): acluser = AZURE_ACL_TEST_APPID azure.touch(a) permission = "rwx" azure.modify_acl_entries(a, acl_spec="user:"******":"+permission) current_acl = azure.get_acl_status(a) aclspec = [s for s in current_acl['entries'] if acluser in s] assert aclspec != [] azure.remove_acl_entries(a, acl_spec="user:" + acluser) current_acl = azure.get_acl_status(a) aclspec = [s for s in current_acl['entries'] if acluser in s] assert aclspec == []
def test_modify_acl_entries(azure): with azure_teardown(azure): acluser = AZURE_ACL_TEST_APPID azure.touch(a) permission = "---" azure.modify_acl_entries(a, acl_spec="user:"******":"+permission) current_acl = azure.get_acl_status(a) aclspec = [s for s in current_acl['entries'] if acluser in s][0] assert aclspec.split(':')[-1] == permission permission = "rwx" azure.modify_acl_entries(a, acl_spec="user:"******":" + permission) current_acl = azure.get_acl_status(a) aclspec = [s for s in current_acl['entries'] if acluser in s][0] assert aclspec.split(':')[-1] == permission
def check_acl_perms(path, permission): current_acl = azure.get_acl_status(path) acl_user_entry = [ s for s in current_acl['entries'] if acluser in s ] assert len(acl_user_entry) == 1 assert acl_user_entry[0].split(':')[-1] == permission
def test_set_acl(azure): with azure_teardown(azure): acluser = AZURE_ACL_TEST_APPID azure.touch(a) set_acl_base ="user::rwx,group::rwx,other::---," permission = "rwx" azure.set_acl(a, acl_spec=set_acl_base + "user:"******":"+permission) current_acl = azure.get_acl_status(a) aclspec = [s for s in current_acl['entries'] if acluser in s][0] assert len(current_acl['entries']) == 5 assert aclspec.split(':')[-1] == permission
def test_acl_management(azure): user_id = '470c0ccf-c91a-4597-98cd-48507d2f1486' acl_to_add = 'user:{}:rwx'.format(user_id) acl_to_modify = 'user:{}:-w-'.format(user_id) acl_to_remove = 'user:{}'.format(user_id) with azure_teardown(azure): azure.touch(a) # get initial ACLs initial_acls = azure.get_acl_status(a) acl_len = len(initial_acls['entries']) # set the full acl new_acl = ','.join(initial_acls['entries']) new_acl += ',{}'.format(acl_to_add) azure.set_acl(a, new_acl) # get the ACL and ensure it has an additional entry new_acls = azure.get_acl_status(a) assert acl_len + 2 == len(new_acls['entries']) # assert that the entry is there assert acl_to_add in new_acls['entries'] # set the specific ACL entry azure.modify_acl_entries(a, acl_to_modify) # get and validate that it was changed new_acls = azure.get_acl_status(a) assert acl_len + 2 == len(new_acls['entries']) # assert that the entry is there assert acl_to_modify in new_acls['entries'] # remove the ACL entry azure.remove_acl_entries(a, acl_to_remove) # get and validate that it was changed new_acls = azure.get_acl_status(a) assert acl_len + 1 == len(new_acls['entries']) # assert that the entry is there assert acl_to_modify not in new_acls['entries'] # remove the full acl and validate the lengths azure.remove_default_acl(a) # get and validate that it was changed new_acls = azure.get_acl_status(a) assert 4 == len(new_acls['entries']) # remove the full acl and validate the lengths azure.remove_acl(a) # get and validate that it was changed new_acls = azure.get_acl_status(a) assert 3 == len(new_acls['entries'])