mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 23:54:44 +02:00
Include tests for EPP contact create/update actions regarding to addressing
This commit is contained in:
parent
8f8b246e49
commit
e40353042e
3 changed files with 205 additions and 0 deletions
|
@ -7,6 +7,7 @@ module Epp
|
||||||
KEY_TO_VALUE = {
|
KEY_TO_VALUE = {
|
||||||
completed_successfully: 1000,
|
completed_successfully: 1000,
|
||||||
completed_successfully_action_pending: 1001,
|
completed_successfully_action_pending: 1001,
|
||||||
|
completed_without_address: 1100,
|
||||||
completed_successfully_no_messages: 1300,
|
completed_successfully_no_messages: 1300,
|
||||||
completed_successfully_ack_to_dequeue: 1301,
|
completed_successfully_ack_to_dequeue: 1301,
|
||||||
completed_successfully_ending_session: 1500,
|
completed_successfully_ending_session: 1500,
|
||||||
|
|
|
@ -140,4 +140,115 @@ class EppContactCreateBaseTest < EppTestCase
|
||||||
end
|
end
|
||||||
assert_epp_response :required_parameter_missing
|
assert_epp_response :required_parameter_missing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_does_not_save_address_when_address_processing_turned_off
|
||||||
|
name = 'new'
|
||||||
|
email = 'new@registrar.test'
|
||||||
|
phone = '+1.2'
|
||||||
|
|
||||||
|
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>
|
||||||
|
<create>
|
||||||
|
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||||
|
<contact:postalInfo>
|
||||||
|
<contact:name>#{name}</contact:name>
|
||||||
|
<contact:addr>
|
||||||
|
<contact:street>123 Example</contact:street>
|
||||||
|
<contact:city>Tallinn</contact:city>
|
||||||
|
<contact:sp>FFF</contact:sp>
|
||||||
|
<contact:pc>123456</contact:pc>
|
||||||
|
<contact:cc>EE</contact:cc>
|
||||||
|
</contact:addr>
|
||||||
|
</contact:postalInfo>
|
||||||
|
<contact:voice>#{phone}</contact:voice>
|
||||||
|
<contact:email>#{email}</contact:email>
|
||||||
|
</contact:create>
|
||||||
|
</create>
|
||||||
|
<extension>
|
||||||
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
|
<eis:ident type="priv" cc="US">123</eis:ident>
|
||||||
|
</eis:extdata>
|
||||||
|
</extension>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
assert_difference 'Contact.count' do
|
||||||
|
post epp_create_path, params: { frame: request_xml },
|
||||||
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_epp_response :completed_without_address
|
||||||
|
contact = Contact.find_by(name: name)
|
||||||
|
assert_equal name, contact.name
|
||||||
|
assert_equal email, contact.email
|
||||||
|
assert_equal phone, contact.phone
|
||||||
|
assert_not_empty contact.code
|
||||||
|
assert_nil contact.city
|
||||||
|
assert_nil contact.street
|
||||||
|
assert_nil contact.zip
|
||||||
|
assert_nil contact.country_code
|
||||||
|
assert_nil contact.state
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_saves_address_when_address_processing_turned_on
|
||||||
|
Setting.address_processing = true
|
||||||
|
|
||||||
|
name = 'new'
|
||||||
|
email = 'new@registrar.test'
|
||||||
|
phone = '+1.2'
|
||||||
|
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>
|
||||||
|
<create>
|
||||||
|
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||||
|
<contact:postalInfo>
|
||||||
|
<contact:name>#{name}</contact:name>
|
||||||
|
<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:voice>#{phone}</contact:voice>
|
||||||
|
<contact:email>#{email}</contact:email>
|
||||||
|
</contact:create>
|
||||||
|
</create>
|
||||||
|
<extension>
|
||||||
|
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||||
|
<eis:ident type="priv" cc="US">123</eis:ident>
|
||||||
|
</eis:extdata>
|
||||||
|
</extension>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
assert_difference 'Contact.count' do
|
||||||
|
post epp_create_path, params: { frame: request_xml },
|
||||||
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_epp_response :completed_successfully
|
||||||
|
contact = Contact.find_by(name: name)
|
||||||
|
assert_equal name, contact.name
|
||||||
|
assert_equal email, contact.email
|
||||||
|
assert_equal phone, contact.phone
|
||||||
|
assert_not_empty contact.code
|
||||||
|
assert_equal city, contact.city
|
||||||
|
assert_equal street, contact.street
|
||||||
|
assert_equal zip, contact.zip
|
||||||
|
assert_equal country_code, contact.country_code
|
||||||
|
assert_equal state, contact.state
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -232,6 +232,99 @@ class EppContactUpdateBaseTest < EppTestCase
|
||||||
assert_epp_response :completed_successfully
|
assert_epp_response :completed_successfully
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_updates_address_when_address_processing_turned_on
|
||||||
|
@contact.update_columns(code: @contact.code.upcase)
|
||||||
|
Setting.address_processing = true
|
||||||
|
|
||||||
|
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' }
|
||||||
|
|
||||||
|
assert_epp_response :completed_successfully
|
||||||
|
@contact.reload
|
||||||
|
|
||||||
|
assert_equal city, @contact.city
|
||||||
|
assert_equal street, @contact.street
|
||||||
|
assert_equal zip, @contact.zip
|
||||||
|
assert_equal country_code, @contact.country_code
|
||||||
|
assert_equal state, @contact.state
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_does_not_update_address_when_address_processing_turned_off
|
||||||
|
@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' }
|
||||||
|
|
||||||
|
assert_epp_response :completed_without_address
|
||||||
|
@contact.reload
|
||||||
|
|
||||||
|
assert_nil @contact.city
|
||||||
|
assert_nil @contact.street
|
||||||
|
assert_nil @contact.zip
|
||||||
|
assert_nil @contact.country_code
|
||||||
|
assert_nil @contact.state
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
|
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue