def test_list_permissions_for_storage(self, forseti_cli: ForsetiCli, forseti_model_readonly): """Test list_permissions for the storage.admin role includes the expected permissions. Args: forseti_cli (ForsetiCli): Instance of the forseti cli helper forseti_model_readonly (Tuple): Model name & process result """ # Arrange model_name, _, _ = forseti_model_readonly forseti_cli.model_use(model_name=model_name) # Act result = forseti_cli.explainer_list_permissions( roles=['roles/storage.admin']) # Assert assert result.returncode == 0, f'Forseti stdout: {str(result.stdout)}' assert re.search(r'storage.buckets.create', str(result.stdout)) assert re.search(r'storage.buckets.delete', str(result.stdout)) assert re.search(r'storage.buckets.get', str(result.stdout)) assert re.search(r'storage.buckets.getIamPolicy', str(result.stdout)) assert re.search(r'storage.buckets.list', str(result.stdout)) assert re.search(r'storage.buckets.setIamPolicy', str(result.stdout)) assert re.search(r'storage.buckets.update', str(result.stdout)) assert re.search(r'storage.objects.create', str(result.stdout)) assert re.search(r'storage.objects.delete', str(result.stdout)) assert re.search(r'storage.objects.get', str(result.stdout)) assert re.search(r'storage.objects.getIamPolicy', str(result.stdout)) assert re.search(r'storage.objects.list', str(result.stdout)) assert re.search(r'storage.objects.setIamPolicy', str(result.stdout)) assert re.search(r'storage.objects.update', str(result.stdout))
def test_list_permissions_with_role_prefix(self, forseti_cli: ForsetiCli, forseti_model_readonly): """Test list_permissions with storage role prefix includes the expected roles. Args: forseti_cli (ForsetiCli): Instance of the forseti cli helper forseti_model_readonly (Tuple): Model name & process result """ # Arrange model_name, _, _ = forseti_model_readonly forseti_cli.model_use(model_name=model_name) # Act result = forseti_cli.explainer_list_permissions( role_prefixes=['roles/storage']) # Assert assert result.returncode == 0, f'Forseti stdout: {str(result.stdout)}' assert re.search(r'roles\/storage.admin', str(result.stdout)) assert re.search(r'roles\/storage.hmacKeyAdmin', str(result.stdout)) assert re.search(r'roles\/storage.legacyBucketOwner', str(result.stdout)) assert re.search(r'roles\/storage.legacyBucketReader', str(result.stdout)) assert re.search(r'roles\/storage.legacyBucketWriter', str(result.stdout)) assert re.search(r'roles\/storage.legacyObjectOwner', str(result.stdout)) assert re.search(r'roles\/storage.legacyObjectReader', str(result.stdout)) assert re.search(r'roles\/storage.objectAdmin', str(result.stdout)) assert re.search(r'roles\/storage.objectCreator', str(result.stdout)) assert re.search(r'roles\/storage.objectViewer', str(result.stdout)) assert re.search(r'roles\/storagetransfer.admin', str(result.stdout)) assert re.search(r'roles\/storagetransfer.user', str(result.stdout)) assert re.search(r'roles\/storagetransfer.viewer', str(result.stdout))