anchor.diff:      get_shared_file_attrs_test/1,
       get_attrs_on_provider_not_supporting_space_test/1,
   
  -    set_mode_test/1
  +    set_file_mode_test/1,
  +    set_shared_file_mode_test/1,
  +    set_mode_on_provider_not_supporting_space_test/1
   ]).
   
   all() ->
  
positive.code: %%%===================================================================
  
  
  set_mode_test(Config) ->
      [Provider2, Provider1] = Providers = ?config(op_worker_nodes, Config),
  
      GetSessionFun = fun(Node) ->
          ?config({session_id, {?USER_IN_BOTH_SPACES, ?GET_DOMAIN(Node)}}, Config)
      end,
  
      UserSessId = GetSessionFun(Provider2),
  
      RootDirPath = filename:join(["/", ?SPACE_2, ?SCENARIO_NAME]),
      {ok, RootDirGuid} = lfm_proxy:mkdir(Provider2, UserSessId, RootDirPath, 8#777),
      {ok, ShareId} = lfm_proxy:create_share(Provider2, UserSessId, {guid, RootDirGuid}, <<"share">>),
  
      DirPath = filename:join([RootDirPath, <<"dir">>]),
      {ok, DirGuid} = lfm_proxy:mkdir(Provider2, UserSessId, DirPath, 8#777),
  
      RegularFilePath = filename:join([RootDirPath, <<"file">>]),
      {ok, RegularFileGuid} = lfm_proxy:create(Provider2, UserSessId, RegularFilePath, 8#777),
  
      % Wait for metadata sync between providers
      ?assertMatch(
          {ok, _},
          lfm_proxy:stat(Provider1, GetSessionFun(Provider1), {guid, RegularFileGuid}),
          ?ATTEMPTS
      ),
  
      SupportedClientsPerNode = #{
          Provider1 => [?USER_IN_SPACE_1_AUTH, ?USER_IN_SPACE_2_AUTH, ?USER_IN_BOTH_SPACES_AUTH],
          Provider2 => [?USER_IN_SPACE_2_AUTH, ?USER_IN_BOTH_SPACES_AUTH]
      },
  
      ClientSpecForSpace2Scenarios = #client_spec{
          correct = [?USER_IN_SPACE_2_AUTH, ?USER_IN_BOTH_SPACES_AUTH],
          unauthorized = [?NOBODY],
          forbidden = [?USER_IN_SPACE_1_AUTH],
          supported_clients_per_node = SupportedClientsPerNode
      },
  
      % Special case -> any user can make requests for shares but if request is
      % being made using credentials by user not supported on specific provider
      % ?ERROR_USER_NOT_SUPPORTED will be returned
      ClientSpecForShareScenarios = #client_spec{
          correct = [?NOBODY, ?USER_IN_SPACE_1_AUTH, ?USER_IN_SPACE_2_AUTH, ?USER_IN_BOTH_SPACES_AUTH],
          unauthorized = [],
          forbidden = [],
          supported_clients_per_node = SupportedClientsPerNode
      },
  
      DataSpec = #data_spec{
          required = [<<"mode">>],
          correct_values = #{<<"mode">> => [<<"0000">>, <<"0111">>, <<"0777">>]},
          bad_values = [
              {<<"mode">>, true, ?ERROR_BAD_VALUE_INTEGER(<<"mode">>)},
              {<<"mode">>, <<"integer">>, ?ERROR_BAD_VALUE_INTEGER(<<"mode">>)}
          ]
      },
  
      ConstructPrepareRestArgsFun = fun(FileId) ->
          fun(#api_test_ctx{data = Data}) ->
              #rest_args{
                  method = put,
                  path = <<"data/", FileId/binary>>,
                  headers = #{<<"content-type">> => <<"application/json">>},
                  body = json_utils:encode(Data)
              }
          end
      end,
      ConstructPrepareDeprecatedFilePathRestArgsFun = fun(FilePath) ->
          fun(#api_test_ctx{data = Data}) ->
              #rest_args{
                  method = put,
                  path = <<"metadata/attrs", FilePath/binary>>,
                  headers = #{<<"content-type">> => <<"application/json">>},
                  body = json_utils:encode(Data)
              }
          end
      end,
      ConstructPrepareDeprecatedFileIdRestArgsFun = fun(Fileid) ->
          fun(#api_test_ctx{data = Data}) ->
              #rest_args{
                  method = put,
                  path = <<"metadata-id/attrs/", Fileid/binary>>,
                  headers = #{<<"content-type">> => <<"application/json">>},
                  body = json_utils:encode(Data)
              }
          end
      end,
      ConstructPrepareGsArgsFun = fun(FileId, Scope) ->
          fun(#api_test_ctx{data = Data}) ->
              #gs_args{
                  operation = create,
                  gri = #gri{type = op_file, id = FileId, aspect = attrs, scope = Scope},
                  data = Data
              }
          end
      end,
  
      SetMode = fun(Node, FileGuid, NewMode) ->
          ?assertMatch(ok, lfm_proxy:set_perms(Node, GetSessionFun(Node), {guid, FileGuid}, NewMode))
      end,
      GetMode = fun(Node, FileGuid) ->
          {ok, #file_attr{mode = Mode}} = ?assertMatch(
              {ok, _},
              lfm_proxy:stat(Node, GetSessionFun(Node), {guid, FileGuid})
          ),
          Mode
      end,
  
      GetExpectedResultFun = fun
          (#api_test_ctx{client = ?USER_IN_BOTH_SPACES_AUTH}) -> ok;
  
negative.code:         get_shared_file_attrs_test,
          get_attrs_on_provider_not_supporting_space_test,
  
          set_file_mode_test,
          set_shared_file_mode_test,
          set_mode_on_provider_not_supporting_space_test
      ]).
  
  
  