mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
REPP: Domain delete test
This commit is contained in:
parent
1461d2a566
commit
24c3962517
3 changed files with 60 additions and 4 deletions
|
@ -178,7 +178,9 @@ module Repp
|
|||
@domain = Epp::Domain.find_by(registrar: registrar, name: params[:id])
|
||||
@domain ||= Epp::Domain.find_by!(registrar: registrar, name_puny: params[:id])
|
||||
|
||||
@domain
|
||||
return @domain if @domain
|
||||
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
def set_authorized_domain
|
||||
|
@ -196,9 +198,9 @@ module Repp
|
|||
|
||||
def domain_from_url_hash
|
||||
entry = transfer_info_params[:id]
|
||||
return Domain.find(entry) if entry.match?(/\A[0-9]+\z/)
|
||||
return Epp::Domain.find(entry) if entry.match?(/\A[0-9]+\z/)
|
||||
|
||||
Domain.find_by!('name = ? OR name_puny = ?', entry, entry)
|
||||
Epp::Domain.find_by!('name = ? OR name_puny = ?', entry, entry)
|
||||
end
|
||||
|
||||
def limit
|
||||
|
|
54
test/integration/repp/v1/domains/delete_test.rb
Normal file
54
test/integration/repp/v1/domains/delete_test.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsDeleteTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
@domain = domains(:shop)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_domain_pending_delete_confirmation
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = true
|
||||
@auth_headers['Content-Type'] = 'application/json'
|
||||
|
||||
payload = {
|
||||
delete: {
|
||||
verified: false
|
||||
}
|
||||
}
|
||||
|
||||
delete "/repp/v1/domains/#{@domain.name}", headers: @auth_headers, params: payload.to_json
|
||||
@domain.reload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
end
|
||||
|
||||
def test_domain_pending_delete_on_verified_delete
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = true
|
||||
@auth_headers['Content-Type'] = 'application/json'
|
||||
|
||||
payload = {
|
||||
delete: {
|
||||
verified: true
|
||||
}
|
||||
}
|
||||
|
||||
delete "/repp/v1/domains/#{@domain.name}", headers: @auth_headers, params: payload.to_json
|
||||
@domain.reload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
refute @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsCreateTest < ActionDispatch::IntegrationTest
|
||||
class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
@domain = domains(:shop)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue