anchor.diff:      ]
   ).
   
  +-define(DOI_SERVICE,
  +    #{
  +        <<"type">> => <<"DOI">>,
  +        <<"name">> => <<"LifeWatch DataCite">>,
  +        <<"host">> => <<"https://mds.test.datacite.org">>,
  +        <<"doiEndpoint">> => <<"/doi">>,
  +        <<"metadataEndpoint">> => <<"/metadata">>,
  +        <<"mediaEndpoint">> => <<"/media">>,
  +        <<"prefix">> => <<"10.572">>,
  +        <<"username">> => <<"alice">>,
  +        <<"password">> => <<"*******">>,
  +        <<"identifierTemplate">> => <<"{{space.name}}-{{space.guid}}">>,
  +        <<"allowTemplateOverride">> => false
  +    }
  +).
  +
  +-define(PID_SERVICE,
  +    #{
  +        <<"type">> => <<"PID">>,
  +        <<"name">> => <<"iMarine EPIC">>,
  +        <<"endpoint">> => <<"https://epic.grnet.gr/api/v2/handles">>,
  +        <<"prefix">> => <<"11789">>,
  +        <<"suffixGeneration">> => <<"auto">>,
  +        <<"suffixPrefix">> => <<"{{space.name}}">>,
  +        <<"suffixSuffix">> => <<"{{user.name}}">>,
  +        <<"username">> => <<"alice">>,
  +        <<"password">> => <<"*******">>,
  +        <<"identifierTemplate">> => <<"{{space.name}}-{{space.guid}}">>,
  +        <<"allowTemplateOverride">> => false
  +    }
  +).
  +
   %% API
   -export([all/0, groups/0, init_per_suite/1, end_per_suite/1, init_per_testcase/2, end_per_testcase/2]).
   
  
positive.code:                 provider_check_ip_test,
                  provider_check_port_test,
                  support_space_test,
                  get_unsupported_space_info_test
  %%                group_invitation_test todo fix
              ]
          },
          {
  
negative.code: 
  %% handle_services_rest_module_test_group ============================
  
  create_doi_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
  
      Id = add_handle_service(?DOI_SERVICE, UserReqParams),
  
      ?assertMatch(<<_/binary>>, Id).
  
  create_pid_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
  
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
  
      ?assertMatch(<<_/binary>>, Id).
  
  list_services_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      DoiId = add_handle_service(?DOI_SERVICE, UserReqParams),
      PidId = add_handle_service(?PID_SERVICE, UserReqParams),
  
      Services = list_handle_service(UserReqParams), %todo should we list owned services or services that are accessible.
  
      ?assert(is_list(Services)),
      ?assertEqual(lists:sort([DoiId, PidId]), lists:sort(Services)).
  
  get_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?DOI_SERVICE, UserReqParams),
  
      Result = get_handle_service(Id, UserReqParams),
  
      ?assertEqual(?DOI_SERVICE, Result).
  
  modify_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?DOI_SERVICE, UserReqParams),
      Modifications = #{
          <<"name">> => <<"New name">>,
          <<"allowTemplateOverride">> => true
      },
  
      Result = modify_handle_service(Modifications, Id, UserReqParams),
  
      ?assertEqual(204, Result),
      ?assertMatch(#{<<"name">> := <<"New name">>, <<"allowTemplateOverride">> := true},
          get_handle_service(Id, UserReqParams)).
  
  delete_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?DOI_SERVICE, UserReqParams),
  
      Result = delete_handle_service(Id, UserReqParams),
  
      ?assertEqual(204, Result),
      ?assertEqual({request_error, 404}, get_handle_service(Id, UserReqParams)).
  
  add_user_to_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      UserId = ?config(userId, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
  
      Result = add_user_to_handle_service(Id, UserId, UserReqParams),
  
      ?assertEqual(204, Result).
  
  list_service_users_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      UserId = ?config(userId, Config),
      ProviderId = ?config(providerId, Config),
      ProviderReqParams = ?config(providerReqParams, Config),
      {UserId2, _} = register_user(?USER_NAME2, ProviderId, Config, ProviderReqParams),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      204 = add_user_to_handle_service(Id, UserId, UserReqParams),
      204 = add_user_to_handle_service(Id, UserId2, UserReqParams),
  
      Users = list_users_of_handle_service(Id, UserReqParams),
  
      ?assert(is_list(Users)),
      ?assertEqual(lists:sort(UserId, UserId2), lists:sort(Users)).
  
  delete_user_from_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      UserId = ?config(userId, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      204 = add_user_to_handle_service(Id, UserId, UserReqParams),
  
      Result = delete_user_from_handle_service(Id, UserId, UserReqParams),
  
      ?assertEqual(204, Result),
      ?assertEqual([], list_users_of_handle_service(Id, UserReqParams)).
  
  add_group_to_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      GroupId = create_group(<<"test_group">>, <<"organization">>, UserReqParams),
  
      Result = add_group_to_handle_service(Id, GroupId, UserReqParams),
  
      ?assertEqual(204, Result).
  
  list_service_groups_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      GroupId1 = create_group(<<"test_group1">>, <<"organization">>, UserReqParams),
      GroupId2 = create_group(<<"test_group2">>, <<"organization">>, UserReqParams),
  
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      204 = add_group_to_handle_service(Id, GroupId1, UserReqParams),
      204 = add_group_to_handle_service(Id, GroupId2, UserReqParams),
  
      Groups = list_groups_of_handle_service(Id, UserReqParams),
  
      ?assert(is_list(Groups)),
      ?assertEqual(lists:sort(GroupId1, GroupId2), lists:sort(Groups)).
  
  delete_group_from_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      GroupId = create_group(<<"test_group">>, <<"organization">>, UserReqParams),
      204 = add_group_to_handle_service(Id, GroupId, UserReqParams),
  
      Result = delete_group_from_handle_service(Id, GroupId, UserReqParams),
  
      ?assertEqual(204, Result),
      ?assertEqual([], list_groups_of_handle_service(Id, UserReqParams)).
  
  get_user_privileges_for_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      UserId = ?config(userId, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      204 = add_user_to_handle_service(Id, UserId, UserReqParams),
  
      Privileges = get_user_privileges_for_handle_service(Id, UserId, UserReqParams),
  
      ?assertEqual(lists:sort([<<"list_handle_services">>, <<"delete_handle_service">>,
          <<"modify_handle_service">>, <<"view_handle_service">>]),
          lists:sort(Privileges)
      ).
  
  set_user_privileges_for_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      UserId = ?config(userId, Config),
      Privileges = [<<"view_handle_service">>],
  
      Result = set_user_privileges_for_handle_service(Id, UserId, Privileges, UserReqParams),
  
      ?assertEqual(204, Result),
      ?assertEqual(Privileges, get_user_privileges_for_handle_service(Id, UserId, UserReqParams)).
  
  get_group_privileges_for_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      GroupId = create_group(<<"test_group">>, <<"organization">>, UserReqParams),
      204 = add_group_to_handle_service(Id, GroupId, UserReqParams),
  
      Privileges = get_group_privileges_for_handle_service(Id, GroupId, UserReqParams),
  
      ?assertEqual(lists:sort([<<"list_handle_services">>, <<"view_handle_service">>]),
          lists:sort(Privileges)
      ).
  
  set_group_privileges_for_service_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      Id = add_handle_service(?PID_SERVICE, UserReqParams),
      GroupId = create_group(<<"test_group">>, <<"organization">>, UserReqParams),
      204 = add_group_to_handle_service(Id, GroupId, UserReqParams),
      Privileges = [<<"view_handle_service">>],
  
      Result = set_group_privileges_for_handle_service(Id, GroupId, Privileges, UserReqParams),
  
      ?assertEqual(204, Result),
      ?assertEqual(Privileges, get_group_privileges_for_handle_service(Id, GroupId, UserReqParams)).
  
  %% handles_rest_module_test_group ====================================
  
  create_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  list_handles_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  get_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  modify_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  delete_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  add_user_to_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  list_handle_users_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  delete_user_from_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  add_group_to_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  list_handle_groups_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  delete_group_from_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  get_user_privileges_for_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  set_user_privileges_for_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  get_group_privileges_for_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  set_group_privileges_for_handle_test(Config) ->
      UserReqParams = ?config(userReqParams, Config),
      OtherRestAddress = ?config(otherRestAddress, Config),
      UserParamsOtherAddress = update_req_params(UserReqParams, OtherRestAddress, address). %todo write me!
  
  %% other tests =======================================================
  
  