Merge pull request 'Signatures: Only true is true.' (#7892) from bump/http-signatures-0.1.3 into develop
Reviewed-on: https://git.pleroma.social/pleroma/pleroma/pulls/7892
This commit is contained in:
commit
ffff2098f0
2 changed files with 14 additions and 1 deletions
|
|
@ -104,7 +104,7 @@ defmodule Pleroma.Signature do
|
|||
|> put_req_header("(request-target)", request_target)
|
||||
|> put_req_header("@request-target", request_target)
|
||||
|
||||
@http_signatures_impl.validate_conn(conn)
|
||||
@http_signatures_impl.validate_conn(conn) == true
|
||||
end
|
||||
|
||||
@spec validate_signature(Plug.Conn.t()) :: boolean()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ defmodule Pleroma.SignatureTest do
|
|||
import Mock
|
||||
|
||||
alias Pleroma.Signature
|
||||
alias Pleroma.StubbedHTTPSignaturesMock, as: HTTPSignaturesMock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
|
|
@ -103,6 +104,18 @@ defmodule Pleroma.SignatureTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "validate_signature/1" do
|
||||
test "treats HTTP signature errors as failed validation" do
|
||||
conn = %Plug.Conn{method: "GET", request_path: "/inbox", req_headers: []}
|
||||
|
||||
Mox.expect(HTTPSignaturesMock, :validate_conn, fn _conn ->
|
||||
{:error, :request_target_header}
|
||||
end)
|
||||
|
||||
assert Signature.validate_signature(conn) == false
|
||||
end
|
||||
end
|
||||
|
||||
describe "key_id_to_actor_id/1" do
|
||||
test "it properly deduces the actor id for misskey" do
|
||||
assert Signature.key_id_to_actor_id("https://example.com/users/1234/publickey") ==
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue