feat(api): optional auth for public search and studio week. Refs EventHub/EventHubFront#58
This commit is contained in:
@@ -19,7 +19,7 @@ test() ->
|
||||
CalId = api_test_runner:create_calendar(Token, #{title => <<"TestCal">>}),
|
||||
|
||||
test_get_calendar(Token, CalId),
|
||||
test_get_calendar_unauthorized(CalId),
|
||||
test_get_calendar_guest(Token, CalId),
|
||||
test_get_calendar_not_found(Token),
|
||||
test_update_calendar(Token, CalId),
|
||||
test_update_calendar_settings(Token, CalId),
|
||||
@@ -39,12 +39,15 @@ test_get_calendar(Token, CalId) ->
|
||||
?assert(maps:is_key(<<"title">>, Cal)),
|
||||
ct:pal(" OK: ~s", [maps:get(<<"title">>, Cal)]).
|
||||
|
||||
test_get_calendar_unauthorized(CalId) ->
|
||||
ct:pal(" TEST: Get calendar without token (401)"),
|
||||
test_get_calendar_guest(Token, CalId) ->
|
||||
ct:pal(" TEST: Guest GET commercial calendar (200), personal (403)"),
|
||||
Path = <<"/v1/calendars/", CalId/binary>>,
|
||||
Resp = api_test_runner:client_request(get, Path, <<>>),
|
||||
?assertMatch({ok, 401, _, _}, Resp),
|
||||
ct:pal(" OK: got 401").
|
||||
{ok, 200, _, Body} = api_test_runner:client_request(get, Path, <<>>),
|
||||
#{<<"id">> := CalId} = jsx:decode(list_to_binary(Body), [return_maps]),
|
||||
PersonalId = api_test_runner:existing_personal_calendar_id(Token),
|
||||
PPath = <<"/v1/calendars/", PersonalId/binary>>,
|
||||
{ok, 403, _, _} = api_test_runner:client_request(get, PPath, <<>>),
|
||||
ct:pal(" OK: guest commercial 200, personal 403").
|
||||
|
||||
test_get_calendar_not_found(Token) ->
|
||||
ct:pal(" TEST: Get non-existent calendar (404)"),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
%%% - поиск с фильтрацией по датам (from/to)
|
||||
%%% - геопоиск (lat, lon, radius)
|
||||
%%% - пагинацию результатов
|
||||
%%% - ошибку 401 без токена
|
||||
%%% - публичный поиск без токена (200)
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(user_search_tests).
|
||||
@@ -120,7 +120,9 @@ test_search_pagination(Token) ->
|
||||
ct:pal(" OK").
|
||||
|
||||
test_search_unauthorized() ->
|
||||
ct:pal(" TEST: Search without token"),
|
||||
ct:pal(" TEST: Search without token (public)"),
|
||||
Resp = api_test_runner:client_request(get, <<"/v1/search?q=test">>, <<>>),
|
||||
?assertMatch({ok, 401, _, _}, Resp),
|
||||
ct:pal(" OK: got 401").
|
||||
{ok, 200, _, Body} = Resp,
|
||||
Decoded = jsx:decode(list_to_binary(Body), [return_maps]),
|
||||
?assert(is_map(Decoded)),
|
||||
ct:pal(" OK: guest search 200").
|
||||
Reference in New Issue
Block a user