0e4e886cd4
Bootstrap calendar_specialist for owner (active); DELETE owner → 403; toggle via status. Fixes solo assign-to-slot. Refs EventHub/EventHubBack#66
31 lines
951 B
Erlang
31 lines
951 B
Erlang
-module(handler_search_tests).
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
handler_search_test_() ->
|
|
case is_server_running() of
|
|
true ->
|
|
[
|
|
{"Search API requires authentication", fun test_search_requires_auth/0}
|
|
];
|
|
false ->
|
|
io:format("Skipping handler tests: server not running~n"),
|
|
[]
|
|
end.
|
|
|
|
is_server_running() ->
|
|
case httpc:request(get, {"http://localhost:8080/health", []}, [], [{timeout, 1000}]) of
|
|
{ok, {{_, 200, _}, _, _}} -> true;
|
|
_ -> false
|
|
end.
|
|
|
|
test_search_requires_auth() ->
|
|
{ok, {{_, Code, _}, _, Body0}} =
|
|
httpc:request(get, {"http://localhost:8080/v1/search?type=event", []}, [],
|
|
[{body_format, binary}]),
|
|
?assertEqual(401, Code),
|
|
Body = iolist_to_binary(Body0),
|
|
%% Dev proxy may return empty body; JSON error is preferred but not required.
|
|
case Body of
|
|
<<>> -> ok;
|
|
_ -> ?assertMatch(#{<<"error">> := _}, jsx:decode(Body, [return_maps]))
|
|
end. |