diff options
| author | William Pitcock <nenolod@dereferenced.org> | 2018-05-28 17:45:23 +0000 | 
|---|---|---|
| committer | William Pitcock <nenolod@dereferenced.org> | 2018-06-11 22:15:53 +0000 | 
| commit | c99b9b9d926b30e417c2a44fa3f0f64029f76b2d (patch) | |
| tree | 4a732ebf73f45c7a09dbb92dcda953d2e44226f3 /test | |
| parent | 4084889a2d2a00828b2909ee5356f86b42d747e8 (diff) | |
| download | pleroma-c99b9b9d926b30e417c2a44fa3f0f64029f76b2d.tar.gz pleroma-c99b9b9d926b30e417c2a44fa3f0f64029f76b2d.zip | |
testsuite: add mastodon api tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 58 | 
1 files changed, 58 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 566f5acfc..e45b5c9c2 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -4,6 +4,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do    alias Pleroma.Web.TwitterAPI.TwitterAPI    alias Pleroma.{Repo, User, Activity, Notification}    alias Pleroma.Web.{OStatus, CommonAPI} +  alias Pleroma.Web.ActivityPub.ActivityPub    import Pleroma.Factory    import ExUnit.CaptureLog @@ -644,6 +645,63 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do      end    end +  describe "locked accounts" do +    test "/api/v1/follow_requests works" do +      user = insert(:user, %{info: %{"locked" => true}}) +      other_user = insert(:user) + +      {:ok, activity} = ActivityPub.follow(other_user, user) + +      conn = +        build_conn() +        |> assign(:user, user) +        |> get("/api/v1/follow_requests") + +      assert [relationship] = json_response(conn, 200) +      assert to_string(other_user.id) == relationship["id"] +    end + +    test "/api/v1/follow_requests/:id/authorize works" do +      user = insert(:user, %{info: %{"locked" => true}}) +      other_user = insert(:user) + +      {:ok, activity} = ActivityPub.follow(other_user, user) + +      conn = +        build_conn() +        |> assign(:user, user) +        |> post("/api/v1/follow_requests/#{other_user.id}/authorize") + +      assert relationship = json_response(conn, 200) +      assert to_string(other_user.id) == relationship["id"] + +      user = Repo.get(User, user.id) +      other_user = Repo.get(User, other_user.id) + +      assert User.following?(other_user, user) == true +    end + +    test "/api/v1/follow_requests/:id/reject works" do +      user = insert(:user, %{info: %{"locked" => true}}) +      other_user = insert(:user) + +      {:ok, activity} = ActivityPub.follow(other_user, user) + +      conn = +        build_conn() +        |> assign(:user, user) +        |> post("/api/v1/follow_requests/#{other_user.id}/reject") + +      assert relationship = json_response(conn, 200) +      assert to_string(other_user.id) == relationship["id"] + +      user = Repo.get(User, user.id) +      other_user = Repo.get(User, other_user.id) + +      assert User.following?(other_user, user) == false +    end +  end +    test "account fetching", %{conn: conn} do      user = insert(:user) | 
