1: -module(graphql_vcard_SUITE).
    2: 
    3: -compile([export_all, nowarn_export_all]).
    4: 
    5: -import(distributed_helper, [require_rpc_nodes/1, mim/0]).
    6: -import(graphql_helper, [execute_command/4, execute_user_command/5,
    7:                          user_to_bin/1, get_ok_value/2, skip_null_fields/1, get_err_msg/1,
    8:                          get_unauthorized/1, get_not_loaded/1, get_err_code/1]).
    9: -import(domain_helper, [domain/0]).
   10: 
   11: -include_lib("common_test/include/ct.hrl").
   12: -include_lib("eunit/include/eunit.hrl").
   13: 
   14: suite() ->
   15:     require_rpc_nodes([mim]) ++ escalus:suite().
   16: 
   17: all() ->
   18:     [{group, user},
   19:      {group, domain_admin_vcard},
   20:      {group, admin_http},
   21:      {group, admin_cli}].
   22: 
   23: groups() ->
   24:     [{user, [], user_groups()},
   25:      {domain_admin_vcard, [], domain_admin_vcard_tests()},
   26:      {admin_http, [], admin_groups()},
   27:      {admin_cli, [], admin_groups()},
   28:      {user_vcard_configured, [], user_vcard_tests()},
   29:      {user_vcard_not_configured, [], user_vcard_not_configured_tests()},
   30:      {admin_vcard_configured, [], admin_vcard_tests()},
   31:      {admin_vcard_not_configured, [], admin_vcard_not_configured_tests()}].
   32: 
   33: user_groups() ->
   34:     [{group, user_vcard_configured},
   35:      {group, user_vcard_not_configured}].
   36: 
   37: admin_groups() ->
   38:     [{group, admin_vcard_configured},
   39:      {group, admin_vcard_not_configured}].
   40: 
   41: user_vcard_tests() ->
   42:     [user_set_vcard,
   43:      user_get_their_vcard,
   44:      user_get_their_vcard_no_vcard,
   45:      user_get_others_vcard,
   46:      user_get_others_vcard_no_user,
   47:      user_get_others_vcard_no_vcard].
   48: 
   49: user_vcard_not_configured_tests() ->
   50:     [user_set_vcard_not_configured,
   51:      user_get_their_vcard_not_configured,
   52:      user_get_others_vcard_not_configured].
   53: 
   54: domain_admin_vcard_tests() ->
   55:     [admin_set_vcard,
   56:      admin_set_vcard_incomplete_fields,
   57:      domain_admin_set_vcard_no_host,
   58:      domain_admin_set_vcard_no_permission,
   59:      admin_get_vcard,
   60:      admin_get_vcard_no_vcard,
   61:      domain_admin_get_vcard_no_host,
   62:      domain_admin_get_vcard_no_permission].
   63: 
   64: admin_vcard_tests() ->
   65:     [admin_set_vcard,
   66:      admin_set_vcard_incomplete_fields,
   67:      admin_set_vcard_no_host,
   68:      admin_get_vcard,
   69:      admin_get_vcard_no_vcard,
   70:      admin_get_vcard_no_host].
   71: 
   72: admin_vcard_not_configured_tests() ->
   73:     [admin_set_vcard_not_configured,
   74:      admin_get_vcard_not_configured].
   75: 
   76: init_per_suite(Config) ->
   77:     case vcard_helper:is_vcard_ldap() of
   78:         true ->
   79:             {skip, ldap_vcard_is_not_supported};
   80:         _ ->
   81:             HostType = domain_helper:host_type(),
   82:             Config1 = escalus:init_per_suite(Config),
   83:             Config2 = ejabberd_node_utils:init(mim(), Config1),
   84:             Config3 = dynamic_modules:save_modules(domain_helper:host_type(), Config2),
   85:             VCardOpts = dynamic_modules:get_saved_config(HostType, mod_vcard, Config3),
   86:             [{mod_vcard_opts, VCardOpts} | Config3]
   87:     end.
   88: 
   89: end_per_suite(Config) ->
   90:     dynamic_modules:restore_modules(Config),
   91:     escalus:end_per_suite(Config).
   92: 
   93: init_per_group(admin_http, Config) ->
   94:     graphql_helper:init_admin_handler(Config);
   95: init_per_group(admin_cli, Config) ->
   96:     graphql_helper:init_admin_cli(Config);
   97: init_per_group(domain_admin_vcard, Config) ->
   98:     Config1 = ensure_vcard_started(Config),
   99:     graphql_helper:init_domain_admin_handler(Config1);
  100: init_per_group(user, Config) ->
  101:     graphql_helper:init_user(Config);
  102: init_per_group(Group, Config) when Group =:= admin_vcard_configured;
  103:                                    Group =:= user_vcard_configured ->
  104:     ensure_vcard_started(Config);
  105: init_per_group(Group, Config) when Group =:= admin_vcard_not_configured;
  106:                                    Group =:= user_vcard_not_configured ->
  107:     ensure_vcard_stopped(Config).
  108: 
  109: end_per_group(GroupName, _Config) when GroupName =:= admin_http;
  110:                                        GroupName =:= admin_cli;
  111:                                        GroupName =:= user;
  112:                                        GroupName =:= domain_admin_vcard ->
  113:     graphql_helper:clean();
  114: end_per_group(_GroupName, _Config) ->
  115:     escalus_fresh:clean().
  116: 
  117: ensure_vcard_started(Config) ->
  118:     HostType = domain_helper:host_type(),
  119:     VCardConfig = ?config(mod_vcard_opts, Config),
  120:     dynamic_modules:restart(HostType, mod_vcard, VCardConfig),
  121:     Config.
  122: 
  123: ensure_vcard_stopped(Config) ->
  124:     HostType = domain_helper:host_type(),
  125:     dynamic_modules:stop(HostType, mod_vcard),
  126:     Config.
  127: 
  128: init_per_testcase(CaseName, Config) ->
  129:     escalus:init_per_testcase(CaseName, Config).
  130: 
  131: end_per_testcase(CaseName, Config) ->
  132:     escalus:end_per_testcase(CaseName, Config).
  133: 
  134: % User test cases
  135: 
  136: user_set_vcard(Config) ->
  137:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  138:                                     fun user_set_vcard/2).
  139: 
  140: user_set_vcard(Config, Alice) ->
  141:     Vcard = complete_vcard_input(),
  142:     ResultSet = user_set_vcard(Alice, Vcard, Config),
  143:     ParsedResultSet = get_ok_value([data, vcard, setVcard], ResultSet),
  144:     ?assertEqual(Vcard, skip_null_fields(ParsedResultSet)),
  145:     ResultGet = user_get_own_vcard(Alice, Config),
  146:     ParsedResultGet = get_ok_value([data, vcard, getVcard], ResultGet),
  147:     ?assertEqual(Vcard, skip_null_fields(ParsedResultGet)).
  148: 
  149: user_get_their_vcard(Config) ->
  150:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  151:                                     fun user_get_their_vcard/2).
  152: 
  153: user_get_their_vcard(Config, Alice) ->
  154:     Client1Fields = [{<<"FN">>, <<"TESTNAME">>}, {<<"EMAIL">>, [{<<"USERID">>, <<"TESTEMAIL">>},
  155:     {<<"HOME">>, []}, {"WORK", []}]}, {<<"EMAIL">>, [{<<"USERID">>, <<"TESTEMAIL2">>},
  156:     {<<"HOME">>, []}]}],
  157:     ExpectedResult = #{<<"formattedName">> => <<"TESTNAME">>,
  158:         <<"email">> => [#{<<"userId">> => <<"TESTEMAIL">>, <<"tags">> => [<<"HOME">>, <<"WORK">>]},
  159:                         #{<<"userId">> => <<"TESTEMAIL2">>, <<"tags">> => [<<"HOME">>]}]},
  160:     escalus_client:send_and_wait(Alice, escalus_stanza:vcard_update(Client1Fields)),
  161:     Result = user_get_own_vcard(Alice, Config),
  162:     ParsedResult = get_ok_value([data, vcard, getVcard], Result),
  163:     ?assertEqual(ExpectedResult, skip_null_fields(ParsedResult)).
  164: 
  165: user_get_their_vcard_no_vcard(Config) ->
  166:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  167:                                     fun user_get_their_vcard_no_vcard/2).
  168: 
  169: user_get_their_vcard_no_vcard(Config, Alice) ->
  170:     Result = user_get_own_vcard(Alice, Config),
  171:     ?assertEqual(<<"Vcard for user not found">>, get_err_msg(Result)).
  172: 
  173: user_get_others_vcard(Config) ->
  174:     escalus:fresh_story_with_config(Config, [{alice, 1}, {bob, 1}],
  175:                                     fun user_get_others_vcard/3).
  176: 
  177: user_get_others_vcard(Config, Alice, Bob) ->
  178:     Client1Fields = [{<<"FN">>, <<"TESTNAME">>}, {<<"EMAIL">>, [{<<"USERID">>, <<"TESTEMAIL">>},
  179:     {<<"HOME">>, []}, {"WORK", []}]}, {<<"EMAIL">>, [{<<"USERID">>, <<"TESTEMAIL2">>},
  180:     {<<"HOME">>, []}]}],
  181:     ExpectedResult = #{<<"formattedName">> => <<"TESTNAME">>,
  182:         <<"email">> => [#{<<"userId">> => <<"TESTEMAIL">>, <<"tags">> => [<<"HOME">>, <<"WORK">>]},
  183:                         #{<<"userId">> => <<"TESTEMAIL2">>, <<"tags">> => [<<"HOME">>]}]},
  184:     escalus_client:send_and_wait(Bob, escalus_stanza:vcard_update([{<<"VERSION">>, <<"TESTVERSION">>}
  185:                                                                   | Client1Fields])),
  186:     Result = user_get_vcard(Alice, user_to_bin(Bob), Config),
  187:     ParsedResult = get_ok_value([data, vcard, getVcard], Result),
  188:     ?assertEqual(ExpectedResult, skip_null_fields(ParsedResult)).
  189: 
  190: user_get_others_vcard_no_vcard(Config) ->
  191:     escalus:fresh_story_with_config(Config, [{alice, 1}, {bob, 1}],
  192:                                     fun user_get_others_vcard_no_vcard/3).
  193: 
  194: user_get_others_vcard_no_vcard(Config, Alice, Bob) ->
  195:     Result = user_get_vcard(Alice, user_to_bin(Bob), Config),
  196:     ?assertEqual(<<"Vcard for user not found">>, get_err_msg(Result)).
  197: 
  198: user_get_others_vcard_no_user(Config) ->
  199:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  200:                                     fun user_get_others_vcard_no_user/2).
  201: 
  202: user_get_others_vcard_no_user(Config, Alice) ->
  203:     Result = user_get_vcard(Alice, <<"eddie@otherhost">>, Config),
  204:     ?assertEqual(<<"User's domain does not exist">>, get_err_msg(Result)),
  205:     Domain = domain(),
  206:     Result2 = user_get_vcard(Alice, <<"eddie@", Domain/binary>>, Config),
  207:     ?assertEqual(<<"Given user does not exist">>, get_err_msg(Result2)).
  208: 
  209: % User VCard not configured test cases
  210: 
  211: user_set_vcard_not_configured(Config) ->
  212:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  213:                                     fun user_set_vcard_not_configured/2).
  214: 
  215: user_set_vcard_not_configured(Config, Alice) ->
  216:     Vcard = complete_vcard_input(),
  217:     Res = user_set_vcard(Alice, Vcard, Config),
  218:     get_not_loaded(Res).
  219: 
  220: user_get_others_vcard_not_configured(Config) ->
  221:     escalus:fresh_story_with_config(Config, [{alice, 1}, {bob, 1}],
  222:                                     fun user_get_others_vcard_not_configured/3).
  223: 
  224: user_get_others_vcard_not_configured(Config, Alice, Bob) ->
  225:     Res = user_get_vcard(Alice, user_to_bin(Bob), Config),
  226:     get_not_loaded(Res).
  227: 
  228: user_get_their_vcard_not_configured(Config) ->
  229:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  230:                                     fun user_get_their_vcard_not_configured/2).
  231: 
  232: user_get_their_vcard_not_configured(Config, Alice) ->
  233:     Res = user_get_own_vcard(Alice, Config),
  234:     ?assertEqual(<<"vcard_not_configured_error">>, get_err_code(Res)).
  235: 
  236: %% Domain admin test cases
  237: 
  238: domain_admin_set_vcard_no_host(Config) ->
  239:     Vcard = complete_vcard_input(),
  240:     get_unauthorized(set_vcard(Vcard, <<"eddie@otherhost">>, Config)).
  241: 
  242: domain_admin_get_vcard_no_host(Config) ->
  243:     get_unauthorized(get_vcard(<<"eddie@otherhost">>, Config)).
  244: 
  245: domain_admin_get_vcard_no_permission(Config) ->
  246:     escalus:fresh_story_with_config(Config, [{alice_bis, 1}],
  247:                                     fun domain_admin_get_vcard_no_permission/2).
  248: 
  249: domain_admin_get_vcard_no_permission(Config, AliceBis) ->
  250:     Result = get_vcard(user_to_bin(AliceBis), Config),
  251:     get_unauthorized(Result).
  252: 
  253: domain_admin_set_vcard_no_permission(Config) ->
  254:     escalus:fresh_story_with_config(Config, [{alice_bis, 1}],
  255:                                     fun domain_admin_set_vcard_no_permission/2).
  256: 
  257: domain_admin_set_vcard_no_permission(Config, AliceBis) ->
  258:     Vcard = complete_vcard_input(),
  259:     Result = set_vcard(Vcard, user_to_bin(AliceBis), Config),
  260:     get_unauthorized(Result).
  261: 
  262: %% Admin test cases
  263: 
  264: admin_set_vcard(Config) ->
  265:     Config1 = [{vcard, complete_vcard_input()} | Config],
  266:     escalus:fresh_story_with_config(Config1, [{alice, 1}, {bob, 1}],
  267:                                     fun admin_set_vcard/3).
  268: 
  269: admin_set_vcard_incomplete_fields(Config) ->
  270:     Config1 = [{vcard, address_vcard_input()} | Config],
  271:     escalus:fresh_story_with_config(Config1, [{alice, 1}, {bob, 1}],
  272:                                     fun admin_set_vcard/3).
  273: 
  274: admin_set_vcard(Config, Alice, _Bob) ->
  275:     Vcard = ?config(vcard, Config),
  276:     ResultSet = set_vcard(Vcard, user_to_bin(Alice), Config),
  277:     ParsedResultSet = get_ok_value([data, vcard, setVcard], ResultSet),
  278:     ?assertEqual(Vcard, skip_null_fields(ParsedResultSet)),
  279:     ResultGet = get_vcard(user_to_bin(Alice), Config),
  280:     ParsedResultGet = get_ok_value([data, vcard, getVcard], ResultGet),
  281:     ?assertEqual(Vcard, skip_null_fields(ParsedResultGet)).
  282: 
  283: admin_set_vcard_no_host(Config) ->
  284:     Vcard = complete_vcard_input(),
  285:     Result = set_vcard(Vcard, <<"eddie@otherhost">>, Config),
  286:     ?assertEqual(<<"User's domain does not exist">>, get_err_msg(Result)),
  287:     Domain = domain(),
  288:     Result2 = set_vcard(Vcard, <<"eddie@", Domain/binary>>, Config),
  289:     ?assertEqual(<<"Given user does not exist">>, get_err_msg(Result2)).
  290: 
  291: admin_get_vcard(Config) ->
  292:     escalus:fresh_story_with_config(Config, [{alice, 1}, {bob, 1}],
  293:                                     fun admin_get_vcard/3).
  294: 
  295: admin_get_vcard(Config, Alice, _Bob) ->
  296:     Client1Fields = [{<<"ADR">>, [{<<"POBOX">>, <<"TESTPobox">>}, {<<"EXTADD">>, <<"TESTExtadd">>},
  297:         {<<"STREET">>, <<"TESTStreet">>}, {<<"LOCALITY">>, <<"TESTLocality">>},
  298:         {<<"REGION">>, <<"TESTRegion">>}, {<<"PCODE">>, <<"TESTPCODE">>},
  299:         {<<"CTRY">>, <<"TESTCTRY">>}, {<<"HOME">>, []}, {<<"WORK">>, []}]}],
  300:     ExpectedResult = #{<<"address">> => [#{<<"pobox">> => <<"TESTPobox">>,
  301:         <<"extadd">> => <<"TESTExtadd">>, <<"street">> => <<"TESTStreet">>,
  302:         <<"locality">> => <<"TESTLocality">>, <<"region">> => <<"TESTRegion">>,
  303:         <<"pcode">> => <<"TESTPCODE">>, <<"country">> => <<"TESTCTRY">>,
  304:         <<"tags">> => [<<"HOME">>, <<"WORK">>]}]},
  305:     escalus_client:send_and_wait(Alice, escalus_stanza:vcard_update(Client1Fields)),
  306:     Result = get_vcard(user_to_bin(Alice), Config),
  307:     ParsedResult = get_ok_value([data, vcard, getVcard], Result),
  308:     ?assertEqual(ExpectedResult, skip_null_fields(ParsedResult)).
  309: 
  310: admin_get_vcard_no_vcard(Config) ->
  311:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  312:                                     fun admin_get_vcard_no_vcard/2).
  313: 
  314: admin_get_vcard_no_vcard(Config, Alice) ->
  315:     Result = get_vcard(user_to_bin(Alice), Config),
  316:     ?assertEqual(<<"Vcard for user not found">>, get_err_msg(Result)).
  317: 
  318: admin_get_vcard_no_host(Config) ->
  319:     Result = get_vcard(<<"eddie@otherhost">>, Config),
  320:     ?assertEqual(<<"User's domain does not exist">>, get_err_msg(Result)),
  321:     Domain = domain(),
  322:     Result2 = get_vcard(<<"eddie@", Domain/binary>>, Config),
  323:     ?assertEqual(<<"Given user does not exist">>, get_err_msg(Result2)).
  324: 
  325: %% Admin VCard not configured test cases
  326: 
  327: admin_get_vcard_not_configured(Config) ->
  328:     escalus:fresh_story_with_config(Config, [{alice, 1}],
  329:                                     fun admin_get_vcard_not_configured/2).
  330: 
  331: admin_get_vcard_not_configured(Config, Alice) ->
  332:     Res = get_vcard(user_to_bin(Alice), Config),
  333:     get_not_loaded(Res).
  334: 
  335: admin_set_vcard_not_configured(Config) ->
  336:     Config1 = [{vcard, complete_vcard_input()} | Config],
  337:     escalus:fresh_story_with_config(Config1, [{alice, 1}],
  338:                                     fun admin_set_vcard_not_configured/2).
  339: 
  340: admin_set_vcard_not_configured(Config, Alice) ->
  341:     Vcard = ?config(vcard, Config),
  342:     Res = set_vcard(Vcard, user_to_bin(Alice), Config),
  343:     get_not_loaded(Res).
  344: 
  345: %% Commands
  346: 
  347: user_set_vcard(User, VCard, Config) ->
  348:     Vars = #{vcard => VCard},
  349:     execute_user_command(<<"vcard">>, <<"setVcard">>, User, Vars, Config).
  350: 
  351: user_get_own_vcard(User, Config) ->
  352:     execute_user_command(<<"vcard">>, <<"getVcard">>, User, #{}, Config).
  353: 
  354: user_get_vcard(User, JID, Config) ->
  355:     Vars = #{user => JID},
  356:     execute_user_command(<<"vcard">>, <<"getVcard">>, User, Vars, Config).
  357: 
  358: set_vcard(VCard, User, Config) ->
  359:     Vars = #{vcard => VCard, user => User},
  360:     execute_command(<<"vcard">>, <<"setVcard">>, Vars, Config).
  361: 
  362: get_vcard(User, Config) ->
  363:     Vars = #{user => User},
  364:     execute_command(<<"vcard">>, <<"getVcard">>, Vars, Config).
  365: 
  366: %% Helpers
  367: 
  368: address_vcard_input() ->
  369:    #{<<"formattedName">> => <<"TestName">>,
  370:      <<"nameComponents">> => #{},
  371:      <<"address">> => [
  372:          #{
  373:              <<"tags">> => [<<"HOME">>, <<"WORK">>],
  374:              <<"pobox">> => <<"poboxTest">>,
  375:              <<"extadd">> => <<"extaddTest">>,
  376:              <<"street">> => <<"TESTSTREET123">>,
  377:              <<"locality">> => <<"LOCALITY123">>,
  378:              <<"region">> => <<"REGION777">>,
  379:              <<"country">> => <<"COUNTRY123">>
  380:          }
  381:      ]}.
  382: 
  383: complete_vcard_input() ->
  384:    #{<<"formattedName">> => <<"TestName">>,
  385:      <<"nameComponents">> => #{
  386:          <<"family">> => <<"familyName">>,
  387:          <<"givenName">> => <<"givenName">>,
  388:          <<"middleName">> => <<"middleName">>,
  389:          <<"prefix">> => <<"prefix">>,
  390:          <<"suffix">> => <<"sufix">>
  391:      },
  392:      <<"nickname">> => [<<"NicknameTest">>, <<"SecondNickname">>],
  393:      <<"photo">> => [
  394:         #{<<"type">> => <<"image/jpeg">>,
  395:           <<"binValue">> => <<"TestBinaries">>},
  396:         #{<<"extValue">> => <<"External Value">>}
  397:     ],
  398:      <<"birthday">> => [<<"birthdayTest">>, <<"SecondBirthday">>],
  399:      <<"address">> => [
  400:          #{
  401:              <<"tags">> => [<<"HOME">>, <<"WORK">>],
  402:              <<"pobox">> => <<"poboxTest">>,
  403:              <<"extadd">> => <<"extaddTest">>,
  404:              <<"street">> => <<"TESTSTREET123">>,
  405:              <<"locality">> => <<"LOCALITY123">>,
  406:              <<"region">> => <<"REGION777">>,
  407:              <<"pcode">> => <<"PcodeTest">>,
  408:              <<"country">> => <<"COUNTRY123">>
  409:          },
  410:          #{
  411:              <<"tags">> => [<<"HOME">>, <<"WORK">>, <<"POSTAL">>],
  412:              <<"pobox">> => <<"poboxTestSecond">>,
  413:              <<"extadd">> => <<"extaddTestSecond">>,
  414:              <<"street">> => <<"TESTSTREET123Second">>,
  415:              <<"locality">> => <<"LOCALITY123Second">>,
  416:              <<"region">> => <<"REGION777TEST">>,
  417:              <<"pcode">> => <<"PcodeTestSECOND">>,
  418:              <<"country">> => <<"COUNTRY123SECOND">>
  419:          }
  420:      ],
  421:      <<"label">> => [
  422:         #{<<"tags">> => [<<"WORK">>, <<"HOME">>], <<"line">> => [<<"LineTest">>, <<"AAA">>]},
  423:         #{<<"tags">> => [<<"POSTAL">>, <<"WORK">>], <<"line">> => [<<"LineTest2">>, <<"AAA">>]}
  424:      ],
  425:      <<"telephone">> => [
  426:          #{<<"tags">> => [<<"HOME">>, <<"BBS">>], <<"number">> => <<"590190190">>},
  427:          #{<<"tags">> => [<<"WORK">>, <<"BBS">>], <<"number">> => <<"590190191">>}
  428:      ],
  429:      <<"email">> => [
  430:          #{<<"tags">> => [<<"PREF">>], <<"userId">> => <<"userIDTEst">>},
  431:          #{<<"tags">> => [<<"PREF">>, <<"HOME">>], <<"userId">> => <<"userIDTEsTETt">>}
  432:      ],
  433:      <<"jabberId">> => [<<"JabberId">>, <<"JabberIDSecind">>],
  434:      <<"mailer">> => [<<"MailerTest">>, <<"MailerSecond">>],
  435:      <<"timeZone">> => [<<"TimeZoneTest">>, <<"TimeZOneSecond">>],
  436:      <<"geo">> => [
  437:          #{<<"lat">> => <<"LatitudeTest">>, <<"lon">> => <<"LongtitudeTest">>},
  438:          #{<<"lat">> => <<"LatitudeTest2">>, <<"lon">> => <<"LongtitudeTest2">>}
  439:      ],
  440:      <<"title">> => [<<"TitleTest">>, <<"SEcondTest">>],
  441:      <<"role">> => [<<"roleTest">>, <<"SecondRole">>],
  442:      <<"logo">> => [
  443:         #{<<"type">> => <<"image/jpeg">>,
  444:           <<"binValue">> => <<"TestBinariesLogo">>},
  445:         #{<<"extValue">> => <<"External Value Logo">>}
  446:      ],
  447:      <<"agent">> => [
  448:          #{<<"vcard">> => agent_vcard_input()},
  449:          #{<<"extValue">> => <<"TESTVALUE">>},
  450:          #{<<"vcard">> => agent_vcard_input()}
  451:      ],
  452:      <<"org">> => [
  453:          #{<<"orgname">> => <<"TESTNAME">>, <<"orgunit">> => [<<"test1">>, <<"TEST2">>]},
  454:          #{<<"orgname">> => <<"TESTNAME123">>, <<"orgunit">> => [<<"test1">>]}
  455:      ],
  456:      <<"categories">> => [
  457:          #{<<"keyword">> => [<<"KeywordTest">>]},
  458:          #{<<"keyword">> => [<<"KeywordTest">>, <<"Keyword2">>]}
  459:      ],
  460:      <<"note">> => [<<"NoteTest">>, <<"NOTE2">>],
  461:      <<"prodId">> => [<<"ProdIdTest">>, <<"PRodTEST2">>],
  462:      <<"rev">> => [<<"revTest">>, <<"RevTest2">>],
  463:      <<"sortString">> => [<<"sortStringTest">>, <<"String2">>],
  464:      <<"sound">> => [
  465:          #{<<"binValue">> => <<"TestBinValue">>},
  466:          #{<<"phonetic">> => <<"PhoneticTest">>},
  467:          #{<<"extValue">> => <<"ExtValueTest">>}
  468:      ],
  469:      <<"uid">> => [<<"UidTest">>, <<"UID2">>],
  470:      <<"url">> => [<<"UrlTest">>, <<"URL2">>],
  471:      <<"desc">> => [<<"DescTest">>, <<"DESC2">>],
  472:      <<"class">> => [
  473:          #{<<"tags">> => [<<"CONFIDENTIAL">>, <<"PRIVATE">>]},
  474:          #{<<"tags">> => [<<"CONFIDENTIAL">>]}
  475:      ],
  476:      <<"key">> => [
  477:          #{<<"type">> => <<"TYPETEST1">>, <<"credential">> => <<"TESTCREDENTIAL1">>},
  478:          #{<<"type">> => <<"TYPETEST2">>, <<"credential">> => <<"TESTCREDENTIAL2">>}
  479:      ]
  480:     }.
  481: 
  482: agent_vcard_input() ->
  483:    #{<<"formattedName">> => <<"TestName">>,
  484:      <<"nameComponents">> => #{
  485:          <<"family">> => <<"familyName">>,
  486:          <<"givenName">> => <<"givenName">>,
  487:          <<"middleName">> => <<"middleName">>,
  488:          <<"prefix">> => <<"prefix">>,
  489:          <<"suffix">> => <<"sufix">>
  490:      },
  491:      <<"nickname">> => [<<"NicknameTest">>, <<"SecondNickname">>],
  492:      <<"photo">> => [
  493:         #{<<"type">> => <<"image/jpeg">>,
  494:           <<"binValue">> => <<"TestBinaries">>},
  495:         #{<<"extValue">> => <<"External Value">>}
  496:     ]}.