瀏覽代碼

tests: add tests for signed object fetches

tags/v1.1.4
Ariadne Conill 5 年之前
父節點
當前提交
1345e0c2bf
共有 2 個文件被更改,包括 32 次插入0 次删除
  1. +2
    -0
      config/test.exs
  2. +30
    -0
      test/object/fetcher_test.exs

+ 2
- 0
config/test.exs 查看文件

@@ -31,6 +31,8 @@ config :pleroma, :instance,
skip_thread_containment: false,
federating: false

config :pleroma, :activitypub, sign_object_fetches: false

# Configure your database
config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres,


+ 30
- 0
test/object/fetcher_test.exs 查看文件

@@ -150,4 +150,34 @@ defmodule Pleroma.Object.FetcherTest do
assert object.id != object_two.id
end
end

describe "signed fetches" do
test_with_mock "it signs fetches when configured to do so",
Pleroma.Signature,
[:passthrough],
[] do
option = Pleroma.Config.get([:activitypub, :sign_object_fetches])
Pleroma.Config.put([:activitypub, :sign_object_fetches], true)

Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")

assert called(Pleroma.Signature.sign(:_, :_))

Pleroma.Config.put([:activitypub, :sign_object_fetches], option)
end

test_with_mock "it doesn't sign fetches when not configured to do so",
Pleroma.Signature,
[:passthrough],
[] do
option = Pleroma.Config.get([:activitypub, :sign_object_fetches])
Pleroma.Config.put([:activitypub, :sign_object_fetches], false)

Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")

refute called(Pleroma.Signature.sign(:_, :_))

Pleroma.Config.put([:activitypub, :sign_object_fetches], option)
end
end
end

Loading…
取消
儲存