mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Merge remote-tracking branch 'origin/add-registrant-api-token-log' into add-role-filter-to-registrant-api
This commit is contained in:
commit
f60bf4013c
60 changed files with 1153 additions and 178 deletions
8
test/fixtures/contact_requests.yml
vendored
Normal file
8
test/fixtures/contact_requests.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
new:
|
||||
whois_record_id: 1
|
||||
email: aaa@bbb.com
|
||||
name: Testname
|
||||
status: new
|
||||
secret: somesecret
|
||||
valid_to: 2010-07-05
|
||||
|
153
test/integration/api/domain_admin_contacts_test.rb
Normal file
153
test/integration/api/domain_admin_contacts_test.rb
Normal file
|
@ -0,0 +1,153 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainAdminContactsTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@admin_current = domains(:shop).admin_contacts.find_by(code: 'jane-001')
|
||||
domain = domains(:airport)
|
||||
domain.admin_contacts << @admin_current
|
||||
@admin_new = contacts(:william)
|
||||
|
||||
@admin_new.update(ident: @admin_current.ident,
|
||||
ident_type: @admin_current.ident_type,
|
||||
ident_country_code: @admin_current.ident_country_code)
|
||||
end
|
||||
|
||||
def test_replace_all_admin_contacts_when_ident_data_doesnt_match
|
||||
@admin_new.update(ident: '777' ,
|
||||
ident_type: 'priv',
|
||||
ident_country_code: 'LV')
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ code: 2304, message: 'Admin contacts must be identical', data: {} }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_replace_all_admin_contacts_of_the_current_registrar
|
||||
assert @admin_new.identical_to?(@admin_current)
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_nil domains(:shop).admin_contacts.find_by(code: @admin_current.code)
|
||||
assert domains(:shop).admin_contacts.find_by(code: @admin_new.code)
|
||||
assert domains(:airport).admin_contacts.find_by(code: @admin_new.code)
|
||||
end
|
||||
|
||||
def test_skip_discarded_domains
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).admin_contacts.find_by(code: @admin_current.code)
|
||||
end
|
||||
|
||||
def test_return_affected_domains_in_alphabetical_order
|
||||
domain = domains(:airport)
|
||||
domain.admin_contacts = [@admin_current]
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000, message: 'Command completed successfully', data: { affected_domains: %w[airport.test shop.test],
|
||||
skipped_domains: [] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_return_skipped_domains_in_alphabetical_order
|
||||
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal %w[airport.test shop.test], JSON.parse(response.body,
|
||||
symbolize_names: true)[:data][:skipped_domains]
|
||||
end
|
||||
|
||||
def test_keep_other_admin_contacts_intact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).admin_contacts.find_by(code: 'john-001')
|
||||
end
|
||||
|
||||
def test_keep_tech_contacts_intact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).tech_contacts.find_by(code: 'william-001')
|
||||
end
|
||||
|
||||
def test_restrict_contacts_to_the_current_registrar
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: 'william-002' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal ({ code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_current_contact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: 'non-existent',
|
||||
new_contact_id: @admin_new.code},
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :not_found
|
||||
assert_equal ({ code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_new_contact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: 'non-existent' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :not_found
|
||||
assert_equal ({code: 2303, message: 'Object does not exist'}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_disallow_invalid_new_contact
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: 'invalid' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ code: 2304, message: 'New contact must be valid', data: {} }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_admin_bulk_changed_when_domain_update_prohibited
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
domains(:airport).admin_contacts = [@admin_current]
|
||||
|
||||
shop_admin_contact = Contact.find_by(code: 'jane-001')
|
||||
assert domains(:shop).admin_contacts.include?(shop_admin_contact)
|
||||
|
||||
patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
|
||||
new_contact_id: @admin_new.code },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { affected_domains: ["airport.test"],
|
||||
skipped_domains: ["shop.test"] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials('test_bestnames', 'testtest')
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||
|
||||
class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@api_key = "Basic #{ENV['api_shared_key']}"
|
||||
@api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}"
|
||||
@headers = { "Authorization": "#{@api_key}" }
|
||||
@json_body = { "data": valid_bounce_request }.as_json
|
||||
end
|
||||
|
|
68
test/integration/api/v1/contact_requests_test.rb
Normal file
68
test/integration/api/v1/contact_requests_test.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ApiV1ContactRequestTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}"
|
||||
@headers = { "Authorization": "#{@api_key}" }
|
||||
@json_create = { "contact_request": valid_contact_request_create }.as_json
|
||||
@json_update = { "contact_request": valid_contact_request_update }.as_json
|
||||
@contact_request = contact_requests(:new)
|
||||
end
|
||||
|
||||
def test_authorizes_api_request
|
||||
post api_v1_contact_requests_path, params: @json_create, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
invalid_headers = { "Authorization": "Basic invalid_api_key" }
|
||||
post api_v1_contact_requests_path, params: @json_create, headers: invalid_headers
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
def test_saves_new_contact_request
|
||||
request_body = @json_create.dup
|
||||
random_mail = "#{rand(10000..99999)}@registry.test"
|
||||
request_body['contact_request']['email'] = random_mail
|
||||
|
||||
post api_v1_contact_requests_path, params: request_body, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
contact_request = ContactRequest.last
|
||||
assert_equal contact_request.email, random_mail
|
||||
assert ContactRequest::STATUS_NEW, contact_request.status
|
||||
end
|
||||
|
||||
def test_updates_existing_contact_request
|
||||
request_body = @json_update.dup
|
||||
|
||||
put api_v1_contact_request_path(@contact_request.id), params: request_body, headers: @headers
|
||||
assert_response :ok
|
||||
|
||||
@contact_request.reload
|
||||
assert ContactRequest::STATUS_CONFIRMED, @contact_request.status
|
||||
end
|
||||
|
||||
def test_not_updates_if_status_error
|
||||
request_body = @json_update.dup
|
||||
request_body['contact_request']['status'] = 'some_error_status'
|
||||
|
||||
put api_v1_contact_request_path(@contact_request.id), params: request_body, headers: @headers
|
||||
assert_response 400
|
||||
|
||||
@contact_request.reload
|
||||
assert ContactRequest::STATUS_NEW, @contact_request.status
|
||||
end
|
||||
|
||||
def valid_contact_request_create
|
||||
{
|
||||
"email": "aaa@bbb.com",
|
||||
"whois_record_id": "1",
|
||||
"name": "test"
|
||||
}.as_json
|
||||
end
|
||||
|
||||
def valid_contact_request_update
|
||||
{
|
||||
"status": "#{ContactRequest::STATUS_CONFIRMED}",
|
||||
}.as_json
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ class EppContactCheckBaseTest < EppTestCase
|
|||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'john-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_contact_is_available
|
||||
|
@ -52,7 +52,8 @@ class EppContactCheckBaseTest < EppTestCase
|
|||
end
|
||||
|
||||
def test_contact_is_unavailable
|
||||
assert_equal 'john-001', @contact.code
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -98,9 +99,61 @@ class EppContactCheckBaseTest < EppTestCase
|
|||
assert_equal 3, response_xml.xpath('//contact:cd', contact: xml_schema).size
|
||||
end
|
||||
|
||||
def test_check_contact_with_prefix
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<check>
|
||||
<contact:check xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>BESTNAMES:JOHN-001</contact:id>
|
||||
</contact:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_check_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_check_contact_without_prefix
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<check>
|
||||
<contact:check xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>JOHN-001</contact:id>
|
||||
</contact:check>
|
||||
</check>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_check_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def xml_schema
|
||||
'https://epp.tld.ee/schema/contact-ee-1.1.xsd'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,60 @@ class EppContactDeleteBaseTest < EppTestCase
|
|||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_delete_contact_with_server_delete_prohibited
|
||||
contact = deletable_contact
|
||||
contact.update(statuses: Contact::SERVER_DELETE_PROHIBITED)
|
||||
assert contact.statuses.include? Contact::SERVER_DELETE_PROHIBITED
|
||||
|
||||
contact.update_columns(code: contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{contact.code.upcase}</contact:id>
|
||||
</contact:delete>
|
||||
</delete>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
assert Contact.exists?(id: contact.id)
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_delete_contact_with_client_delete_prohibited
|
||||
contact = deletable_contact
|
||||
contact.update(statuses: Contact::CLIENT_DELETE_PROHIBITED)
|
||||
assert contact.statuses.include? Contact::CLIENT_DELETE_PROHIBITED
|
||||
|
||||
contact.update_columns(code: contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<contact:delete xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{contact.code.upcase}</contact:id>
|
||||
</contact:delete>
|
||||
</delete>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
assert Contact.exists?(id: contact.id)
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_undeletable_cannot_be_deleted
|
||||
contact = contacts(:john)
|
||||
assert_not contact.deletable?
|
||||
|
@ -61,4 +115,4 @@ class EppContactDeleteBaseTest < EppTestCase
|
|||
DomainContact.delete_all
|
||||
contacts(:john)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,6 +44,58 @@ class EppContactInfoBaseTest < EppTestCase
|
|||
contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_get_info_about_contact_with_prefix
|
||||
@contact.update_columns(code: 'TEST:JOHN-001')
|
||||
assert @contact.code, 'TEST:JOHN-001'
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<info>
|
||||
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>TEST:JOHN-001</contact:id>
|
||||
</contact:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_info_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'TEST:JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_get_info_about_contact_without_prefix
|
||||
@contact.update_columns(code: "#{@contact.registrar.code}:JOHN-001".upcase)
|
||||
assert @contact.code, "#{@contact.registrar.code}:JOHN-001".upcase
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<info>
|
||||
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>JOHN-001</contact:id>
|
||||
</contact:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_info_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal "#{@contact.registrar.code}:JOHN-001".upcase, response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal '+555.555', response_xml.at_xpath('//contact:voice', contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_hides_password_and_name_when_current_registrar_is_not_sponsoring
|
||||
non_sponsoring_registrar = registrars(:goodnames)
|
||||
@contact.update!(registrar: non_sponsoring_registrar)
|
||||
|
|
|
@ -123,6 +123,46 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_domain_should_doesnt_have_pending_update_when_updated_registrant_with_same_idents_data
|
||||
assert_not @domain.statuses.include? "pendingUpdate"
|
||||
|
||||
old_registrant = @domain.registrant
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
|
||||
new_registrant.update(ident: old_registrant.ident)
|
||||
new_registrant.update(ident_country_code: old_registrant.ident_country_code)
|
||||
new_registrant.update(ident_type: old_registrant.ident_type)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant verified="no">#{new_registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
@domain.reload
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
assert_equal @domain.registrant, new_registrant
|
||||
assert_not @domain.statuses.include? "pendingUpdate"
|
||||
end
|
||||
|
||||
def test_requires_verification_from_current_registrant_when_not_yet_verified_by_registrar
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william)
|
||||
|
|
|
@ -37,6 +37,29 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_keeps_update_prohibited_status
|
||||
domain = domains(:shop)
|
||||
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
payload = {
|
||||
"domains": [
|
||||
'shop.test'
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
assert_changes -> { Domain.find_by(name: 'shop.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
assert json[:data][:updated_domains].include? 'shop.test'
|
||||
end
|
||||
domain.reload
|
||||
assert_equal domain.statuses, [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED]
|
||||
end
|
||||
|
||||
def test_throws_error_when_domain_not_renewable
|
||||
payload = {
|
||||
"domains": [
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require "test_helper"
|
||||
|
||||
class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
@ -19,6 +18,22 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
super
|
||||
end
|
||||
|
||||
def test_registrant_locked_domain
|
||||
refute @domain.locked_by_registrant?
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been locked by registrant")
|
||||
end
|
||||
|
||||
def test_registrant_unlocked_domain
|
||||
refute @domain.locked_by_registrant?
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
@domain.remove_registry_lock
|
||||
refute @domain.locked_by_registrant?
|
||||
assert_equal(@domain.registrar.notifications.last.text, "Domain #{@domain.name} has been unlocked by registrant")
|
||||
end
|
||||
|
||||
def test_rejected_registrant_verification_notifies_registrar
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
|
|
|
@ -234,6 +234,19 @@ class ForceDeleteTest < ActionMailer::TestCase
|
|||
assert_includes(@domain.statuses, asserted_status)
|
||||
end
|
||||
|
||||
def test_client_hold_prohibits_manual_inzone
|
||||
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
|
||||
@domain.update(template_name: 'legal_person')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
@domain.schedule_force_delete(type: :soft)
|
||||
travel_to Time.zone.parse('2010-08-21')
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
@domain.statuses << DomainStatus::SERVER_MANUAL_INZONE
|
||||
assert_not @domain.valid?
|
||||
end
|
||||
|
||||
def test_force_delete_soft_year_ahead_not_sets_client_hold_before_threshold
|
||||
asserted_status = DomainStatus::CLIENT_HOLD
|
||||
|
||||
|
|
|
@ -38,6 +38,20 @@ class WhiteIpTest < ActiveSupport::TestCase
|
|||
assert white_ip.valid?
|
||||
end
|
||||
|
||||
def test_validates_include_empty_ipv4
|
||||
white_ip = WhiteIp.new
|
||||
|
||||
white_ip.ipv4 = nil
|
||||
white_ip.ipv6 = '001:0db8:85a3:0000:0000:8a2e:0370:7334'
|
||||
white_ip.registrar = registrars(:bestnames)
|
||||
|
||||
assert_nothing_raised { white_ip.save }
|
||||
assert white_ip.valid?
|
||||
|
||||
assert WhiteIp.include_ip?(white_ip.ipv6)
|
||||
assert_not WhiteIp.include_ip?('192.168.1.1')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_white_ip
|
||||
|
|
49
test/system/registrar_area/bulk_change/admin_contact_test.rb
Normal file
49
test/system/registrar_area/bulk_change/admin_contact_test.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrarAreaAdminContactBulkChangeTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_replace_domain_contacts_of_current_registrar
|
||||
request_stub = stub_request(:patch, /domains\/admin_contacts/)
|
||||
.with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
|
||||
basic_auth: ['test_bestnames', 'testtest'])
|
||||
.to_return(body: { data: { affected_domains: %w[foo.test bar.test],
|
||||
skipped_domains: %w[baz.test qux.test] } }.to_json,
|
||||
status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
click_link 'Admin contact'
|
||||
|
||||
find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace admin contacts'
|
||||
|
||||
assert_requested request_stub
|
||||
assert_current_path registrar_domains_path
|
||||
assert_text 'Admin contacts have been successfully replaced'
|
||||
assert_text 'Affected domains: foo.test, bar.test'
|
||||
assert_text 'Skipped domains: baz.test, qux.test'
|
||||
end
|
||||
|
||||
def test_fails_gracefully
|
||||
stub_request(:patch, /domains\/admin_contacts/)
|
||||
.to_return(status: 400,
|
||||
body: { message: 'epic fail' }.to_json,
|
||||
headers: { 'Content-type' => Mime[:json] })
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
click_link 'Admin contact'
|
||||
|
||||
find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace admin contacts'
|
||||
|
||||
assert_text 'epic fail'
|
||||
assert_field 'Current contact ID', with: 'william-001'
|
||||
assert_field 'New contact ID', with: 'john-001'
|
||||
end
|
||||
end
|
|
@ -16,8 +16,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
|||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
fill_in 'New contact ID', with: 'john-001'
|
||||
find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace technical contacts'
|
||||
|
||||
assert_requested request_stub
|
||||
|
@ -36,8 +36,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
|||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
fill_in 'New contact ID', with: 'john-001'
|
||||
find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001'
|
||||
find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace technical contacts'
|
||||
|
||||
assert_text 'epic fail'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue