diff options
Diffstat (limited to 'test/support')
| -rw-r--r-- | test/support/api_spec_helpers.ex | 6 | ||||
| -rw-r--r-- | test/support/builders/activity_builder.ex | 4 | ||||
| -rw-r--r-- | test/support/builders/user_builder.ex | 4 | ||||
| -rw-r--r-- | test/support/cachex_proxy.ex | 2 | ||||
| -rw-r--r-- | test/support/captcha/mock.ex | 2 | ||||
| -rw-r--r-- | test/support/channel_case.ex | 2 | ||||
| -rw-r--r-- | test/support/cluster.ex | 4 | ||||
| -rw-r--r-- | test/support/conn_case.ex | 6 | ||||
| -rw-r--r-- | test/support/data_case.ex | 2 | ||||
| -rw-r--r-- | test/support/factory.ex | 134 | ||||
| -rw-r--r-- | test/support/helpers.ex | 5 | ||||
| -rw-r--r-- | test/support/http_request_mock.ex | 177 | ||||
| -rw-r--r-- | test/support/mocks.ex | 2 | ||||
| -rw-r--r-- | test/support/mrf_module_mock.ex | 4 | ||||
| -rw-r--r-- | test/support/null_cache.ex | 2 | ||||
| -rw-r--r-- | test/support/oban_helpers.ex | 2 | ||||
| -rw-r--r-- | test/support/websocket_client.ex | 34 | 
17 files changed, 329 insertions, 63 deletions
| diff --git a/test/support/api_spec_helpers.ex b/test/support/api_spec_helpers.ex index 36d6a8b81..df5132357 100644 --- a/test/support/api_spec_helpers.ex +++ b/test/support/api_spec_helpers.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Tests.ApiSpecHelpers do @@ -29,9 +29,7 @@ defmodule Pleroma.Tests.ApiSpecHelpers do            end)          flunk( -          "Value does not conform to schema #{schema.title}: #{Enum.join(errors, "\n")}\n#{ -            inspect(value) -          }" +          "Value does not conform to schema #{schema.title}: #{Enum.join(errors, "\n")}\n#{inspect(value)}"          )      end    end diff --git a/test/support/builders/activity_builder.ex b/test/support/builders/activity_builder.ex index 7c4950bfa..f1ca3951b 100644 --- a/test/support/builders/activity_builder.ex +++ b/test/support/builders/activity_builder.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only +  defmodule Pleroma.Builders.ActivityBuilder do    alias Pleroma.Web.ActivityPub.ActivityPub diff --git a/test/support/builders/user_builder.ex b/test/support/builders/user_builder.ex index 6bccbb35a..d6af30612 100644 --- a/test/support/builders/user_builder.ex +++ b/test/support/builders/user_builder.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only +  defmodule Pleroma.Builders.UserBuilder do    alias Pleroma.Repo    alias Pleroma.User diff --git a/test/support/cachex_proxy.ex b/test/support/cachex_proxy.ex index de1f1c766..83ae5610f 100644 --- a/test/support/cachex_proxy.ex +++ b/test/support/cachex_proxy.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.CachexProxy do diff --git a/test/support/captcha/mock.ex b/test/support/captcha/mock.ex index 175ade131..53e000ed6 100644 --- a/test/support/captcha/mock.ex +++ b/test/support/captcha/mock.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Captcha.Mock do diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index 1fbf6f100..8cb23f5ab 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Web.ChannelCase do diff --git a/test/support/cluster.ex b/test/support/cluster.ex index 524194cf4..1c923fb0c 100644 --- a/test/support/cluster.ex +++ b/test/support/cluster.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only +  defmodule Pleroma.Cluster do    @moduledoc """    Facilities for managing a cluster of slave VM's for federated testing. diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index deee98599..f010fec33 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Web.ConnCase do @@ -102,9 +102,7 @@ defmodule Pleroma.Web.ConnCase do                end)              flunk( -              "Response does not conform to schema of #{op_id} operation: #{ -                Enum.join(errors, "\n") -              }\n#{inspect(json)}" +              "Response does not conform to schema of #{op_id} operation: #{Enum.join(errors, "\n")}\n#{inspect(json)}"              )          end        end diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 0ee2aa4a2..3c9cab061 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.DataCase do diff --git a/test/support/factory.ex b/test/support/factory.ex index 5c4e65c81..d94544717 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Factory do @@ -10,6 +10,15 @@ defmodule Pleroma.Factory do    alias Pleroma.Object    alias Pleroma.User +  @rsa_keys [ +              "test/fixtures/rsa_keys/key_1.pem", +              "test/fixtures/rsa_keys/key_2.pem", +              "test/fixtures/rsa_keys/key_3.pem", +              "test/fixtures/rsa_keys/key_4.pem", +              "test/fixtures/rsa_keys/key_5.pem" +            ] +            |> Enum.map(&File.read!/1) +    def participation_factory do      conversation = insert(:conversation)      user = insert(:user) @@ -28,6 +37,8 @@ defmodule Pleroma.Factory do    end    def user_factory(attrs \\ %{}) do +    pem = Enum.random(@rsa_keys) +      user = %User{        name: sequence(:name, &"Test テスト User #{&1}"),        email: sequence(:email, &"user#{&1}@example.com"), @@ -39,7 +50,7 @@ defmodule Pleroma.Factory do        last_refreshed_at: NaiveDateTime.utc_now(),        notification_settings: %Pleroma.User.NotificationSetting{},        multi_factor_authentication_settings: %Pleroma.MFA.Settings{}, -      ap_enabled: true +      keys: pem      }      urls = @@ -111,6 +122,18 @@ defmodule Pleroma.Factory do      }    end +  def attachment_factory(attrs \\ %{}) do +    user = attrs[:user] || insert(:user) + +    data = +      attachment_data(user.ap_id, nil) +      |> Map.put("id", Pleroma.Web.ActivityPub.Utils.generate_object_id()) + +    %Pleroma.Object{ +      data: merge_attributes(data, Map.get(attrs, :data, %{})) +    } +  end +    def attachment_note_factory(attrs \\ %{}) do      user = attrs[:user] || insert(:user)      {length, attrs} = Map.pop(attrs, :length, 1) @@ -142,6 +165,11 @@ defmodule Pleroma.Factory do      }    end +  def followers_only_note_factory(attrs \\ %{}) do +    %Pleroma.Object{data: data} = note_factory(attrs) +    %Pleroma.Object{data: Map.merge(data, %{"to" => [data["actor"] <> "/followers"]})} +  end +    def audio_factory(attrs \\ %{}) do      text = sequence(:text, &"lain radio episode #{&1}") @@ -191,8 +219,8 @@ defmodule Pleroma.Factory do    end    def article_factory do -    note_factory() -    |> Map.put("type", "Article") +    %Pleroma.Object{data: data} = note_factory() +    %Pleroma.Object{data: Map.merge(data, %{"type" => "Article"})}    end    def tombstone_factory do @@ -208,6 +236,38 @@ defmodule Pleroma.Factory do      }    end +  def question_factory(attrs \\ %{}) do +    user = attrs[:user] || insert(:user) + +    data = %{ +      "id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(), +      "type" => "Question", +      "actor" => user.ap_id, +      "attributedTo" => user.ap_id, +      "attachment" => [], +      "to" => ["https://www.w3.org/ns/activitystreams#Public"], +      "cc" => [user.follower_address], +      "context" => Pleroma.Web.ActivityPub.Utils.generate_context_id(), +      "closed" => DateTime.utc_now() |> DateTime.add(86_400) |> DateTime.to_iso8601(), +      "oneOf" => [ +        %{ +          "type" => "Note", +          "name" => "chocolate", +          "replies" => %{"totalItems" => 0, "type" => "Collection"} +        }, +        %{ +          "type" => "Note", +          "name" => "vanilla", +          "replies" => %{"totalItems" => 0, "type" => "Collection"} +        } +      ] +    } + +    %Pleroma.Object{ +      data: merge_attributes(data, Map.get(attrs, :data, %{})) +    } +  end +    def direct_note_activity_factory do      dm = insert(:direct_note) @@ -267,6 +327,33 @@ defmodule Pleroma.Factory do      |> Map.merge(attrs)    end +  def followers_only_note_activity_factory(attrs \\ %{}) do +    user = attrs[:user] || insert(:user) +    note = insert(:followers_only_note, user: user) + +    data_attrs = attrs[:data_attrs] || %{} +    attrs = Map.drop(attrs, [:user, :note, :data_attrs]) + +    data = +      %{ +        "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), +        "type" => "Create", +        "actor" => note.data["actor"], +        "to" => note.data["to"], +        "object" => note.data, +        "published" => DateTime.utc_now() |> DateTime.to_iso8601(), +        "context" => note.data["context"] +      } +      |> Map.merge(data_attrs) + +    %Pleroma.Activity{ +      data: data, +      actor: data["actor"], +      recipients: data["to"] +    } +    |> Map.merge(attrs) +  end +    def note_activity_factory(attrs \\ %{}) do      user = attrs[:user] || insert(:user)      note = attrs[:note] || insert(:note, user: user) @@ -396,6 +483,33 @@ defmodule Pleroma.Factory do      }    end +  def question_activity_factory(attrs \\ %{}) do +    user = attrs[:user] || insert(:user) +    question = attrs[:question] || insert(:question, user: user) + +    data_attrs = attrs[:data_attrs] || %{} +    attrs = Map.drop(attrs, [:user, :question, :data_attrs]) + +    data = +      %{ +        "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), +        "type" => "Create", +        "actor" => question.data["actor"], +        "to" => question.data["to"], +        "object" => question.data["id"], +        "published" => DateTime.utc_now() |> DateTime.to_iso8601(), +        "context" => question.data["context"] +      } +      |> Map.merge(data_attrs) + +    %Pleroma.Activity{ +      data: data, +      actor: data["actor"], +      recipients: data["to"] +    } +    |> Map.merge(attrs) +  end +    def oauth_app_factory do      %Pleroma.Web.OAuth.App{        client_name: sequence(:client_name, &"Some client #{&1}"), @@ -536,4 +650,16 @@ defmodule Pleroma.Factory do        context: ["home"]      }    end + +  def announcement_factory(params \\ %{}) do +    data = Map.get(params, :data, %{}) + +    {_, params} = Map.pop(params, :data) + +    %Pleroma.Announcement{ +      data: Map.merge(%{"content" => "test announcement", "all_day" => false}, data) +    } +    |> Map.merge(params) +    |> Pleroma.Announcement.add_rendered_properties() +  end  end diff --git a/test/support/helpers.ex b/test/support/helpers.ex index 856a6a376..0bd487f39 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Tests.Helpers do @@ -42,8 +42,7 @@ defmodule Pleroma.Tests.Helpers do      # Displaying a warning to prevent unintentional clearing of all but one keys in section      if Keyword.keyword?(temp_setting) and length(temp_setting) == 1 do        Logger.warn( -        "Please change to `clear_config([section]); clear_config([section, key], value)`: " <> -          "#{inspect(config_path)}, #{inspect(temp_setting)}" +        "Please change `clear_config([section], key: value)` to `clear_config([section, key], value)`"        )      end diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex index 8807c2d14..b0cf613ac 100644 --- a/test/support/http_request_mock.ex +++ b/test/support/http_request_mock.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule HttpRequestMock do @@ -424,14 +424,6 @@ defmodule HttpRequestMock do      {:error, :nxdomain}    end -  def get("http://osada.macgirvin.com/.well-known/host-meta", _, _, _) do -    {:ok, -     %Tesla.Env{ -       status: 404, -       body: "" -     }} -  end -    def get("https://osada.macgirvin.com/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{ @@ -725,6 +717,15 @@ defmodule HttpRequestMock do       }}    end +  def get( +        "https://mastodon.social/.well-known/webfinger?resource=acct:not_found@mastodon.social", +        _, +        _, +        [{"accept", "application/xrd+xml,application/jrd+json"}] +      ) do +    {:ok, %Tesla.Env{status: 404}} +  end +    def get("http://gs.example.org/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{ @@ -756,7 +757,7 @@ defmodule HttpRequestMock do      {:ok, %Tesla.Env{status: 406, body: ""}}    end -  def get("http://squeet.me/.well-known/host-meta", _, _, _) do +  def get("https://squeet.me/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/squeet.me_host_meta")}}    end @@ -797,7 +798,7 @@ defmodule HttpRequestMock do      {:ok, %Tesla.Env{status: 200, body: "", headers: [{"content-type", "application/jrd+json"}]}}    end -  def get("http://framatube.org/.well-known/host-meta", _, _, _) do +  def get("https://framatube.org/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{         status: 200, @@ -806,7 +807,7 @@ defmodule HttpRequestMock do    end    def get( -        "http://framatube.org/main/xrd?uri=acct:framasoft@framatube.org", +        "https://framatube.org/main/xrd?uri=acct:framasoft@framatube.org",          _,          _,          [{"accept", "application/xrd+xml,application/jrd+json"}] @@ -841,7 +842,7 @@ defmodule HttpRequestMock do       }}    end -  def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do +  def get("https://status.alpicola.com/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{         status: 200, @@ -849,7 +850,7 @@ defmodule HttpRequestMock do       }}    end -  def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do +  def get("https://macgirvin.com/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{         status: 200, @@ -857,7 +858,7 @@ defmodule HttpRequestMock do       }}    end -  def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do +  def get("https://gerzilla.de/.well-known/host-meta", _, _, _) do      {:ok,       %Tesla.Env{         status: 200, @@ -1075,6 +1076,14 @@ defmodule HttpRequestMock do       }}    end +  def get("https://404.site" <> _, _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 404, +       body: "" +     }} +  end +    def get(          "https://zetsubou.xn--q9jyb4c/.well-known/webfinger?resource=acct:lain@zetsubou.xn--q9jyb4c",          _, @@ -1124,6 +1133,57 @@ defmodule HttpRequestMock do       }}    end +  def get("http://lm.kazv.moe/.well-known/host-meta", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta") +     }} +  end + +  def get("https://lm.kazv.moe/.well-known/host-meta", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta") +     }} +  end + +  def get( +        "https://lm.kazv.moe/.well-known/webfinger?resource=acct:mewmew@lm.kazv.moe", +        _, +        _, +        [{"accept", "application/xrd+xml,application/jrd+json"}] +      ) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/https___lm.kazv.moe_users_mewmew.xml"), +       headers: [{"content-type", "application/xrd+xml"}] +     }} +  end + +  def get("https://lm.kazv.moe/users/mewmew", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/mewmew@lm.kazv.moe.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://lm.kazv.moe/users/mewmew/collections/featured", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: +         File.read!("test/fixtures/users_mock/masto_featured.json") +         |> String.replace("{{domain}}", "lm.kazv.moe") +         |> String.replace("{{nickname}}", "mewmew"), +       headers: [{"content-type", "application/activity+json"}] +     }} +  end +    def get("https://info.pleroma.site/activity.json", _, _, [          {"accept", "application/activity+json"}        ]) do @@ -1311,11 +1371,84 @@ defmodule HttpRequestMock do       }}    end +  def get("https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/gleasonator-AG3RzWfwEKKrY63qj2.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://gleasonator.com/users/macgirvin", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/macgirvin@gleasonator.com.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://gleasonator.com/users/macgirvin/collections/featured", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: +         File.read!("test/fixtures/users_mock/masto_featured.json") +         |> String.replace("{{domain}}", "gleasonator.com") +         |> String.replace("{{nickname}}", "macgirvin"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://mk.absturztau.be/users/8ozbzjs3o8", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/mametsuko@mk.absturztau.be.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://p.helene.moe/users/helene", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/helene@p.helene.moe.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://mk.absturztau.be/notes/93e7nm8wqg", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/mk.absturztau.be-93e7nm8wqg.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://mk.absturztau.be/notes/93e7nm8wqg/activity", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/mk.absturztau.be-93e7nm8wqg-activity.json"), +       headers: activitypub_object_headers() +     }} +  end + +  def get("https://p.helene.moe/objects/fd5910ac-d9dc-412e-8d1d-914b203296c4", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/tesla_mock/p.helene.moe-AM7S6vZQmL6pI9TgPY.json"), +       headers: activitypub_object_headers() +     }} +  end +    def get(url, query, body, headers) do      {:error, -     "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{ -       inspect(headers) -     }"} +     "Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}    end    # POST Requests @@ -1381,9 +1514,7 @@ defmodule HttpRequestMock do    def post(url, query, body, headers) do      {:error, -     "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{ -       inspect(headers) -     }"} +     "Mock response not implemented for POST #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}    end    # Most of the rich media mocks are missing HEAD requests, so we just return 404. @@ -1398,8 +1529,6 @@ defmodule HttpRequestMock do    def head(url, query, body, headers) do      {:error, -     "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{ -       inspect(headers) -     }"} +     "Mock response not implemented for HEAD #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}    end  end diff --git a/test/support/mocks.ex b/test/support/mocks.ex index fd8f825b3..d167996bd 100644 --- a/test/support/mocks.ex +++ b/test/support/mocks.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  Mox.defmock(Pleroma.CachexMock, for: Pleroma.Caching) diff --git a/test/support/mrf_module_mock.ex b/test/support/mrf_module_mock.ex index 4dfdeb3b4..616fc720e 100644 --- a/test/support/mrf_module_mock.ex +++ b/test/support/mrf_module_mock.ex @@ -1,9 +1,9 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule MRFModuleMock do -  @behaviour Pleroma.Web.ActivityPub.MRF +  @behaviour Pleroma.Web.ActivityPub.MRF.Policy    @impl true    def filter(message), do: {:ok, message} diff --git a/test/support/null_cache.ex b/test/support/null_cache.ex index 47c10ebb6..9f1d45f1d 100644 --- a/test/support/null_cache.ex +++ b/test/support/null_cache.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.NullCache do diff --git a/test/support/oban_helpers.ex b/test/support/oban_helpers.ex index 9b6e5256e..94170a0f8 100644 --- a/test/support/oban_helpers.ex +++ b/test/support/oban_helpers.ex @@ -1,5 +1,5 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Tests.ObanHelpers do diff --git a/test/support/websocket_client.ex b/test/support/websocket_client.ex index 34b955474..7163bbd41 100644 --- a/test/support/websocket_client.ex +++ b/test/support/websocket_client.ex @@ -1,22 +1,21 @@  # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>  # SPDX-License-Identifier: AGPL-3.0-only  defmodule Pleroma.Integration.WebsocketClient do    # https://github.com/phoenixframework/phoenix/blob/master/test/support/websocket_client.exs +  use WebSockex +    @doc """    Starts the WebSocket server for given ws URL. Received Socket.Message's    are forwarded to the sender pid    """    def start_link(sender, url, headers \\ []) do -    :crypto.start() -    :ssl.start() - -    :websocket_client.start_link( -      String.to_charlist(url), +    WebSockex.start_link( +      url,        __MODULE__, -      [sender], +      %{sender: sender},        extra_headers: headers      )    end @@ -36,27 +35,32 @@ defmodule Pleroma.Integration.WebsocketClient do    end    @doc false -  def init([sender], _conn_state) do -    {:ok, %{sender: sender}} +  @impl true +  def handle_frame(frame, state) do +    send(state.sender, frame) +    {:ok, state}    end -  @doc false -  def websocket_handle(frame, _conn_state, state) do -    send(state.sender, frame) +  @impl true +  def handle_disconnect(conn_status, state) do +    send(state.sender, {:close, conn_status})      {:ok, state}    end    @doc false -  def websocket_info({:text, msg}, _conn_state, state) do +  @impl true +  def handle_info({:text, msg}, state) do      {:reply, {:text, msg}, state}    end -  def websocket_info(:close, _conn_state, _state) do +  @impl true +  def handle_info(:close, _state) do      {:close, <<>>, "done"}    end    @doc false -  def websocket_terminate(_reason, _conn_state, _state) do +  @impl true +  def terminate(_reason, _state) do      :ok    end  end | 
