1: -module(mongoose_api_common_SUITE).
    2: -compile([export_all, nowarn_export_all]).
    3: 
    4: -include_lib("eunit/include/eunit.hrl").
    5: 
    6: 
    7: -define(aq(E, V), (
    8:     [ct:fail("ASSERT EQUAL~n\tExpected ~p~n\tActual   ~p~n", [(E), (V)])
    9:      || (E) =/= (V)]
   10:     )).
   11: 
   12: all() ->
   13:     [url_is_correct_for_create_command,
   14:      url_is_correct_for_read_command,
   15:      url_is_correct_for_read_command_with_subcategory].
   16: 
   17: url_is_correct_for_create_command(_) ->
   18:     Cmd = create_cmd(),
   19:     Url = mongoose_api_common:create_admin_url_path(Cmd),
   20:     ?aq(<<"/users/:host">>, Url).
   21: 
   22: url_is_correct_for_read_command(_) ->
   23:     Cmd = read_cmd(),
   24:     Url = mongoose_api_common:create_admin_url_path(Cmd),
   25:     ?aq(<<"/users/:host">>, Url).
   26: 
   27: url_is_correct_for_read_command_with_subcategory(_) ->
   28:     Cmd = read_cmd2(),
   29:     Url = mongoose_api_common:create_admin_url_path(Cmd),
   30:     ?aq(<<"/users/:host/rosters">>, Url).
   31: 
   32: create_cmd() ->
   33:     Props = [
   34:              {name, registeruser},
   35:              {category, <<"users">>},
   36:              {desc, <<"Register a user">>},
   37:              {module, ?MODULE},
   38:              {function, register},
   39:              {action, create},
   40:              {args, [{user, binary}, {host, binary}, {password, binary}]},
   41:              {identifiers, [host]},
   42:              {result, {msg, binary}}
   43:             ],
   44:     mongoose_commands:new(Props).
   45: 
   46: read_cmd() ->
   47:     Props = [
   48:             {name, listusers},
   49:             {category, <<"users">>},
   50:             {desc, <<"List registered users on this host">>},
   51:             {module, ?MODULE},
   52:             {function, registered_users},
   53:             {action, read},
   54:             {args, [{host, binary}]},
   55:             {result, []}
   56:         ],
   57:     mongoose_commands:new(Props).
   58: 
   59: read_cmd2() ->
   60:     Props = [
   61:             {name, listusers},
   62:             {category, <<"users">>},
   63:             {subcategory, <<"rosters">>},
   64:             {desc, <<"List registered users on this host">>},
   65:             {module, ?MODULE},
   66:             {function, registered_users},
   67:             {action, read},
   68:             {args, [{host, binary}]},
   69:             {result, []}
   70:         ],
   71:     mongoose_commands:new(Props).
   72: