anchor.diff:  
           #scenario_spec{
               type = rest,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ShareClientSpec,
  -            prepare_args_fun = ConstructPrepareRestArgsFun(ShareRootDirObjectId),
  -            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, Data) ->
  -                ValidateListedChildren(rest, files, ShareId, Data, Response)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -        #scenario_spec{
  -            type = gs,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ShareClientSpec,
  -            prepare_args_fun = ConstructPrepareGsArgsFun(ShareRootDirGuid, public),
  -            validate_result_fun = fun(_TargetNode, {ok, Result}, _Env, Data) ->
  -                ValidateListedChildren(gs, files, ShareId, Data, Result)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -        % 'private' scope is forbidden for shares even if user would be able to
  -        % list children using normal guid
  -        #scenario_spec{
  -            type = gs,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ShareClientSpec,
  -            prepare_args_fun = ConstructPrepareGsArgsFun(ShareRootDirGuid, private),
  -            validate_result_fun = fun(_TargetNode, Result, _Env, _Data) ->
  -                ?assertEqual(?ERROR_UNAUTHORIZED, Result)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -
  -        %% LISTING FILE SHOULD FAIL WITH ?ENOTDIR ERROR
  -
  -        #scenario_spec{
  -            type = rest,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareRestArgsFun(FileObjectId1),
  -            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_400_BAD_REQUEST, Response}, _Env, _Data) ->
  -                ExpError = #{<<"error">> => errors:to_json(?ERROR_POSIX(?ENOTDIR))},
  -                ?assertEqual(ExpError, Response)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -        #scenario_spec{
  -            type = gs,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareGsArgsFun(FileGuid1, private),
  -            validate_result_fun = fun(_TargetNode, Result, _, _) ->
  -                ?assertEqual(?ERROR_POSIX(?ENOTDIR), Result)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -
  -        %% LISTING USER ROOT DIR SHOULD LIST ALL SPACES ALSO THOSE NOT SUPPORTED LOCALLY
  -
  -        #scenario_spec{
  -            type = rest,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareRestArgsFun(UserRootDirObjectId),
  -            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, Data) ->
  -                ValidateListedChildren(rest, spaces, undefined, Data, Response)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -        #scenario_spec{
  -            type = gs,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareGsArgsFun(UserRootDirGuid, private),
  -            validate_result_fun = fun(_TargetNode, {ok, Result}, _, Data) ->
  -                ValidateListedChildren(gs, spaces, undefined, Data, Result)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -
  -        %% TEST LISTING ON PROVIDERS NOT SUPPORTING SPACE
  -
  -        #scenario_spec{
  -            type = rest,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ClientSpec#client_spec{forbidden = [{user, <<"user3">>}]},
  -            prepare_args_fun = ConstructPrepareRestArgsFun(Space1ObjectId),
  -            validate_result_fun = fun
  -                (Target, {ok, ?HTTP_400_BAD_REQUEST, Response}, _Env, _Data) when Target == Provider2 ->
  -                    ExpError = #{<<"error">> => errors:to_json(?ERROR_SPACE_NOT_SUPPORTED_BY(Provider2DomainBin))},
  -                    ?assertEqual(ExpError, Response);
  -                (_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, _Data) ->
  -                    ?assertEqual(#{<<"children">> => []}, Response)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -        #scenario_spec{
  -            type = gs,
  -            target_nodes = [Provider1, Provider2],
  -            client_spec = ClientSpec#client_spec{forbidden = [{user, <<"user3">>}]},
  -            prepare_args_fun = ConstructPrepareGsArgsFun(Space1Guid, private),
  -            validate_result_fun = fun
  -                (Target, Result, _, _Data) when Target == Provider2 ->
  -                    ?assertEqual(?ERROR_SPACE_NOT_SUPPORTED_BY(Provider2DomainBin), Result);
  -                (_TargetNode, {ok, Result}, _, _Data) ->
  -                    ?assertEqual(#{<<"children">> => []}, Result)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -
  -        %% TEST DEPRECATED LISTING NORMAL DIR ENDPOINTS
  -
  -        #scenario_spec{
  -            type = rest_with_file_path,
  -            target_nodes = [Provider2, Provider1],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareDeprecatedPathRestArgsFun(RootDirPath),
  -            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, Data) ->
  -                ValidateListedChildren(deprecated_rest, files, undefined, Data, Response)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -        #scenario_spec{
  -            type = rest,
  -            target_nodes = [Provider2, Provider1],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareDeprecatedIdRestArgsFun(RootDirObjectId),
  -            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, Data) ->
  -                ValidateListedChildren(deprecated_rest, files, undefined, Data, Response)
  -            end,
  -            data_spec = ParamsSpec
  -        },
  -
  -        %% TEST DEPRECATED LISTING SHARE ENDPOINTS
  -
  +            target_nodes = Providers,
  +            client_spec = ClientSpecForShareListing,
  +            prepare_args_fun = ConstructPrepareRestArgsFun(ShareDirObjectId),
  +            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, Data) ->
  +                validate_listed_files(Response, rest, ShareId, Data, Files)
  +            end,
  +            data_spec = ParamsSpec
  +        },
           #scenario_spec{
               type = rest_not_supported,
  -            target_nodes = [Provider2, Provider1],
  -            client_spec = ClientSpec,
  -            prepare_args_fun = ConstructPrepareDeprecatedIdRestArgsFun(ShareRootDirObjectId),
  +            target_nodes = Providers,
  +            client_spec = ClientSpecForShareListing,
  +            prepare_args_fun = ConstructPrepareDeprecatedIdRestArgsFun(ShareDirObjectId),
               validate_result_fun = fun(_TargetNode, {ok, ?HTTP_400_BAD_REQUEST, Response}, _Env, _Data) ->
                   ExpError = #{<<"error">> => errors:to_json(?ERROR_NOT_SUPPORTED)},
                   ?assertEqual(ExpError, Response)
               end,
               data_spec = ParamsSpec
           },
  -
  -        %% TEST DEPRECATED LISTING FILE ENDPOINTS
  -
  +        #scenario_spec{
  +            type = gs,
  +            target_nodes = Providers,
  +            client_spec = ClientSpecForShareListing,
  +            prepare_args_fun = ConstructPrepareGsArgsFun(ShareDirGuid, public),
  +            validate_result_fun = fun(_TargetNode, {ok, Result}, _Env, Data) ->
  +                validate_listed_files(Result, gs, ShareId, Data, Files)
  +            end,
  +            data_spec = ParamsSpec
  +        },
  +        % 'private' scope is forbidden for shares even if user would be able to
  +        % list children using normal guid
  +        #scenario_spec{
  +            type = gs,
  +            target_nodes = Providers,
  +            client_spec = ClientSpecForShareListing,
  +            prepare_args_fun = ConstructPrepareGsArgsFun(ShareDirGuid, private),
  +            validate_result_fun = fun(_TargetNode, Result, _Env, _Data) ->
  +                ?assertEqual(?ERROR_UNAUTHORIZED, Result)
  +            end,
  +            data_spec = ParamsSpec
  +        },
  +
  +        %% TEST LISTING FILE
  +
  +        % TODO fix
  +%%        #scenario_spec{
  +%%            type = rest,
  +%%            target_nodes = Providers,
  +%%            client_spec = ClientSpecForSpace2Listing,
  +%%            prepare_args_fun = ConstructPrepareRestArgsFun(FileObjectId1),
  +%%            validate_result_fun = fun(_TargetNode, {ok, ?HTTP_400_BAD_REQUEST, Response}, _Env, _Data) ->
  +%%                ExpError = #{<<"error">> => errors:to_json(?ERROR_POSIX(?ENOTDIR))},
  +%%                ?assertEqual(ExpError, Response)
  +%%            end,
  +%%            data_spec = ParamsSpec
  +%%        },
           #scenario_spec{
               type = rest_with_file_path,
  -            target_nodes = [Provider2, Provider1],
  -            client_spec = ClientSpec,
  +            target_nodes = Providers,
  +            client_spec = ClientSpecForSpace2Listing,
               prepare_args_fun = ConstructPrepareDeprecatedPathRestArgsFun(FilePath1),
               validate_result_fun = fun(_TargetNode, {ok, ?HTTP_200_OK, Response}, _Env, _Data) ->
                   ?assertEqual([#{
  
positive.code:             }
          end
      end,
      ValidateListedChildren = fun(ScenarioType, ObjectListed, ShareId, Data, Result) ->
          Limit = maps:get(<<"limit">>, Data, 100),
          Offset = maps:get(<<"offset">>, Data, 0),
          ExpFiles0 = case ObjectListed of
              files -> Files;
              spaces -> Spaces
          end,
          ExpFiles1 = case Offset >= length(ExpFiles0) of
              true -> [];
              false -> lists:sublist(ExpFiles0, Offset+1, Limit)
          end,
          ExpFiles2 = lists:map(fun({Guid, Name, Path}) ->
              {file_id:guid_to_share_guid(Guid, ShareId), Name, Path}
          end, ExpFiles1),
          ExpFiles3 = case ScenarioType of
              deprecated_rest ->
                  lists:map(fun({Guid, _Name, Path}) ->
                      {ok, ObjectId} = file_id:guid_to_objectid(Guid),
                      #{
                          <<"id">> => ObjectId,
                          <<"path">> => Path
                      }
                  end, ExpFiles2);
              rest ->
                  #{<<"children">> => lists:map(fun({Guid, Name, _Path}) ->
                      {ok, ObjectId} = file_id:guid_to_objectid(Guid),
                      #{
                          <<"id">> => ObjectId,
                          <<"name">> => Name
                      }
                  end, ExpFiles2)};
              gs ->
                  #{<<"children">> => lists:map(fun({Guid, _Name, _Path}) ->
                      Guid
                  end, ExpFiles2)}
          end,
          ?assertEqual(ExpFiles3, Result)
      end,
      ParamsSpec = #data_spec{
          optional = [<<"limit">>, <<"offset">>],
          correct_values = #{
              <<"limit">> => [1, 100],
              <<"offset">> => [1, 10]
          },
          bad_values = [
              {<<"limit">>, true, ?ERROR_BAD_VALUE_INTEGER(<<"limit">>)},
              {<<"limit">>, -100, ?ERROR_BAD_VALUE_TOO_LOW(<<"limit">>, 1)},
              {<<"limit">>, 0, ?ERROR_BAD_VALUE_TOO_LOW(<<"limit">>, 1)},
              {<<"offset">>, <<"abc">>, ?ERROR_BAD_VALUE_INTEGER(<<"offset">>)}
          ]
      },
  
      ?assert(api_test_utils:run_scenarios(Config, [
  
  
negative.code:     end.
  
  
  %% @private
  -spec construct_qs_param(ParamName :: binary(), Data :: map()) -> binary().
  construct_qs_param(ParamName, Data) ->
      case maps:get(ParamName, Data, undefined) of
          undefined ->
              <<>>;
          Value ->
              <<ParamName/binary, "=", (str_utils:to_binary(Value))/binary>>
      end.
  
  
  %% @private
  -spec validate_listed_files(
      ListedChildren :: term(),
      Format :: gs | rest | deprecated_rest,
      ShareId :: undefined | od_share:id(),
      Params :: map(),
      AllFiles :: [{file_id:file_guid(), Name :: binary(), Path :: binary()}]
  ) ->
      ok | no_return().
  validate_listed_files(ListedChildren, Format, ShareId, Params, AllFiles) ->
      Limit = maps:get(<<"limit">>, Params, 1000),
      Offset = maps:get(<<"offset">>, Params, 0),
  
      ExpFiles1 = case Offset >= length(AllFiles) of
          true ->
              [];
          false ->
              lists:sublist(AllFiles, Offset+1, Limit)
      end,
  
      ExpFiles2 = lists:map(fun({Guid, Name, Path}) ->
          {file_id:guid_to_share_guid(Guid, ShareId), Name, Path}
      end, ExpFiles1),
  
      ExpFiles3 = case Format of
          gs ->
              #{<<"children">> => lists:map(fun({Guid, _Name, _Path}) ->
                  Guid
              end, ExpFiles2)};
          rest ->
              #{<<"children">> => lists:map(fun({Guid, Name, _Path}) ->
                  {ok, ObjectId} = file_id:guid_to_objectid(Guid),
                  #{
                      <<"id">> => ObjectId,
                      <<"name">> => Name
                  }
              end, ExpFiles2)};
          deprecated_rest ->
              lists:map(fun({Guid, _Name, Path}) ->
                  {ok, ObjectId} = file_id:guid_to_objectid(Guid),
                  #{
                      <<"id">> => ObjectId,
                      <<"path">> => Path
                  }
              end, ExpFiles2)
      end,
  
      ?assertEqual(ExpFiles3, ListedChildren).
  