mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 19:48:28 +02:00
Merge remote-tracking branch 'origin/master' into repp-domains
This commit is contained in:
commit
e2f377f1c2
187 changed files with 1934 additions and 2552 deletions
|
@ -63,6 +63,23 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
|
||||
end
|
||||
|
||||
def test_bulk_transfer_if_domain_has_update_prohibited_status
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { success: [],
|
||||
failed: [{ type: "domain_transfer",
|
||||
domain_name: "shop.test",
|
||||
errors: [{:code=>"2304", :msg=>"Object status prohibits operation"}] }],
|
||||
}}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request_params
|
||||
|
|
|
@ -104,6 +104,25 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_bulk_namesaervers_if_domain_update_prohibited
|
||||
domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
params = { data: { type: 'nameserver', id: domains(:shop).nameservers.hostnames[0],
|
||||
attributes: { hostname: 'ns55.bestnames.test' } } }
|
||||
put '/repp/v1/registrar/nameservers', params: params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { type: "nameserver",
|
||||
id: "ns55.bestnames.test",
|
||||
attributes: {hostname: "ns55.bestnames.test"},
|
||||
affected_domains: ["airport.test"],
|
||||
skipped_domains: ["shop.test"]}}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_unauthenticated
|
||||
put '/repp/v1/registrar/nameservers'
|
||||
assert_response 401
|
||||
|
|
|
@ -5,9 +5,10 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:hospital)
|
||||
@domain = domains(:airport)
|
||||
@registrant = @domain.registrant
|
||||
@user = users(:registrant)
|
||||
domains(:metro).tech_domain_contacts.update(contact_id: @registrant.id)
|
||||
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
end
|
||||
|
||||
|
@ -19,7 +20,14 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
|
||||
assert_equal('hospital.test', domain[:name])
|
||||
assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id])
|
||||
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, domain[:registrant])
|
||||
assert_equal({:name=>"John",
|
||||
:id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
|
||||
:ident=>"1234", :ident_type=>"priv",
|
||||
:ident_country_code=>"US",
|
||||
:phone=>"+555.555",
|
||||
:email=>"john@inbox.test",
|
||||
:org=>false},
|
||||
domain[:registrant])
|
||||
assert_equal([{name: 'John',
|
||||
id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957',
|
||||
email: 'john@inbox.test'}],
|
||||
|
@ -57,6 +65,46 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
end
|
||||
|
||||
def test_return_domain_list_with_registrants_and_admins
|
||||
domains(:hospital).admin_domain_contacts.update(contact_id: contacts(:william).id)
|
||||
domains(:hospital).update(registrant: contacts(:william).becomes(Registrant))
|
||||
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_json[:domains].each do |x|
|
||||
if x[:registrant][:org] == false
|
||||
x[:tech_contacts].each do |s|
|
||||
assert_not s[:name].include?(@registrant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_return_domain_list_with_registrants_and_admins_tech
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0, 'tech' => true }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_json[:domains].each do |x|
|
||||
if x[:name] == 'metro.test'
|
||||
x[:tech_contacts].each do |s|
|
||||
assert s[:name].include?(@registrant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_domains_total_if_an_incomplete_list_is_returned
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal response_json[:domains].length, response_json[:count]
|
||||
assert_equal response_json[:total], 5
|
||||
end
|
||||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
get '/api/v1/registrant/domains', params: { 'limit' => 2, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
|
|
|
@ -130,7 +130,15 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal({ name: 'Best Names', website: 'https://bestnames.test' }, response_json[:registrar])
|
||||
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, response_json[:registrant])
|
||||
assert_equal({:name=>"John",
|
||||
:id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
|
||||
:ident=>"1234",
|
||||
:ident_type=>"priv",
|
||||
:ident_country_code=>"US",
|
||||
:phone=>"+555.555",
|
||||
:email=>"john@inbox.test",
|
||||
:org=>false},
|
||||
response_json[:registrant])
|
||||
assert_equal([{name: 'Jane',
|
||||
id: '9db3de62-2414-4487-bee2-d5c155567768',
|
||||
email: 'jane@mail.test'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -325,6 +325,104 @@ class EppContactUpdateBaseTest < EppTestCase
|
|||
assert_nil @contact.state
|
||||
end
|
||||
|
||||
def test_update_contact_with_update_prohibited
|
||||
@contact.update(statuses: [Contact::CLIENT_UPDATE_PROHIBITED])
|
||||
@contact.update_columns(code: @contact.code.upcase)
|
||||
|
||||
street = '123 Example'
|
||||
city = 'Tallinn'
|
||||
state = 'Harjumaa'
|
||||
zip = '123456'
|
||||
country_code = 'EE'
|
||||
|
||||
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>
|
||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{@contact.code}</contact:id>
|
||||
<contact:chg>
|
||||
<contact:postalInfo>
|
||||
<contact:addr>
|
||||
<contact:street>#{street}</contact:street>
|
||||
<contact:city>#{city}</contact:city>
|
||||
<contact:sp>#{state}</contact:sp>
|
||||
<contact:pc>#{zip}</contact:pc>
|
||||
<contact:cc>#{country_code}</contact:cc>
|
||||
</contact:addr>
|
||||
</contact:postalInfo>
|
||||
</contact:chg>
|
||||
</contact:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
@contact.reload
|
||||
|
||||
assert_not_equal city, @contact.city
|
||||
assert_not_equal street, @contact.street
|
||||
assert_not_equal zip, @contact.zip
|
||||
assert_not_equal country_code, @contact.country_code
|
||||
assert_not_equal state, @contact.state
|
||||
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_legal_document
|
||||
assert_equal 'john-001', @contact.code
|
||||
assert_not_equal 'new name', @contact.name
|
||||
assert_not_equal 'new-email@inbox.test', @contact.email
|
||||
assert_not_equal '+123.4', @contact.phone
|
||||
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = false
|
||||
|
||||
# https://github.com/internetee/registry/issues/415
|
||||
@contact.update_columns(code: @contact.code.upcase)
|
||||
|
||||
assert_not @contact.legal_documents.present?
|
||||
|
||||
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>
|
||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>john-001</contact:id>
|
||||
<contact:chg>
|
||||
<contact:postalInfo>
|
||||
<contact:name>new name</contact:name>
|
||||
</contact:postalInfo>
|
||||
<contact:voice>+123.4</contact:voice>
|
||||
<contact:email>new-email@inbox.test</contact:email>
|
||||
</contact:chg>
|
||||
</contact: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
|
||||
|
||||
assert_difference -> { @contact.legal_documents.reload.size } do
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
@contact.reload
|
||||
end
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'new name', @contact.name
|
||||
assert_equal 'new-email@inbox.test', @contact.email
|
||||
assert_equal '+123.4', @contact.phone
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
|
||||
|
|
|
@ -133,6 +133,40 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_deletes_on_update_prohibited
|
||||
assert_equal 'shop.test', @domain.name
|
||||
@domain.update(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = false
|
||||
|
||||
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>
|
||||
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<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
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
assert_not @domain.pending_delete_confirmation?
|
||||
assert_no_emails
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_skips_registrant_confirmation_when_required_but_already_verified_by_registrar
|
||||
assert_equal 'shop.test', @domain.name
|
||||
Setting.request_confirmation_on_domain_deletion_enabled = true
|
||||
|
|
|
@ -32,6 +32,38 @@ class EppDomainRenewBaseTest < EppTestCase
|
|||
assert_equal original_valid_to + default_renewal_period, domain.valid_to
|
||||
end
|
||||
|
||||
def test_renews_domain_if_update_prohibited
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
domain = domains(:shop)
|
||||
original_valid_to = domain.valid_to
|
||||
default_renewal_period = 1.year
|
||||
domain.statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
domain.save
|
||||
|
||||
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>
|
||||
<renew>
|
||||
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{domain.name}</domain:name>
|
||||
<domain:curExpDate>#{domain.expire_time.to_date}</domain:curExpDate>
|
||||
<domain:period unit="y">1</domain:period>
|
||||
</domain:renew>
|
||||
</renew>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_renew_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal original_valid_to + default_renewal_period, domain.valid_to
|
||||
assert domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
end
|
||||
|
||||
def test_domain_cannot_be_renewed_when_invalid
|
||||
domain = domains(:invalid)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@contact = contacts(:john)
|
||||
@original_registrant_change_verification =
|
||||
Setting.request_confirmation_on_registrant_change_enabled
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
@ -62,6 +63,27 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_prohibited_domain_cannot_be_updated
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
|
||||
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>shop.test</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_does_not_return_server_delete_prohibited_status_when_pending_update_status_is_set
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::PENDING_UPDATE])
|
||||
|
@ -123,6 +145,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)
|
||||
|
@ -225,6 +287,49 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
Setting.legal_document_is_mandatory = old_value
|
||||
end
|
||||
|
||||
# ================================================================
|
||||
def test_domain_should_not_padding_if_registrant_update_with_same_ident
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
|
||||
current = @domain.registrant
|
||||
new_registrant = contacts(:william)
|
||||
new_registrant.update(
|
||||
ident: current.ident,
|
||||
ident_type: current.ident_type,
|
||||
ident_country_code: current.ident_country_code
|
||||
)
|
||||
|
||||
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>#{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
|
||||
|
||||
# NOTE: completed_successfully_action_pending
|
||||
assert_epp_response :completed_successfully
|
||||
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
|
||||
end
|
||||
|
||||
def test_skips_verification_when_provided_registrant_is_the_same_as_current_one
|
||||
Setting.request_confirmation_on_registrant_change_enabled = true
|
||||
|
||||
|
|
|
@ -26,6 +26,31 @@ class EppPollTest < EppTestCase
|
|||
assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text
|
||||
end
|
||||
|
||||
def test_does_not_drop_error_if_old_version
|
||||
version = Version::DomainVersion.last
|
||||
@notification.update(attached_obj_type: 'DomainVersion', attached_obj_id: version.id)
|
||||
|
||||
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>
|
||||
<poll op="req"/>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
assert_nothing_raised do
|
||||
post epp_poll_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully_ack_to_dequeue
|
||||
assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count]
|
||||
assert_equal @notification.id.to_s, xml_doc.at_css('msgQ')[:id]
|
||||
assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, xml_doc.at_css('msgQ qDate').text
|
||||
assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text
|
||||
end
|
||||
|
||||
def test_return_action_data_when_present
|
||||
@notification.update!(action: actions(:contact_update))
|
||||
|
||||
|
|
14
test/integration/registrant_area/application_helper_test.rb
Normal file
14
test/integration/registrant_area/application_helper_test.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ApplicationHelperTest < ActionView::TestCase
|
||||
def test_env_style_when_pic_present
|
||||
assert_dom_equal %{<body style={"background-image: url(#{image_path("registrar/bg-#{unstable_env}.png")});"}>},
|
||||
%{<body style={"#{env_style}"}>}
|
||||
end
|
||||
|
||||
def test_env_style_return_nil
|
||||
env_style = ''
|
||||
assert_dom_equal %{<body style=''>},
|
||||
%{<body style={"#{env_style}"}>}
|
||||
end
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantAreaContactsIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@registrant = users(:registrant)
|
||||
sign_in @registrant
|
||||
end
|
||||
|
||||
def test_can_view_other_domain_contacts
|
||||
secondary_contact = contacts(:jane)
|
||||
|
||||
visit registrant_domain_path(@domain)
|
||||
assert_text secondary_contact.name
|
||||
click_link secondary_contact.name
|
||||
assert_text @domain.name
|
||||
assert_text secondary_contact.email
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantAreaDomainDeleteConfirmationIntegrationTest < ActionDispatch::IntegrationTest
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_notifies_registrant_by_email_when_accepted
|
||||
@domain.update!(registrant_verification_asked_at: Time.zone.now,
|
||||
registrant_verification_token: 'test',
|
||||
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
|
||||
patch registrant_domain_delete_confirm_path(@domain, token: 'test', confirmed: true)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
|
||||
def test_notifies_registrant_by_email_when_rejected
|
||||
@domain.update!(registrant_verification_asked_at: Time.zone.now,
|
||||
registrant_verification_token: 'test',
|
||||
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
|
||||
patch registrant_domain_delete_confirm_path(@domain, token: 'test', rejected: true)
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
sign_in users(:registrant)
|
||||
end
|
||||
|
||||
def test_downloads_list_as_csv
|
||||
get registrant_domains_path(format: :csv)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
|
||||
def test_downloads_list_as_pdf
|
||||
get registrant_domains_path(format: :pdf)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal Mime[:pdf], response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"domains.pdf\"; filename*=UTF-8''domains.pdf", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
end
|
|
@ -1,6 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
|
||||
include FormTagHelper
|
||||
|
||||
setup do
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'test_helper'
|
|||
|
||||
class ReppV1BalanceTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
@registrar = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@registrar.username}:#{@registrar.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
@ -19,4 +20,32 @@ class ReppV1BalanceTest < ActionDispatch::IntegrationTest
|
|||
assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
|
||||
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
|
||||
end
|
||||
|
||||
def test_can_query_balance_with_details
|
||||
# Create new billable action to get activity
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: { domains: ['shop.test'], renew_period: '1y' }
|
||||
|
||||
started_from = "2010-07-05"
|
||||
end_to = DateTime.current.to_date.to_s(:db)
|
||||
|
||||
get "/repp/v1/accounts/balance?detailed=true", 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]
|
||||
assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
|
||||
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
|
||||
entry = json[:data][:transactions].last
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.created_at, entry[:created_at]
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.description, entry[:description]
|
||||
assert_equal 'debit', entry[:type]
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.sum.to_s, entry[:sum]
|
||||
assert_equal @registrar.registrar.cash_account.account_activities.last.new_balance.to_s, entry[:balance]
|
||||
|
||||
json[:data][:transactions].map do |trans|
|
||||
assert trans[:created_at].to_date.to_s(:db) >= started_from
|
||||
assert trans[:created_at].to_date.to_s(:db) >= end_to
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,43 @@ 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_multi_domains_сannot_be_renewed_with_renew_prohibited_status
|
||||
array_domains = [domains(:shop), domains(:airport)]
|
||||
payload = {
|
||||
"domains": array_domains.pluck(:name),
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
array_domains.each do |domain|
|
||||
set_status_for_domain(domain, [DomainStatus::CLIENT_RENEW_PROHIBITED, DomainStatus::SERVER_RENEW_PROHIBITED])
|
||||
end
|
||||
|
||||
assert_renew_prohibited_domains(array_domains, payload)
|
||||
end
|
||||
|
||||
def test_throws_error_when_domain_not_renewable
|
||||
payload = {
|
||||
"domains": [
|
||||
|
@ -88,4 +125,36 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 2005, json[:code]
|
||||
assert_equal 'Invalid renew period', json[:message]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_status_for_domain(domain, statuses)
|
||||
domain.update(statuses: statuses)
|
||||
|
||||
if statuses.size > 1
|
||||
statuses.each do |status|
|
||||
assert domain.statuses.include? status
|
||||
end
|
||||
else
|
||||
assert domain.statuses.include? statuses
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_renew(payload)
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def assert_renew_prohibited_domains(domains, payload)
|
||||
assert_no_changes -> { Domain.where(name: domains).pluck(:valid_to) } do
|
||||
json = bulk_renew(payload)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2002, json[:code]
|
||||
assert domains.all? do |domain|
|
||||
json[:message].include? "Domain renew error for #{domain.name}"
|
||||
end
|
||||
assert json[:data].empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,6 +34,33 @@ class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest
|
|||
assert json[:data][:affected_domains].include? 'shop.test'
|
||||
end
|
||||
|
||||
def test_fails_to_update_if_prohibited
|
||||
domain = domains(:shop)
|
||||
domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED])
|
||||
nameserver = nameservers(:shop_ns1)
|
||||
payload = {
|
||||
"data": {
|
||||
"id": nameserver.hostname,
|
||||
"type": "nameserver",
|
||||
"attributes": {
|
||||
"hostname": "#{nameserver.hostname}.test",
|
||||
"ipv4": ["1.1.1.1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put '/repp/v1/registrar/nameservers', 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_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
|
||||
assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
|
||||
assert json[:data][:affected_domains].include? 'airport.test'
|
||||
assert json[:data][:skipped_domains].include? 'shop.test'
|
||||
end
|
||||
|
||||
def test_nameserver_with_hostname_must_exist
|
||||
payload = {
|
||||
"data": {
|
||||
|
|
|
@ -21,7 +21,7 @@ class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
|
|||
status: 'reserved',
|
||||
punycode_name: 'reserved.test' }]
|
||||
|
||||
assert_equal response_json[:domains], expected_objects
|
||||
assert_empty response_json[:domains] - expected_objects
|
||||
end
|
||||
|
||||
def test_get_index_with_type_parameter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue