mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
Covered with tests api users and white ips
This commit is contained in:
parent
9cbf9f88bf
commit
a4d28a0ee2
14 changed files with 618 additions and 4 deletions
49
test/integration/repp/v1/api_users/delete_test.rb
Normal file
49
test/integration/repp/v1/api_users/delete_test.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ApiUsersDeleteTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
|
||||
adapter = ENV['shunter_default_adapter'].constantize.new
|
||||
adapter&.clear!
|
||||
end
|
||||
|
||||
def test_deletes_api_user
|
||||
epp_user = users(:api_bestnames_epp)
|
||||
delete "/repp/v1/api_users/#{epp_user.id}", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
refute ApiUser.exists?(epp_user.id)
|
||||
end
|
||||
|
||||
def test_cannot_delete_api_user
|
||||
delete '/repp/v1/api_users/wrong_id', headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal 2303, json[:code]
|
||||
assert_equal 'Object does not exist', json[:message]
|
||||
end
|
||||
|
||||
def test_returns_error_response_if_throttled
|
||||
ENV['shunter_default_threshold'] = '1'
|
||||
ENV['shunter_enabled'] = 'true'
|
||||
|
||||
delete "/repp/v1/api_users/#{users(:api_bestnames_epp).id}", headers: @auth_headers
|
||||
delete "/repp/v1/api_users/#{users(:api_bestnames).id}", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal json[:code], 2502
|
||||
assert response.body.include?(Shunter.default_error_message)
|
||||
ENV['shunter_default_threshold'] = '10000'
|
||||
ENV['shunter_enabled'] = 'false'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue