Fix webhook create test expectations
This commit is contained in:
parent
83dcc4ae36
commit
afe33bcc44
3 changed files with 15 additions and 14 deletions
|
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.AdminAPI.WebhookControllerTest do
|
||||||
|
|
||||||
describe "PATCH /api/pleroma/admin/webhooks" do
|
describe "PATCH /api/pleroma/admin/webhooks" do
|
||||||
test "edits a webhook", %{conn: conn} do
|
test "edits a webhook", %{conn: conn} do
|
||||||
%{id: id} =
|
{:ok, %{id: id}} =
|
||||||
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
@ -66,7 +66,7 @@ defmodule Pleroma.Web.AdminAPI.WebhookControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "can't edit an internal webhook", %{conn: conn} do
|
test "can't edit an internal webhook", %{conn: conn} do
|
||||||
%{id: id} =
|
{:ok, %{id: id}} =
|
||||||
Webhook.create(%{url: "https://example.com/webhook1", events: [], internal: true})
|
Webhook.create(%{url: "https://example.com/webhook1", events: [], internal: true})
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
@ -82,7 +82,7 @@ defmodule Pleroma.Web.AdminAPI.WebhookControllerTest do
|
||||||
|
|
||||||
describe "DELETE /api/pleroma/admin/webhooks" do
|
describe "DELETE /api/pleroma/admin/webhooks" do
|
||||||
test "deletes a webhook", %{conn: conn} do
|
test "deletes a webhook", %{conn: conn} do
|
||||||
%{id: id} =
|
{:ok, %{id: id}} =
|
||||||
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ defmodule Pleroma.Webhook.NotifyTest do
|
||||||
test "notifies have a valid signature" do
|
test "notifies have a valid signature" do
|
||||||
activity = insert(:report_activity)
|
activity = insert(:report_activity)
|
||||||
|
|
||||||
%{secret: secret} =
|
{:ok, %{secret: secret} = webhook} =
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
||||||
|
|
||||||
Tesla.Mock.mock(fn %{url: "https://example.com/webhook", body: body, headers: headers} = _ ->
|
Tesla.Mock.mock(fn %{url: "https://example.com/webhook", body: body, headers: headers} = _ ->
|
||||||
{"X-Hub-Signature", "sha256=" <> signature} =
|
{"X-Hub-Signature", "sha256=" <> signature} =
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,15 @@ defmodule Pleroma.WebhookTest do
|
||||||
alias Pleroma.Webhook
|
alias Pleroma.Webhook
|
||||||
|
|
||||||
test "creating a webhook" do
|
test "creating a webhook" do
|
||||||
%{id: id} = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
{:ok, %{id: id}} =
|
||||||
|
Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
||||||
|
|
||||||
assert %{url: "https://example.com/webhook"} = Webhook.get(id)
|
assert %{url: "https://example.com/webhook"} = Webhook.get(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "editing a webhook" do
|
test "editing a webhook" do
|
||||||
%{id: id} =
|
{:ok, %{id: id} = webhook} =
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
||||||
|
|
||||||
Webhook.update(webhook, %{events: [:"account.created"]})
|
Webhook.update(webhook, %{events: [:"account.created"]})
|
||||||
|
|
||||||
|
|
@ -23,10 +24,10 @@ defmodule Pleroma.WebhookTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "filter webhooks by type" do
|
test "filter webhooks by type" do
|
||||||
%{id: id1} =
|
{:ok, %{id: id1}} =
|
||||||
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook1", events: [:"report.created"]})
|
||||||
|
|
||||||
%{id: id2} =
|
{:ok, %{id: id2}} =
|
||||||
Webhook.create(%{
|
Webhook.create(%{
|
||||||
url: "https://example.com/webhook2",
|
url: "https://example.com/webhook2",
|
||||||
events: [:"account.created", :"report.created"]
|
events: [:"account.created", :"report.created"]
|
||||||
|
|
@ -38,16 +39,16 @@ defmodule Pleroma.WebhookTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "change webhook state" do
|
test "change webhook state" do
|
||||||
%{id: id, enabled: true} =
|
{:ok, %{id: id, enabled: true} = webhook} =
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
||||||
|
|
||||||
Webhook.set_enabled(webhook, false)
|
Webhook.set_enabled(webhook, false)
|
||||||
assert %{enabled: false} = Webhook.get(id)
|
assert %{enabled: false} = Webhook.get(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rotate webhook secrets" do
|
test "rotate webhook secrets" do
|
||||||
%{id: id, secret: secret} =
|
{:ok, %{id: id, secret: secret} = webhook} =
|
||||||
webhook = Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
Webhook.create(%{url: "https://example.com/webhook", events: [:"report.created"]})
|
||||||
|
|
||||||
Webhook.rotate_secret(webhook)
|
Webhook.rotate_secret(webhook)
|
||||||
%{secret: new_secret} = Webhook.get(id)
|
%{secret: new_secret} = Webhook.get(id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue