1 defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
2 use Pleroma.Web.ConnCase
6 describe "POST /api/pleroma/follow_import" do
7 test "it returns HTTP 200", %{conn: conn} do
13 |> assign(:user, user1)
14 |> post("/api/pleroma/follow_import", %{"list" => "#{user2.ap_id}"})
17 assert response == "job started"
20 test "requires 'follow' permission", %{conn: conn} do
21 token1 = insert(:oauth_token, scopes: ["read", "write"])
22 token2 = insert(:oauth_token, scopes: ["follow"])
23 another_user = insert(:user)
25 for token <- [token1, token2] do
28 |> put_req_header("authorization", "Bearer #{token.token}")
29 |> post("/api/pleroma/follow_import", %{"list" => "#{another_user.ap_id}"})
32 assert %{"error" => "Insufficient permissions: follow."} == json_response(conn, 403)
34 assert json_response(conn, 200)
40 describe "POST /api/pleroma/blocks_import" do
41 test "it returns HTTP 200", %{conn: conn} do
47 |> assign(:user, user1)
48 |> post("/api/pleroma/blocks_import", %{"list" => "#{user2.ap_id}"})
51 assert response == "job started"
55 describe "GET /api/statusnet/config.json" do
56 test "it returns the managed config", %{conn: conn} do
57 Pleroma.Config.put([:instance, :managed_config], false)
58 Pleroma.Config.put([:fe], theme: "rei-ayanami-towel")
62 |> get("/api/statusnet/config.json")
65 refute response["site"]["pleromafe"]
67 Pleroma.Config.put([:instance, :managed_config], true)
71 |> get("/api/statusnet/config.json")
74 assert response["site"]["pleromafe"]
77 test "if :pleroma, :fe is false, it returns the new style config settings", %{conn: conn} do
78 Pleroma.Config.put([:instance, :managed_config], true)
79 Pleroma.Config.put([:fe, :theme], "rei-ayanami-towel")
80 Pleroma.Config.put([:frontend_configurations, :pleroma_fe], %{theme: "asuka-hospital"})
84 |> get("/api/statusnet/config.json")
87 assert response["site"]["pleromafe"]["theme"] == "rei-ayanami-towel"
89 Pleroma.Config.put([:fe], false)
93 |> get("/api/statusnet/config.json")
96 assert response["site"]["pleromafe"]["theme"] == "asuka-hospital"
100 describe "GET /api/pleroma/frontend_configurations" do
101 test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} do
112 Pleroma.Config.put(:frontend_configurations, config)
116 |> get("/api/pleroma/frontend_configurations")
117 |> json_response(:ok)
119 assert response == Jason.encode!(config |> Enum.into(%{})) |> Jason.decode!()