mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-10-30 21:41:16 +00:00
98cb255d12
OTP builds to 1.15
Changelog entry
Ensure policies are fully loaded
Fix :warn
use main branch for linkify
Fix warn in tests
Migrations for phoenix 1.17
Revert "Migrations for phoenix 1.17"
This reverts commit 6a3b2f15b7
.
Oban upgrade
Add default empty whitelist
mix format
limit test to amd64
OTP 26 tests for 1.15
use OTP_VERSION tag
baka
just 1.15
Massive deps update
Update locale, deps
Mix format
shell????
multiline???
?
max cases 1
use assert_recieve
don't put_env in async tests
don't async conn/fs tests
mix format
FIx some uploader issues
Fix tests
69 lines
1.9 KiB
Elixir
69 lines
1.9 KiB
Elixir
# Akkoma: Magically expressive social media
|
|
# Copyright © 2022-2022 Akkoma Authors <https://akkoma.dev/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Web.Plugs.EnsureHTTPSignaturePlugTest do
|
|
use Pleroma.Web.ConnCase, async: false
|
|
alias Pleroma.Web.Plugs.EnsureHTTPSignaturePlug
|
|
|
|
import Plug.Conn
|
|
import Phoenix.Controller, only: [put_format: 2]
|
|
|
|
import Pleroma.Tests.Helpers, only: [clear_config: 2]
|
|
|
|
describe "requires a signature when `authorized_fetch_mode` is enabled" do
|
|
setup do
|
|
clear_config([:activitypub, :authorized_fetch_mode], true)
|
|
|
|
conn =
|
|
build_conn(:get, "/doesntmatter")
|
|
|> put_format("activity+json")
|
|
|
|
[conn: conn]
|
|
end
|
|
|
|
test "and signature has been set as invalid", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> assign(:valid_signature, false)
|
|
|> EnsureHTTPSignaturePlug.call(%{})
|
|
|
|
assert conn.halted == true
|
|
assert conn.status == 401
|
|
assert conn.state == :sent
|
|
assert conn.resp_body == "Request not signed"
|
|
end
|
|
|
|
test "and signature has been set as valid", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> assign(:valid_signature, true)
|
|
|> EnsureHTTPSignaturePlug.call(%{})
|
|
|
|
assert conn.halted == false
|
|
end
|
|
|
|
test "does nothing for non-ActivityPub content types", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> assign(:valid_signature, false)
|
|
|> put_format("html")
|
|
|> EnsureHTTPSignaturePlug.call(%{})
|
|
|
|
assert conn.halted == false
|
|
end
|
|
end
|
|
|
|
test "does nothing on invalid signature when `authorized_fetch_mode` is disabled" do
|
|
clear_config([:activitypub, :authorized_fetch_mode], false)
|
|
|
|
conn =
|
|
build_conn(:get, "/doesntmatter")
|
|
|> put_format("activity+json")
|
|
|> assign(:valid_signature, false)
|
|
|> EnsureHTTPSignaturePlug.call(%{})
|
|
|
|
assert conn.halted == false
|
|
end
|
|
end
|