anchor.diff:      do_request(Endpoint, Headers, Method, Body, []).
   do_request(Endpoint, Headers, Method, Body, Options) ->
       ibrowse:send_req(Endpoint, Headers, Method, Body, Options).
  -
   
   get_macaroon_id(Token) ->
       {ok, Macaroon} = macaroon:deserialize(Token),
  
positive.code: 
  %% provider_rest_module_test_group====================================
  
  provider_crud_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
      
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      ?assertMatch(
          [?CLIENT_NAME1, ?URLS1, ?REDIRECTION_POINT1, ProviderId],
          read_provider(ProviderReqParams)
      ),
  
      update_provider(?URLS2, ?REDIRECTION_POINT2, ?CLIENT_NAME2, ProviderReqParams),
  
      ?assertMatch(
          [?CLIENT_NAME2, ?URLS2, ?REDIRECTION_POINT2, ProviderId],
          read_provider(ProviderReqParams)
      ),
  
      ?assertMatch(
          [?CLIENT_NAME2, ?URLS2, ?REDIRECTION_POINT2, ProviderId],
          get_provider_data_by_pid(ProviderId, ProviderReqParams)
      ),
  
      delete_provider(ProviderReqParams),
  
      ?assertMatch(request_error,read_provider(ProviderReqParams)).
  
  provider_space_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      %% create user
      UserId = create_user(?USER_NAME1, Node),
  
      %% authenticate user
      NewHeaders = auth_user(UserId, ProviderId, ReqParams, Node),
      UserReqParams = update_req_params(ProviderReqParams, NewHeaders, headers),
  
      %% get space creation token1
      SCRToken1 = get_space_creation_token_for_user(UserReqParams),
  
      SID1 = create_space_for_provider(SCRToken1, ?SPACE_NAME1, ?SPACE_SIZE1, ProviderReqParams),
  
      %% get space creation token2
      SCRToken2 = get_space_creation_token_for_user(UserReqParams),
  
      SID2 = create_space_for_provider(SCRToken2, ?SPACE_NAME2, ?SPACE_SIZE2, ProviderReqParams),
  
      SupportedSpaces = get_provider_spaces(ProviderReqParams),
  
      ?assertMatch(true, is_included([SID1, SID2], SupportedSpaces)),
  
      DeleteResponse = delete_provider_space(SID1, ProviderReqParams),
  
      ?assertMatch(ok, check_status(DeleteResponse)),
  
      SupportedSpaces2 = get_provider_spaces(ProviderReqParams),
  
      ?assertMatch([[SID2]], SupportedSpaces2),
  
      [SID_test, SpaceName_test, {[{ProviderId_test, SpaceSize}]}] =
          get_provider_space(SID2, ProviderReqParams),
  
      ?assertMatch(
          [SID_test, SpaceName_test, ProviderId_test, SpaceSize],
          [SID2, ?SPACE_NAME2, ProviderId, binary_to_integer(?SPACE_SIZE2)]
      ).
  
  provider_check_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, [], []},
      ?assertMatch(ok, check_status(check_provider_ip(ReqParams))),
      ?assertMatch(ok, check_status(check_provider_ports(ReqParams))).
  
  %%%===================================================================
  
  %% user_rest_module_test_group========================================
  
  user_crud_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
      
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
       %% create user
      UserId = create_user(?USER_NAME1, Node),
  
      %% authenticate user
      NewHeaders = auth_user(UserId, ProviderId, ReqParams, Node),
      UserReqParams = update_req_params(ProviderReqParams, NewHeaders, headers),
  
      %% check if user data is correct
      ?assertMatch([UserId, ?USER_NAME1], read_user(UserReqParams)),
  
      update_user(?USER_NAME2, UserReqParams),
  
      %% check if user data was updated
      ?assertMatch([UserId, ?USER_NAME2], read_user(UserReqParams)),
  
       UserId2 = create_user(?USER_NAME2, Node),
  
      %% authenticate user
      NewHeaders2 = auth_user(UserId2, ProviderId, ReqParams, Node),
      UserReqParams2 = update_req_params(ProviderReqParams, NewHeaders2, headers),
  
      MergeToken = get_user_merge_token(UserReqParams2),
  
      %%  merge user2 with user1
      Response = merge_users(MergeToken, UserReqParams),
  
      ?assertMatch(ok, check_status(Response)),
  
      DeleteResponse = delete_user(UserReqParams),
      ?assertMatch(ok, check_status(DeleteResponse)),
  
      %% try to read deleted user
      ?assertMatch(request_error, read_user(UserReqParams)).
  
  user_space_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
      
      %% create user
      UserId = create_user(?USER_NAME1, Node),
  
      %% authenticate user
      NewHeaders = auth_user(UserId, ProviderId, ReqParams, Node),
      UserReqParams = update_req_params(ProviderReqParams, NewHeaders, headers),
  
      SID1 = create_space_for_user(?SPACE_NAME1, UserReqParams),
      SID2 = create_space_for_user(?SPACE_NAME2, UserReqParams),
  
      ?assertMatch([[SID1, SID2], <<"undefined">>], get_user_spaces(UserReqParams)),
  
      set_default_space_for_user(SID2, UserReqParams),
  
      ?assertMatch([[SID1, SID2], SID2], get_user_spaces(UserReqParams)),
  
      ?assertMatch(SID2, get_user_default_space(UserReqParams)),
  
      ?assertMatch([SID1, ?SPACE_NAME1], get_user_space(SID1, UserReqParams)),
  
      DeleteResponse = delete_user_space(SID1, UserReqParams),
      ?assertMatch(ok, check_status(DeleteResponse)),
  
      %% try to read deleted user's space
      ?assertMatch(request_error, get_user_space(SID1, UserReqParams)).
  
  many_users_space_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      %% create users
      UserId = create_user(?USER_NAME1, Node),
      UserId2 = create_user(?USER_NAME2, Node),
  
      %% authenticate users
      NewHeaders1 = auth_user(UserId, ProviderId, ReqParams, Node),
      NewHeaders2 = auth_user(UserId2, ProviderId, ReqParams, Node),
      UserReqParams1 = update_req_params(ProviderReqParams, NewHeaders1, headers),
      UserReqParams2 = update_req_params(ProviderReqParams, NewHeaders2, headers),
  
      SID1 = create_space_for_user(?SPACE_NAME1, UserReqParams1),
  
      SupportToken = get_space_support_token(SID1, UserReqParams1),
  
      SupportResponse = provider_support_space(SupportToken, ?SPACE_SIZE1, ProviderReqParams),
  
      ?assertMatch(ok, check_status(SupportResponse)),
  
      InvitationToken = get_space_invitation_token(users, SID1, UserReqParams1),
  
      SID2 = join_user_to_space(InvitationToken, UserReqParams2),
  
      %% check if SID returned for user2 is the same as SID1
      ?assertMatch(SID1, SID2),
  
      %% check if space is in list of user2 space
      ?assertMatch([[SID1], <<"undefined">>], get_user_spaces(UserReqParams2)).
  
  user_group_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
      {ProviderId, ProviderReqParams} =
      register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      %% create users
      UserId = create_user(?USER_NAME1, Node),
  
      %% authenticate user
      NewHeaders = auth_user(UserId, ProviderId, ReqParams, Node),
      UserReqParams = update_req_params(ProviderReqParams, NewHeaders, headers),
  
      GID1 = create_group_for_user(?GROUP_NAME1, UserReqParams),
      GID2 = create_group_for_user(?GROUP_NAME2, UserReqParams),
  
      ?assertMatch(true, is_included([GID1, GID2], get_user_groups(UserReqParams))),
  
      Response = user_leave_group(GID2,UserReqParams),
  
      ?assertMatch(ok, check_status(Response)),
      ?assertMatch(false, is_included([GID2], get_user_groups(UserReqParams))),
      ?assertMatch([GID1, ?GROUP_NAME1], get_user_group(GID1, UserReqParams)).
  
  many_users_group_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      %% create users
      UserId1 = create_user(?USER_NAME1, Node),
      UserId2 = create_user(?USER_NAME2, Node),
  
      %% authenticate users
      NewHeaders1 = auth_user(UserId1, ProviderId, ReqParams, Node),
      NewHeaders2 = auth_user(UserId2, ProviderId, ReqParams, Node),
      UserReqParams1 = update_req_params(ProviderReqParams, NewHeaders1, headers),
      UserReqParams2 = update_req_params(ProviderReqParams, NewHeaders2, headers),
  
      GID1 = create_group_for_user(?GROUP_NAME1, UserReqParams1),
  
      InvitationToken = get_group_invitation_token(GID1, UserReqParams1),
  
      GID2 = join_user_to_group(InvitationToken, UserReqParams2),
  
      %% check if GID returned for user2 is the same as GID1
      ?assertMatch(GID1, GID2),
  
      ?assertMatch([GID1, ?GROUP_NAME1], get_user_group(GID2, UserReqParams2)),
      ?assertMatch(true, is_included([UserId1, UserId2], get_group_users(GID1, UserReqParams1))).
  
  %% group_rest_module_test_group =======================================
  
  group_crud_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
       %% create users
      UserId = create_user(?USER_NAME1, Node),
  
      %% authenticate user
      NewHeaders = auth_user(UserId, ProviderId, ReqParams, Node),
      UserReqParams = update_req_params(ProviderReqParams, NewHeaders, headers),
      
      %% create group
      GID = create_group(?GROUP_NAME1, UserReqParams),
  
      ?assertMatch([GID, ?GROUP_NAME1], read_group(GID, UserReqParams)),
  
      UpdateResponse = update_group(GID, ?GROUP_NAME2, UserReqParams),
      ?assertMatch(ok, check_status(UpdateResponse)),
      ?assertMatch([GID, ?GROUP_NAME2], read_group(GID, UserReqParams)),
  
      DeleteResponse = delete_group(GID, UserReqParams),
  
      ?assertMatch(ok, check_status(DeleteResponse)),
      ?assertMatch(request_error, read_group(GID, UserReqParams)).
  
  group_users_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
       %% create users
      UserId1 = create_user(?USER_NAME1, Node),
      UserId2 = create_user(?USER_NAME2, Node),
  
      %% authenticate users
      NewHeaders = auth_user(UserId1, ProviderId, ReqParams, Node),
      UserReqParams1 = update_req_params(ProviderReqParams, NewHeaders, headers),
      NewHeaders2 = auth_user(UserId2, ProviderId, ReqParams, Node),
      UserReqParams2 = update_req_params(ProviderReqParams, NewHeaders2, headers),
  
      GID1 = create_group(?GROUP_NAME1, UserReqParams1),
      
      ?assertMatch([UserId1, ?USER_NAME1], get_group_user(GID1, UserId1, UserReqParams1)),
      ?assertMatch([UserId1], get_group_users(GID1, UserReqParams1)),
  
      Token = get_group_invitation_token(GID1, UserReqParams1),
      join_user_to_group(Token, UserReqParams2),
  
      ?assertMatch(true, is_included([UserId1, UserId2], get_group_users(GID1, UserReqParams1))),
  
      DeleteResponse = delete_group_user(GID1, UserId1, UserReqParams1),
  
      ?assertMatch(ok, check_status(DeleteResponse)).
  
  group_privileges_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      [Node] = ?config(gr_nodes, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
       %% create users
      UserId1 = create_user(?USER_NAME1, Node),
      UserId2 = create_user(?USER_NAME2, Node),
      UserId3 = create_user(?USER_NAME3, Node),
  
      %% authenticate users
      NewHeaders = auth_user(UserId1, ProviderId, ReqParams, Node),
      UserReqParams1 = update_req_params(ProviderReqParams, NewHeaders, headers),
      NewHeaders2 = auth_user(UserId2, ProviderId, ReqParams, Node),
      UserReqParams2 = update_req_params(ProviderReqParams, NewHeaders2, headers),
      NewHeaders3 = auth_user(UserId3, ProviderId, ReqParams, Node),
      UserReqParams3 = update_req_params(ProviderReqParams, NewHeaders3, headers),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
  
  
negative.code: 
      %% check other user privileges
      ?assertMatch(true,
          is_included([group_view_data], get_group_user_privileges(GID, UserId2, UserReqParams1))).
  
  group_set_privileges_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      {UserId2, UserReqParams2} =
          register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
      {UserId3, UserReqParams3} =
          register_user(?USER_NAME3, ProviderId, Config, ProviderReqParams),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
  
      InvitationToken = get_group_invitation_token(GID, UserReqParams1),
  
      %% add user to group
      join_user_to_group(InvitationToken, UserReqParams2),
  
      SID = create_space_for_user(?SPACE_NAME1, UserReqParams2),
  
      Users = [{UserId1, UserReqParams1}, {UserId2, UserReqParams2}, {UserId3, UserReqParams3}],
      ?assertMatch(ok, group_privileges_check(?GROUP_PRIVILEGES, Users, GID, SID)).
  
  group_create_space_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
      SID1 = create_space_for_group(?SPACE_NAME1, GID, UserReqParams1),
  
      ?assertMatch([SID1], get_group_spaces(GID,UserReqParams1)).
  
  group_get_space_data_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
      SID1 = create_space_for_group(?SPACE_NAME1, GID, UserReqParams1),
  
      ?assertMatch([SID1, ?SPACE_NAME1], get_group_space(GID, SID1, UserReqParams1)).
  
  group_delete_space_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
      SID1 = create_space_for_group(?SPACE_NAME1, GID, UserReqParams1),
  
      ?assertMatch(ok, check_status(group_leave_space(GID, SID1, UserReqParams1))),
      ?assertMatch(false, is_included([SID1], get_group_spaces(GID, UserReqParams1))).
  
  group_space_invitation_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
      SID1 = create_space_for_group(?SPACE_NAME1, GID, UserReqParams1),
      SID2 = create_space_for_user(?SPACE_NAME2, UserReqParams1),
  
      InvitationToken = get_space_invitation_token(groups, SID2, UserReqParams1),
  
      ?assertMatch(SID2, join_group_to_space(InvitationToken, GID, UserReqParams1)),
      ?assertMatch(true, is_included([SID1, SID2], get_group_spaces(GID, UserReqParams1))).
  
  %% spaces_rest_module_test_group =======================================
  
  space_create_by_user_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      SID = create_space(?SPACE_NAME1, UserReqParams),
  
      ?assertMatch([SID, ?SPACE_NAME1],read_space(SID, UserReqParams)).
  
  space_create_by_provider_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      Token = get_space_creation_token_for_user(UserReqParams),
      SID = create_space(Token, ?SPACE_NAME1, ?SPACE_SIZE1, ProviderReqParams),
  
      ?assertMatch([SID, ?SPACE_NAME1],read_space(SID, ProviderReqParams)).
  
  space_update_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      SID = create_space(?SPACE_NAME1, UserReqParams),
  
      ?assertMatch(ok, check_status(update_space(?SPACE_NAME2, SID, UserReqParams))),
      ?assertMatch([SID, ?SPACE_NAME2], read_space(SID, UserReqParams)).
  
  space_delete_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      SID = create_space(?SPACE_NAME1, UserReqParams),
      ?assertMatch(ok, check_status(delete_space(SID, UserReqParams))).
  
  space_get_users_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      {UserId2, UserReqParams2} =
          register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
  
      SID = create_space(?SPACE_NAME1, UserReqParams1),
  
      InvitationToken = get_space_invitation_token(users, SID, UserReqParams1),
  
      join_user_to_space(InvitationToken, UserReqParams2),
      ?assertMatch(true, is_included([UserId1, UserId2], get_space_users(SID, UserReqParams1))).
  
  space_get_user_data_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      {UserId2, UserReqParams2} =
          register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
  
      SID = create_space(?SPACE_NAME1, UserReqParams1),
      
      ?assertMatch([UserId2, ?USER_NAME2], get_space_user(SID, UserId2, UserReqParams2)).
  
  space_delete_user_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      {UserId2, UserReqParams2} =
          register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
  
      SID = create_space(?SPACE_NAME1, UserReqParams1),
      Token = get_space_invitation_token(users, SID, UserReqParams1),
      join_user_to_space(Token, UserReqParams2),
      
      ?assertMatch(ok, check_status(delete_space_user(SID, UserId2, UserReqParams1))),
      ?assertMatch(false, is_included([UserId2], get_space_users(SID, UserReqParams1))).
  
  space_get_groups_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID1 = create_group(?GROUP_NAME1, UserReqParams),
      GID2 = create_group(?GROUP_NAME2, UserReqParams),
      SID = create_space_for_group(?SPACE_NAME1, GID1, UserReqParams),
  
      ?assertMatch(true, is_included([GID1, GID2], get_space_groups(SID, UserReqParams))).
  
  space_get_group_data_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID1 = create_group(?GROUP_NAME1, UserReqParams),
      SID = create_space_for_group(?SPACE_NAME1, GID1, UserReqParams),
  
      ?assertMatch([GID1, ?GROUP_NAME2], get_space_group(SID, GID1, UserReqParams)).
  
  space_delete_group_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
  
      GID1 = create_group(?GROUP_NAME1, UserReqParams),
      SID = create_space_for_group(?SPACE_NAME1, GID1, UserReqParams),
  
      ?assertMatch(ok, check_status(delete_space_group(SID, GID1, UserReqParams))),
      ?assertMatch(false, is_included([GID1], get_space_groups(SID, UserReqParams))).
  
  space_get_providers_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      
      Token = get_space_creation_token_for_user(UserReqParams),
      SID = create_space_for_provider(Token, ?SPACE_NAME1, ?SPACE_SIZE1, ProviderReqParams),
  
      ?assertMatch([ProviderId], get_space_providers(SID, UserReqParams)).
  
  space_get_provider_data_test(Config) ->
   RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      
      Token = get_space_creation_token_for_user(UserReqParams),
      SID = create_space_for_provider(Token, ?SPACE_NAME1, ?SPACE_SIZE1, ProviderReqParams),
  
      ?assertMatch(
          [?CLIENT_NAME1, ProviderId, ?URLS1, ?REDIRECTION_POINT1],
          get_space_provider(SID, ProviderId, UserReqParams)
      ).
  
  space_delete_provider_test(Config) ->
   RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {_UserId, UserReqParams} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      
      Token = get_space_creation_token_for_user(UserReqParams),
      SID = create_space_for_provider(Token, ?SPACE_NAME1, ?SPACE_SIZE1, ProviderReqParams),
  
      ?assertMatch(ok, check_status(delete_space_provider(SID, ProviderId, UserReqParams))),
  
      ?assertMatch([], get_space_providers(SID, UserReqParams)).
  
  space_get_privileges_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      {UserId2, UserReqParams2} =
          register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
  
      SID = create_space_for_user(?SPACE_NAME1, UserReqParams1),
      InvitationToken = get_space_invitation_token(users, SID, UserReqParams1),
      join_user_to_space(InvitationToken, UserReqParams2),
  
      ?assertMatch(true,
          is_included(?SPACE_PRIVILEGES, get_space_privileges(users, SID, UserId1, UserReqParams1))),
  
      ?assertMatch(true,
          is_included([space_view_data], get_space_privileges(users, SID, UserId2, UserReqParams1))).
  
  
  space_set_privileges_test(Config) ->
      RestAddress = ?config(restAddress, Config),
      ReqParams = {RestAddress, ?CONTENT_TYPE_HEADER, []},
  
      {ProviderId, ProviderReqParams} =
          register_provider(?URLS1, ?REDIRECTION_POINT1, ?CLIENT_NAME1, Config, ReqParams),
  
      {UserId1, UserReqParams1} =
          register_user(?USER_NAME1, ProviderId, Config, ProviderReqParams),
      {UserId2, UserReqParams2} =
          register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
      {UserId3, UserReqParams3} =
          register_user(?USER_NAME3, ProviderId, Config, ProviderReqParams),
  
      GID = create_group(?GROUP_NAME1, UserReqParams1),
      SID = create_space_for_user(?SPACE_NAME1, UserReqParams1),
      InvitationToken = get_space_invitation_token(users, SID, UserReqParams1),
      join_user_to_space(InvitationToken, UserReqParams2),
  