OpenAPI: MastodonAPI Timeline Controller
This commit is contained in:
parent
19fbe5b860
commit
7eecc3b61d
@ -115,7 +115,8 @@ def hashtag_operation do
|
|||||||
],
|
],
|
||||||
operationId: "TimelineController.hashtag",
|
operationId: "TimelineController.hashtag",
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("Array of Status", "application/json", array_of_statuses())
|
200 => Operation.response("Array of Status", "application/json", array_of_statuses()),
|
||||||
|
401 => Operation.response("Error", "application/json", ApiError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -905,10 +905,10 @@ defp ensure_authenticated_access(base_uri) do
|
|||||||
%{conn: auth_conn} = oauth_access(["read:statuses"])
|
%{conn: auth_conn} = oauth_access(["read:statuses"])
|
||||||
|
|
||||||
res_conn = get(auth_conn, "#{base_uri}?local=true")
|
res_conn = get(auth_conn, "#{base_uri}?local=true")
|
||||||
assert length(json_response(res_conn, 200)) == 1
|
assert length(json_response_and_validate_schema(res_conn, 200)) == 1
|
||||||
|
|
||||||
res_conn = get(auth_conn, "#{base_uri}?local=false")
|
res_conn = get(auth_conn, "#{base_uri}?local=false")
|
||||||
assert length(json_response(res_conn, 200)) == 2
|
assert length(json_response_and_validate_schema(res_conn, 200)) == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with default settings on private instances, returns 403 for unauthenticated users", %{
|
test "with default settings on private instances, returns 403 for unauthenticated users", %{
|
||||||
@ -922,7 +922,7 @@ test "with default settings on private instances, returns 403 for unauthenticate
|
|||||||
for local <- [true, false] do
|
for local <- [true, false] do
|
||||||
res_conn = get(conn, "#{base_uri}?local=#{local}")
|
res_conn = get(conn, "#{base_uri}?local=#{local}")
|
||||||
|
|
||||||
assert json_response(res_conn, :unauthorized) == error_response
|
assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
|
||||||
end
|
end
|
||||||
|
|
||||||
ensure_authenticated_access(base_uri)
|
ensure_authenticated_access(base_uri)
|
||||||
@ -939,7 +939,7 @@ test "with `%{local: true, federated: true}`, returns 403 for unauthenticated us
|
|||||||
for local <- [true, false] do
|
for local <- [true, false] do
|
||||||
res_conn = get(conn, "#{base_uri}?local=#{local}")
|
res_conn = get(conn, "#{base_uri}?local=#{local}")
|
||||||
|
|
||||||
assert json_response(res_conn, :unauthorized) == error_response
|
assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
|
||||||
end
|
end
|
||||||
|
|
||||||
ensure_authenticated_access(base_uri)
|
ensure_authenticated_access(base_uri)
|
||||||
@ -951,10 +951,10 @@ test "with `%{local: false, federated: true}`, forbids unauthenticated access to
|
|||||||
clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||||
|
|
||||||
res_conn = get(conn, "#{base_uri}?local=true")
|
res_conn = get(conn, "#{base_uri}?local=true")
|
||||||
assert length(json_response(res_conn, 200)) == 1
|
assert length(json_response_and_validate_schema(res_conn, 200)) == 1
|
||||||
|
|
||||||
res_conn = get(conn, "#{base_uri}?local=false")
|
res_conn = get(conn, "#{base_uri}?local=false")
|
||||||
assert json_response(res_conn, :unauthorized) == error_response
|
assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
|
||||||
|
|
||||||
ensure_authenticated_access(base_uri)
|
ensure_authenticated_access(base_uri)
|
||||||
end
|
end
|
||||||
@ -966,11 +966,11 @@ test "with `%{local: true, federated: false}`, forbids unauthenticated access to
|
|||||||
clear_config([:restrict_unauthenticated, :timelines, :federated], false)
|
clear_config([:restrict_unauthenticated, :timelines, :federated], false)
|
||||||
|
|
||||||
res_conn = get(conn, "#{base_uri}?local=true")
|
res_conn = get(conn, "#{base_uri}?local=true")
|
||||||
assert json_response(res_conn, :unauthorized) == error_response
|
assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
|
||||||
|
|
||||||
# Note: local activities get delivered as part of federated timeline
|
# Note: local activities get delivered as part of federated timeline
|
||||||
res_conn = get(conn, "#{base_uri}?local=false")
|
res_conn = get(conn, "#{base_uri}?local=false")
|
||||||
assert length(json_response(res_conn, 200)) == 2
|
assert length(json_response_and_validate_schema(res_conn, 200)) == 2
|
||||||
|
|
||||||
ensure_authenticated_access(base_uri)
|
ensure_authenticated_access(base_uri)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user