mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 22:29:38 +02:00
Remove rate limit for api test cases
This commit is contained in:
parent
fe8aebe920
commit
afbfb474c2
1 changed files with 24 additions and 3 deletions
|
@ -8,8 +8,29 @@ class Api::V1::TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||||
@family = @user.family
|
@family = @user.family
|
||||||
@account = @family.accounts.first
|
@account = @family.accounts.first
|
||||||
@transaction = @family.transactions.first
|
@transaction = @family.transactions.first
|
||||||
@api_key = api_keys(:active_key) # Has read_write scope
|
|
||||||
@read_only_api_key = api_keys(:one) # Has read scope
|
# Destroy existing active API keys to avoid validation errors
|
||||||
|
@user.api_keys.active.destroy_all
|
||||||
|
|
||||||
|
# Create fresh API keys instead of using fixtures to avoid parallel test conflicts (rate limiting in test)
|
||||||
|
@api_key = ApiKey.create!(
|
||||||
|
user: @user,
|
||||||
|
name: "Test Read-Write Key",
|
||||||
|
scopes: [ "read_write" ],
|
||||||
|
display_key: "test_rw_#{SecureRandom.hex(8)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
@read_only_api_key = ApiKey.create!(
|
||||||
|
user: @user,
|
||||||
|
name: "Test Read-Only Key",
|
||||||
|
scopes: [ "read" ],
|
||||||
|
display_key: "test_ro_#{SecureRandom.hex(8)}",
|
||||||
|
source: "mobile" # Use different source to allow multiple keys
|
||||||
|
)
|
||||||
|
|
||||||
|
# Clear any existing rate limit data
|
||||||
|
Redis.new.del("api_rate_limit:#{@api_key.id}")
|
||||||
|
Redis.new.del("api_rate_limit:#{@read_only_api_key.id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# INDEX action tests
|
# INDEX action tests
|
||||||
|
@ -335,6 +356,6 @@ end
|
||||||
private
|
private
|
||||||
|
|
||||||
def api_headers(api_key)
|
def api_headers(api_key)
|
||||||
{ "X-Api-Key" => api_key.plain_key }
|
{ "X-Api-Key" => api_key.display_key }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue