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)"),
|
||||
|
||||
Reference in New Issue
Block a user