diff options
| author | Maksim Pechnikov <parallel588@gmail.com> | 2020-02-25 07:15:33 +0300 | 
|---|---|---|
| committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-02-25 07:22:56 +0300 | 
| commit | 10f452ad1feae9a882b6dc4cd35e09adb7e78208 (patch) | |
| tree | 62083f08fbe99cd38002d1f6896cd2fd79675320 /test/web/mastodon_api/controllers | |
| parent | 28701c08ad9219219a32f31b2ed9dcb83f92cd59 (diff) | |
| parent | 035c2c1415ed46abb268cf85c141384416a799e2 (diff) | |
| download | pleroma-10f452ad1feae9a882b6dc4cd35e09adb7e78208.tar.gz pleroma-10f452ad1feae9a882b6dc4cd35e09adb7e78208.zip | |
Merge branch 'develop' into issue/1276
Diffstat (limited to 'test/web/mastodon_api/controllers')
| -rw-r--r-- | test/web/mastodon_api/controllers/account_controller_test.exs | 10 | ||||
| -rw-r--r-- | test/web/mastodon_api/controllers/status_controller_test.exs | 20 | 
2 files changed, 24 insertions, 6 deletions
| diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs index e2abcd7c5..8625bb9cf 100644 --- a/test/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/web/mastodon_api/controllers/account_controller_test.exs @@ -15,6 +15,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do    import Pleroma.Factory    describe "account fetching" do +    clear_config([:instance, :limit_to_local_content]) +      test "works by id" do        user = insert(:user) @@ -44,7 +46,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do      end      test "works by nickname for remote users" do -      limit_to_local = Pleroma.Config.get([:instance, :limit_to_local_content])        Pleroma.Config.put([:instance, :limit_to_local_content], false)        user = insert(:user, nickname: "user@example.com", local: false) @@ -52,13 +53,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do          build_conn()          |> get("/api/v1/accounts/#{user.nickname}") -      Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)        assert %{"id" => id} = json_response(conn, 200)        assert id == user.id      end      test "respects limit_to_local_content == :all for remote user nicknames" do -      limit_to_local = Pleroma.Config.get([:instance, :limit_to_local_content])        Pleroma.Config.put([:instance, :limit_to_local_content], :all)        user = insert(:user, nickname: "user@example.com", local: false) @@ -67,12 +66,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do          build_conn()          |> get("/api/v1/accounts/#{user.nickname}") -      Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)        assert json_response(conn, 404)      end      test "respects limit_to_local_content == :unauthenticated for remote user nicknames" do -      limit_to_local = Pleroma.Config.get([:instance, :limit_to_local_content])        Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)        user = insert(:user, nickname: "user@example.com", local: false) @@ -90,7 +87,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do          |> assign(:token, insert(:oauth_token, user: reading_user, scopes: ["read:accounts"]))          |> get("/api/v1/accounts/#{user.nickname}") -      Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local)        assert %{"id" => id} = json_response(conn, 200)        assert id == user.id      end @@ -677,6 +673,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do        assert json_response(res, 400) == %{"error" => "{\"email\":[\"has already been taken\"]}"}      end +    clear_config([Pleroma.Plugs.RemoteIp, :enabled]) +      test "rate limit", %{conn: conn} do        Pleroma.Config.put([Pleroma.Plugs.RemoteIp, :enabled], true)        app_token = insert(:oauth_token, user: nil) diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs index 810f371cb..781c3f7dc 100644 --- a/test/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/web/mastodon_api/controllers/status_controller_test.exs @@ -21,6 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do    clear_config([:instance, :federating])    clear_config([:instance, :allow_relay]) +  clear_config([:rich_media, :enabled])    describe "posting statuses" do      setup do: oauth_access(["write:statuses"]) @@ -1254,4 +1255,23 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do      assert [] = json_response(third_conn, 200)    end + +  test "expires_at is nil for another user" do +    %{conn: conn, user: user} = oauth_access(["read:statuses"]) +    {:ok, activity} = CommonAPI.post(user, %{"status" => "foobar", "expires_in" => 1_000_000}) + +    expires_at = +      activity.id +      |> ActivityExpiration.get_by_activity_id() +      |> Map.get(:scheduled_at) +      |> NaiveDateTime.to_iso8601() + +    assert %{"pleroma" => %{"expires_at" => ^expires_at}} = +             conn |> get("/api/v1/statuses/#{activity.id}") |> json_response(:ok) + +    %{conn: conn} = oauth_access(["read:statuses"]) + +    assert %{"pleroma" => %{"expires_at" => nil}} = +             conn |> get("/api/v1/statuses/#{activity.id}") |> json_response(:ok) +  end  end | 
