wip test
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
f3825b676a
commit
c2f3242177
3 changed files with 35 additions and 5 deletions
|
@ -727,7 +727,8 @@
|
|||
status_id_action: {60_000, 3},
|
||||
password_reset: {1_800_000, 5},
|
||||
account_confirmation_resend: {8_640_000, 5},
|
||||
ap_routes: {60_000, 15}
|
||||
ap_routes: {60_000, 15},
|
||||
bites: {10_000, 10}
|
||||
|
||||
config :pleroma, Pleroma.Workers.PurgeExpiredActivity, enabled: true, min_lifetime: 600
|
||||
|
||||
|
|
|
@ -9,14 +9,13 @@ defmodule Pleroma.Web.MastodonAPI.BiteController do
|
|||
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||
# alias Pleroma.Web.Plugs.RateLimiter
|
||||
alias Pleroma.Web.Plugs.RateLimiter
|
||||
|
||||
plug(Pleroma.Web.ApiSpec.CastAndValidate, replace_params: false)
|
||||
|
||||
plug(OAuthScopesPlug, %{scopes: ["write:bite"]} when action == :bite)
|
||||
plug(OAuthScopesPlug, %{scopes: ["write:bites"]} when action == :bite)
|
||||
|
||||
# plug(RateLimiter, [name: :relations_actions] when action in @relationship_actions)
|
||||
# plug(RateLimiter, [name: :app_account_creation] when action == :create)
|
||||
plug(RateLimiter, [name: :bites])
|
||||
|
||||
plug(:assign_account_by_id)
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2024 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.MastodonAPI.BiteControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do: oauth_access(["write:bites"])
|
||||
|
||||
test "bites a user", %{conn: conn} do
|
||||
%{id: bitten_id} = insert(:user)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/api/v1/bite?id=#{bitten_id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response == %{}
|
||||
end
|
||||
|
||||
test "self harm is not supported", %{conn: conn, user: %{id: self_id}} do
|
||||
response =
|
||||
conn
|
||||
|> post("/api/v1/bite?id=#{self_id}")
|
||||
|> json_response_and_validate_schema(400)
|
||||
|
||||
assert %{"error" => "Can not bite yourself"} = response
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue