mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 17:44:43 +03:00
increase api_keys.hourly_request_limit in CE (#4200)
* increase api_keys.hourly_request_limit in CE * changelog * add tests
This commit is contained in:
parent
823f7a8800
commit
22ea56a779
@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
### Changed
|
||||
|
||||
- Increase hourly request limit for API keys in CE from 600 to 1000000 (practically removing the limit) plausible/analytics#4200
|
||||
|
||||
### Fixed
|
||||
|
||||
## v2.1.1 - 2024-06-06
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule Plausible.Auth.ApiKey do
|
||||
use Plausible
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@ -9,7 +10,7 @@ defmodule Plausible.Auth.ApiKey do
|
||||
schema "api_keys" do
|
||||
field :name, :string
|
||||
field :scopes, {:array, :string}, default: ["stats:read:*"]
|
||||
field :hourly_request_limit, :integer, default: 600
|
||||
field :hourly_request_limit, :integer, default: on_ee(do: 600, else: 1_000_000)
|
||||
|
||||
field :key, :string, virtual: true
|
||||
field :key_hash, :string
|
||||
|
@ -57,6 +57,26 @@ defmodule Plausible.AuthTest do
|
||||
assert {:ok, %Auth.ApiKey{}} = Auth.create_api_key(user, "my new key", key)
|
||||
end
|
||||
|
||||
@tag :ee_only
|
||||
test "defaults to 600 requests per hour limit in EE" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, %Auth.ApiKey{hourly_request_limit: hourly_request_limit}} =
|
||||
Auth.create_api_key(user, "my new EE key", Ecto.UUID.generate())
|
||||
|
||||
assert hourly_request_limit == 600
|
||||
end
|
||||
|
||||
@tag :ce_build_only
|
||||
test "defaults to 1000000 requests per hour limit in CE" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, %Auth.ApiKey{hourly_request_limit: hourly_request_limit}} =
|
||||
Auth.create_api_key(user, "my new CE key", Ecto.UUID.generate())
|
||||
|
||||
assert hourly_request_limit == 1_000_000
|
||||
end
|
||||
|
||||
test "errors when key already exists" do
|
||||
u1 = insert(:user)
|
||||
u2 = insert(:user)
|
||||
|
Loading…
Reference in New Issue
Block a user