Merge branch 'master' into 2236-removing-old-validation-events

This commit is contained in:
Thiago Youssef 2022-05-17 16:06:41 +03:00
commit bbc1380e46
169 changed files with 2190 additions and 1340 deletions

View file

@ -2,4 +2,24 @@ contact_update:
operation: update
contact: john
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
user: registrant
user: registrant
contacts_update_bulk_action:
operation: bulk_update
user: registrant
contact_update_subaction_one:
operation: update
contact: william
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
user: registrant
bulk_action: contacts_update_bulk_action
contact_update_subaction_two:
operation: update
contact: jane
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
user: registrant
bulk_action: contacts_update_bulk_action

View file

@ -1,6 +1,7 @@
john:
name: John
email: john@inbox.test
email_history: john@inbox.test
phone: '+555.555'
ident: 1234
ident_type: priv
@ -18,6 +19,7 @@ john:
william: &william
name: William
email: william@inbox.test
email_history: william@inbox.test
phone: '+555.555'
fax: '+666.6'
ident: 12345

4
test/fixtures/files/accounts.csv vendored Normal file
View file

@ -0,0 +1,4 @@
Id,Balance,Currency,Registrar
112846265,100.0,EUR,Best Names
298486374,100.0,EUR,Good Names
597560588,0.0,EUR,Not in use
1 Id Balance Currency Registrar
2 112846265 100.0 EUR Best Names
3 298486374 100.0 EUR Good Names
4 597560588 0.0 EUR Not in use

View file

@ -0,0 +1,3 @@
name
tere.test
chao.test
1 name
2 tere.test
3 chao.test

View file

@ -0,0 +1,4 @@
name
tere.test
chao.test
cha.chacha
1 name
2 tere.test
3 chao.test
4 cha.chacha

View file

@ -0,0 +1,3 @@
Name,ID,Ident,Registrar,Action,Created at
,test_code,[ ],Best Names,update,2018-04-23 15:50:48
,,[ ],,update,2010-07-04 21:00:00
1 Name ID Ident Registrar Action Created at
2 test_code [ ] Best Names update 2018-04-23 15:50:48
3 [ ] update 2010-07-04 21:00:00

2
test/fixtures/files/contacts.csv vendored Normal file
View file

@ -0,0 +1,2 @@
Name,ID,Ident,E-mail,Created at,Registrar,Phone
Acme Ltd,acme-ltd-001,1234567 [US org],acme@outlook.test,2010-07-05 07:30:00,Best Names,+555.555
1 Name ID Ident E-mail Created at Registrar Phone
2 Acme Ltd acme-ltd-001 1234567 [US org] acme@outlook.test 2010-07-05 07:30:00 Best Names +555.555

View file

@ -0,0 +1,3 @@
Name,Registrant,Registrar,Action,Created at
,test_code,Best Names,update,2018-04-23 15:50:48
,John,,update,2010-07-04 21:00:00
1 Name Registrant Registrar Action Created at
2 test_code Best Names update 2018-04-23 15:50:48
3 John update 2010-07-04 21:00:00

2
test/fixtures/files/domains.csv vendored Normal file
View file

@ -0,0 +1,2 @@
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Contacts code,Force delete date,Force delete data
metro.test,Jack,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""jack-001"", ""jack-001""]",,
1 Domain Registrant Valid to Registrar Created at Statuses Contacts code Force delete date Force delete data
2 metro.test Jack 2010-07-05 00:00:00 Good Names 2010-07-05 07:30:00 [] ["jack-001", "jack-001"]

3
test/fixtures/files/invoices.csv vendored Normal file
View file

@ -0,0 +1,3 @@
Number,Buyer,Due Date,Receipt Date,Issue Date,Total,Currency,Seller Name
2,Best Names,2010-07-06,Unpaid,2010-07-05,16.5,EUR,Seller Ltd
1,Best Names,2010-07-06,2010-07-05,2010-07-05,16.5,EUR,Seller Ltd
1 Number Buyer Due Date Receipt Date Issue Date Total Currency Seller Name
2 2 Best Names 2010-07-06 Unpaid 2010-07-05 16.5 EUR Seller Ltd
3 1 Best Names 2010-07-06 2010-07-05 2010-07-05 16.5 EUR Seller Ltd

View file

@ -7,7 +7,7 @@ class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase
sign_in users(:admin)
@original_default_language = Setting.default_language
end
def test_show_account_activities_page
account_activities(:one).update(sum: "123.00")
visit admin_account_activities_path
@ -19,7 +19,7 @@ class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase
visit admin_root_path
click_link_or_button 'Settings', match: :first
find(:xpath, "//ul/li/a[text()='Account activities']").click
assert has_current_path?(admin_account_activities_path(created_after: 'today'))
end

View file

@ -0,0 +1,173 @@
require 'test_helper'
require 'application_system_test_case'
class AdminAreaAuctionIntegrationTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
@original_default_language = Setting.default_language
end
def test_should_open_index_page
visit admin_root_path
click_link_or_button 'Settings', match: :first
find(:xpath, "//ul/li/a[text()='Auctions']").click
assert_text 'Auctions'
end
def test_search_domains
visit admin_auctions_path
auction = auctions(:one)
fill_in 'domain_matches', :with => auction.domain
find(:xpath, ".//button[./span[contains(@class, 'glyphicon-search')]]", match: :first).click
assert_text auction.domain
assert_text 'auto'
assert_text 'no_bids'
end
def test_filter_no_bids_auction
auction_one = auctions(:one)
auction_two = auctions(:idn)
visit admin_auctions_path
select "no_bids", :from => "statuses_contains"
find(:xpath, ".//button[./span[contains(@class, 'glyphicon-search')]]", match: :first).click
assert_text auction_one.domain
assert_text auction_two.domain
end
def test_manually_create_auction
visit admin_auctions_path
fill_in 'domain', :with => 'new-awesome-auction.test'
find(:id, "new-auction-btn", match: :first).click
assert_text 'new-awesome-auction.test'
assert_text 'manual'
assert_text 'started'
end
def test_manually_create_auction_with_punycode
visit admin_auctions_path
fill_in 'domain', :with => 'xn--phimtte-10ad.test'
find(:id, "new-auction-btn", match: :first).click
assert_text 'xn--phimtte-10ad.test'
assert_text 'manual'
assert_text 'started'
end
def test_raise_error_if_try_to_add_auction_with_invalid_zone
visit admin_auctions_path
fill_in 'domain', :with => 'new-awesome-auction.chuchacha'
find(:id, "new-auction-btn", match: :first).click
assert_no_text 'new-awesome-auction.chuchacha'
assert_text 'Cannot generate domain. Reason: invalid format'
end
def test_raise_error_if_try_to_add_auction_with_invalid_format
visit admin_auctions_path
fill_in 'domain', :with => '#de$er.test'
find(:id, "new-auction-btn", match: :first).click
assert_no_text '#de$er.test'
assert_text 'Cannot generate domain. Reason: invalid format'
end
def test_raise_error_if_try_to_add_same_domain
visit admin_auctions_path
fill_in 'domain', :with => 'new-awesome-auction.test'
find(:id, "new-auction-btn", match: :first).click
fill_in 'domain', :with => 'new-awesome-auction.test'
find(:id, "new-auction-btn", match: :first).click
assert_text 'Adding new-awesome-auction.test failed - domain registered or regsitration is blocked'
end
def test_raise_error_if_try_to_add_registred_domain
visit admin_auctions_path
domain = domains(:shop)
fill_in 'domain', :with => domain.name
find(:id, "new-auction-btn", match: :first).click
assert_text "Adding #{domain.name} failed - domain registered or regsitration is blocked"
end
def test_raise_error_if_try_to_add_blocked_domain
visit admin_auctions_path
domain = blocked_domains(:one)
fill_in 'domain', :with => domain.name
find(:id, "new-auction-btn", match: :first).click
assert_text "Adding #{domain.name} failed - domain registered or regsitration is blocked"
end
def test_raise_error_if_try_to_add_disputed_domain
visit admin_auctions_path
domain = disputes(:active)
fill_in 'domain', :with => domain.domain_name
find(:id, "new-auction-btn", match: :first).click
assert_text "Adding #{domain.domain_name} failed - domain registered or regsitration is blocked"
end
def test_upload_invalid_csv_file
visit admin_auctions_path
attach_file(:q_file, Rails.root.join('test', 'fixtures', 'files', 'mass_actions', 'invalid_mass_force_delete_list.csv').to_s)
click_link_or_button 'Upload csv'
assert_text "Invalid CSV format. Should be column with 'name' where is the list of name of domains!"
end
def test_upload_valid_csv_file
visit admin_auctions_path
attach_file(:q_file, Rails.root.join('test', 'fixtures', 'files', 'auction_domains_list.csv').to_s)
click_link_or_button 'Upload csv'
assert_text "tere.test"
assert_text "chao.test"
end
def test_upload_valid_csv_file_with_invalid_item
visit admin_auctions_path
attach_file(:q_file, Rails.root.join('test', 'fixtures', 'files', 'auction_domains_list_with_invalid_item.csv').to_s)
click_link_or_button 'Upload csv'
assert_text "tere.test"
assert_text "chao.test"
assert_text "These domains were ignored: cha.chacha"
end
def test_should_remove_domain_from_reserved_if_it_added_to_auction
visit admin_auctions_path
domain = reserved_domains(:one)
fill_in 'domain', :with => domain.name
find(:id, "new-auction-btn", match: :first).click
assert_text domain.name
assert_text 'manual'
assert_text 'started'
visit admin_reserved_domains_path
assert_no_text domain.name
end
def test_should_open_reserved_page_in_modal_window
visit admin_auctions_path
find(:id, "reserved-modal", match: :first).click
assert_text 'Reserved domains'
end
end

View file

@ -20,8 +20,8 @@ class ApiV1AuctionDetailsTest < ActionDispatch::IntegrationTest
assert_response :ok
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:no_bids] }), ActiveSupport::JSON
.decode(response.body)
'status' => Auction.statuses[:no_bids],
'platform' => nil }), ActiveSupport::JSON.decode(response.body)
end
def test_auction_not_found

View file

@ -15,8 +15,8 @@ class ApiV1AuctionListTest < ActionDispatch::IntegrationTest
assert_response :ok
assert_equal ([{ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:started] }]), ActiveSupport::JSON
.decode(response.body)
'status' => Auction.statuses[:started],
'platform' => nil }]), ActiveSupport::JSON.decode(response.body)
end
def test_does_not_return_finished_auctions

View file

@ -27,8 +27,8 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
assert_response :ok
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:awaiting_payment] }), ActiveSupport::JSON
.decode(response.body)
'status' => Auction.statuses[:awaiting_payment],
'platform' => nil }), ActiveSupport::JSON.decode(response.body)
end
def test_marks_as_awaiting_payment

View file

@ -76,7 +76,7 @@ class EppContactCheckBaseTest < EppTestCase
response_xml = Nokogiri::XML(response.body)
assert_correct_against_schema response_xml
assert_equal '0', response_xml.at_xpath('//contact:id', contact: xml_schema)['avail']
assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
# assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
end
def test_multiple_contacts
@ -127,7 +127,7 @@ class EppContactCheckBaseTest < EppTestCase
assert_correct_against_schema response_xml
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
# assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
end
def test_check_contact_without_prefix
@ -154,7 +154,7 @@ class EppContactCheckBaseTest < EppTestCase
assert_correct_against_schema response_xml
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
# assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
end
private

View file

@ -142,42 +142,42 @@ class EppContactCreateBaseTest < EppTestCase
assert_epp_response :parameter_value_syntax_error
end
def test_responces_error_with_email_error
name = 'new'
email = 'new@registrar@test'
phone = '+1.2'
# def test_responces_error_with_email_error
# name = 'new'
# email = 'new@registrar@test'
# phone = '+1.2'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<create>
<contact:create xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')}">
<contact:postalInfo>
<contact:name>#{name}</contact:name>
</contact:postalInfo>
<contact:voice>#{phone}</contact:voice>
<contact:email>#{email}</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
<eis:ident type="priv" cc="US">any</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
# request_xml = <<-XML
# <?xml version="1.0" encoding="UTF-8" standalone="no"?>
# <epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
# <command>
# <create>
# <contact:create xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')}">
# <contact:postalInfo>
# <contact:name>#{name}</contact:name>
# </contact:postalInfo>
# <contact:voice>#{phone}</contact:voice>
# <contact:email>#{email}</contact:email>
# </contact:create>
# </create>
# <extension>
# <eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
# <eis:ident type="priv" cc="US">any</eis:ident>
# </eis:extdata>
# </extension>
# </command>
# </epp>
# XML
assert_no_difference 'Contact.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
# assert_no_difference 'Contact.count' do
# post epp_create_path, params: { frame: request_xml },
# headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
# end
response_xml = Nokogiri::XML(response.body)
assert_correct_against_schema response_xml
assert_epp_response :parameter_value_syntax_error
end
# response_xml = Nokogiri::XML(response.body)
# assert_correct_against_schema response_xml
# assert_epp_response :parameter_value_syntax_error
# end
def test_respects_custom_code
name = 'new'

View file

@ -80,6 +80,35 @@ class EppContactUpdateBaseTest < EppTestCase
assert_emails 1
end
def test_destroy_old_validation_when_email_is_changed
@contact.verify_email
old_validation_event = @contact.validation_events.first
@contact.update_columns(code: @contact.code.upcase)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<update>
<contact:update xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')}">
<contact:id>john-001</contact:id>
<contact:chg>
<contact:email>john-new@inbox.test</contact:email>
</contact:chg>
</contact:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_raises(ActiveRecord::RecordNotFound) do
ValidationEvent.find(old_validation_event.id)
end
end
def test_skips_notifying_contact_when_email_is_not_changed
assert_equal 'john-001', @contact.code
assert_equal 'john@inbox.test', @contact.email

View file

@ -717,52 +717,6 @@ class EppDomainUpdateBaseTest < EppTestCase
assert_no_emails
end
# COMMENT OU REASON: FOR EXPIRED DOMAIN SHOULD NOT SET FD
# def test_makes_update_if_was_forcedelete
# contact = @domain.contacts.first
# contact.update_attribute(:email, '`@outlook.test')
# contact.verify_email
# assert contact.email_verification_failed?
# @domain.reload
#
# assert @domain.force_delete_scheduled?
#
# @domain.update_attribute(:statuses_before_force_delete, nil)
#
# Setting.request_confirmation_on_registrant_change_enabled = true
# new_registrant = contacts(:william).becomes(Registrant)
# assert_not_equal new_registrant, @domain.registrant
#
# request_xml = <<-XML
# <?xml version="1.0" encoding="UTF-8" standalone="no"?>
# <epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
# <command>
# <update>
# <domain:update xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
# <domain:name>#{@domain.name}</domain:name>
# <domain:chg>
# <domain:registrant verified="yes">#{new_registrant.code}</domain:registrant>
# </domain:chg>
# </domain:update>
# </update>
# <extension>
# <eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
# <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
#
# response_xml = Nokogiri::XML(response.body)
# assert_correct_against_schema response_xml
# assert_epp_response :completed_successfully
# end
def test_clears_force_delete_when_registrar_changed
Setting.request_confirmation_on_registrant_change_enabled = true
new_registrant = contacts(:william).becomes(Registrant)

View file

@ -7,16 +7,8 @@ class EppPollTest < EppTestCase
# Deliberately does not conform to RFC5730, which requires the first notification to be returned
def test_return_latest_notification_when_queue_is_not_empty
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<poll op="req"/>
</command>
</epp>
XML
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_poll_path, params: { frame: request_req_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
assert_epp_response :completed_successfully_ack_to_dequeue
@ -30,17 +22,9 @@ class EppPollTest < EppTestCase
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="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<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' }
post epp_poll_path, params: { frame: request_req_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
xml_doc = Nokogiri::XML(response.body)
@ -54,19 +38,11 @@ class EppPollTest < EppTestCase
def test_return_action_data_when_present
@notification.update!(action: actions(:contact_update))
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<poll op="req"/>
</command>
</epp>
XML
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_poll_path, params: { frame: request_req_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
namespace = Xsd::Schema.filename(for_prefix: 'changePoll')
namespace = Xsd::Schema.filename(for_prefix: 'changePoll', for_version: '1.0')
assert_equal 'update', xml_doc.xpath('//changePoll:operation', 'changePoll' => namespace).text
assert_equal Time.zone.parse('2010-07-05').utc.xmlschema,
xml_doc.xpath('//changePoll:date', 'changePoll' => namespace).text
@ -76,19 +52,35 @@ class EppPollTest < EppTestCase
'changePoll' => namespace).text
end
def test_return_notifcation_with_bulk_action_data
bulk_action = actions(:contacts_update_bulk_action)
@notification.update!(action: bulk_action,
attached_obj_id: bulk_action.id,
attached_obj_type: 'BulkAction')
post epp_poll_path, params: { frame: request_req_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
namespace = Xsd::Schema.filename(for_prefix: 'changePoll', for_version: '1.0')
assert_equal 2, xml_doc.xpath('//contact:cd', contact: xml_schema).size
assert_epp_response :completed_successfully_ack_to_dequeue
assert_equal 'bulk_update', xml_doc.xpath('//changePoll:operation',
'changePoll' => namespace).text
assert_equal @notification.action.id.to_s, xml_doc.xpath('//changePoll:svTRID',
'changePoll' => namespace).text
assert_equal 'Registrant User', xml_doc.xpath('//changePoll:who',
'changePoll' => namespace).text
assert_equal 'Auto-update according to official data',
xml_doc.xpath('//changePoll:reason', 'changePoll' => namespace).text
end
def test_no_notifications
registrars(:bestnames).notifications.delete_all(:delete_all)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<poll op="req"/>
</command>
</epp>
XML
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_poll_path, params: { frame: request_req_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :completed_successfully_no_messages
end
@ -106,7 +98,7 @@ class EppPollTest < EppTestCase
XML
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
notification.reload
xml_doc = Nokogiri::XML(response.body)
@ -128,7 +120,7 @@ class EppPollTest < EppTestCase
</epp>
XML
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
notification.reload
assert notification.unread?
@ -145,13 +137,22 @@ class EppPollTest < EppTestCase
</epp>
XML
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :object_does_not_exist
end
def test_anonymous_user_cannot_access
request_xml = <<-XML
post '/epp/command/poll', params: { frame: request_req_xml },
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
assert_epp_response :authorization_error
end
private
def request_req_xml
<<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
@ -159,10 +160,9 @@ class EppPollTest < EppTestCase
</command>
</epp>
XML
end
post '/epp/command/poll', params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
assert_epp_response :authorization_error
def xml_schema
Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')
end
end

View file

@ -1,14 +0,0 @@
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

View file

@ -52,6 +52,8 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
end
def test_can_remove_admin_contacts
Spy.on_instance_method(Actions::DomainUpdate, :validate_email).and_return(true)
contact = contacts(:john)
payload = { contacts: [ { code: contact.code, type: 'admin' } ] }
post "/repp/v1/domains/#{@domain.name}/contacts", headers: @auth_headers, params: payload
@ -68,6 +70,8 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
end
def test_can_remove_tech_contacts
Spy.on_instance_method(Actions::DomainUpdate, :validate_email).and_return(true)
contact = contacts(:john)
payload = { contacts: [ { code: contact.code, type: 'tech' } ] }
post "/repp/v1/domains/#{@domain.name}/contacts", headers: @auth_headers, params: payload
@ -77,6 +81,9 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
delete "/repp/v1/domains/#{@domain.name}/contacts", headers: @auth_headers, params: payload
json = JSON.parse(response.body, symbolize_names: true)
@domain.reload
contact.reload
assert_response :ok
assert_equal 1000, json[:code]
@ -84,6 +91,8 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
end
def test_can_not_remove_one_and_only_contact
Spy.on_instance_method(Actions::DomainUpdate, :validate_email).and_return(true)
contact = @domain.admin_contacts.last
payload = { contacts: [ { code: contact.code, type: 'admin' } ] }
@ -96,5 +105,4 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
assert @domain.admin_contacts.any?
end
end

View file

@ -0,0 +1,18 @@
require 'test_helper'
class BaseTest < ActiveSupport::TestCase
def test_hold_domains_force_delete_email
domain = domains(:shop)
domain.update!(statuses: [DomainStatus::SERVER_HOLD])
domain.update!(expire_time: Time.zone.now + 1.year)
registrant = domain.registrant
registrant.update!(email: "#{registrant.email.split('@').first}@#{domain.name}")
Domains::ForceDeleteEmail::Base.run(email: registrant.email)
domain.reload
assert_not domain.force_delete_scheduled?
end
end

View file

@ -1,27 +0,0 @@
require 'test_helper'
class MigrateBeforeForceDeleteStatusesJobTest < ActiveJob::TestCase
setup do
travel_to Time.zone.parse('2010-07-05')
@domain = domains(:shop)
end
def test_migrate_data_before_force_delete
@domain.update(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
@domain.reload
assert @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
@domain.schedule_force_delete(type: :soft)
@domain.reload
assert @domain.force_delete_scheduled?
perform_enqueued_jobs do
MigrateBeforeForceDeleteStatusesJob.perform_later
end
@domain.reload
assert @domain.force_delete_domain_statuses_history.include? DomainStatus::SERVER_UPDATE_PROHIBITED
end
end

View file

@ -1,22 +0,0 @@
require 'test_helper'
class MigrateBeforeForceDeleteStatusesJobTest < ActiveJob::TestCase
setup do
travel_to Time.zone.parse('2010-07-05')
@domain = domains(:shop)
end
def test_migrate_statuses_to_domain_history_job
@domain.update(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
@domain.reload
assert @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
perform_enqueued_jobs do
MigrateStatusesToDomainHistoryJob.perform_later
end
@domain.reload
assert @domain.admin_store_statuses_history.include? DomainStatus::SERVER_UPDATE_PROHIBITED
end
end

View file

@ -13,7 +13,8 @@ class NameserverRecordValidationJobTest < ActiveSupport::TestCase
def test_nameserver_should_validate_succesfully_and_set_validation_datetime
mock_dns_response = OpenStruct.new
answer = OpenStruct.new
answer.serial = '12343'
answer.instance_variable_set(:@serial, '12345')
mock_dns_response.answer = [ answer ]
Spy.on_instance_method(NameserverValidator, :setup_resolver).and_return(Dnsruby::Resolver.new)
@ -26,6 +27,8 @@ class NameserverRecordValidationJobTest < ActiveSupport::TestCase
NameserverRecordValidationJob.perform_now(domain_name: @domain.name)
@nameserver.reload
p @nameserver
assert_not_nil @nameserver.validation_datetime
assert_nil @nameserver.validation_counter
assert_nil @nameserver.failed_validation_reason
@ -47,7 +50,7 @@ class NameserverRecordValidationJobTest < ActiveSupport::TestCase
assert_nil @nameserver.validation_datetime
assert @nameserver.validation_counter, 1
assert @nameserver.failed_validation_reason.include? "No any answer comes from **#{@nameserver.hostname}**"
assert @nameserver.failed_validation_reason.include? "DNS Server **#{@nameserver.hostname}**"
end
def test_should_return_failed_validation_with_serial_reason
@ -68,13 +71,14 @@ class NameserverRecordValidationJobTest < ActiveSupport::TestCase
assert_nil @nameserver.validation_datetime
assert @nameserver.validation_counter, 1
assert @nameserver.failed_validation_reason.include? "Serial number for nameserver hostname **#{@nameserver.hostname}** doesn't present. SOA validation failed."
assert @nameserver.failed_validation_reason.include? "Serial number for nameserver hostname **#{@nameserver.hostname}** of #{@nameserver.domain.name} doesn't present in zone. SOA validation failed."
end
def test_after_third_invalid_times_nameserver_should_be_invalid
mock_dns_response = OpenStruct.new
answer = OpenStruct.new
answer.some_field = '12343'
answer.type = 'SOA'
mock_dns_response.answer = [ answer ]
Spy.on_instance_method(NameserverValidator, :setup_resolver).and_return(Dnsruby::Resolver.new)
@ -89,9 +93,12 @@ class NameserverRecordValidationJobTest < ActiveSupport::TestCase
end
@nameserver.reload
p @nameserver.failed_validation_reason
assert_nil @nameserver.validation_datetime
assert @nameserver.validation_counter, 1
assert @nameserver.failed_validation_reason.include? "Serial number for nameserver hostname **#{@nameserver.hostname}** doesn't present. SOA validation failed."
assert @nameserver.failed_validation_reason.include? "Serial number for nameserver hostname **#{@nameserver.hostname}** of #{@nameserver.domain.name} doesn't present in zone. SOA validation failed."
assert @nameserver.failed_validation?
end

View file

@ -0,0 +1,17 @@
require 'test_helper'
require 'serializers/repp/domain'
class SerializersReppDomainTest < ActiveSupport::TestCase
def setup
@domain = domains(:airport)
end
def test_returns_status_notes
status_notes = { 'serverForceDelete' => '`@internet2.ee' }
@domain.update!(statuses: %w[serverForceDelete], status_notes: status_notes)
@serializer = Serializers::Repp::Domain.new(@domain)
@json = @serializer.to_json
assert_equal(status_notes, @json[:statuses])
end
end

View file

@ -28,33 +28,4 @@ class DomainExpireMailerTest < ActionMailer::TestCase
assert_equal I18n.t("domain_expire_mailer.expired_soft.subject", domain_name: domain.name),
email.subject
end
# COMMENT OU REASON: FOR EXPIRED DOMAIN SHOULD NOT SET FD
# def test_delivers_domain_expiration_soft_email_if_auto_fd
# domain = domains(:shop)
# email_address = domain.registrar.email
# assert_not domain.force_delete_scheduled?
# travel_to Time.zone.parse('2010-07-05')
# email = '`@internet.ee'
#
# Truemail.configure.default_validation_type = :regex
#
# contact = domain.admin_contacts.first
# contact.update_attribute(:email, email)
# contact.verify_email
#
# assert contact.email_verification_failed?
#
# domain.reload
#
# assert_no domain.force_delete_scheduled?
#
# email = DomainExpireMailer.expired_soft(domain: domain,
# registrar: domain.registrar,
# email: email_address).deliver_now
#
# assert_emails 1
# assert_equal I18n.t("domain_expire_mailer.expired_soft.subject", domain_name: domain.name),
# email.subject
# end
end

View file

@ -137,9 +137,8 @@ class BouncedMailAddressTest < ActiveSupport::TestCase
bounced_mail = BouncedMailAddress.last
registrant = domains(:shop).registrant
registrant.verify_email(check_level: 'smtp')
assert_equal registrant.email, bounced_mail.email
assert registrant.email_verification_failed?
end
def sns_bounce_payload

View file

@ -1,39 +0,0 @@
require 'test_helper'
class ContactDisclosableTest < ActiveSupport::TestCase
setup do
@contact = contacts(:john)
@original_disclosable_attributes = Contact.disclosable_attributes
end
teardown do
Contact.disclosable_attributes = @original_disclosable_attributes
end
def test_no_disclosed_attributes_by_default
assert_empty Contact.new.disclosed_attributes
end
def test_disclosable_attributes
assert_equal %w[name email], Contact.disclosable_attributes
end
def test_valid_without_disclosed_attributes
@contact.disclosed_attributes = []
assert @contact.valid?
end
def test_invalid_when_attribute_is_not_disclosable
Contact.disclosable_attributes = %w[some disclosable]
@contact.disclosed_attributes = %w[some undisclosable]
assert @contact.invalid?
assert_includes @contact.errors[:disclosed_attributes], 'contain unsupported attribute(s)'
end
def test_valid_when_attribute_is_disclosable
Contact.disclosable_attributes = %w[some disclosable]
@contact.disclosed_attributes = %w[disclosable]
assert @contact.valid?
end
end

View file

@ -90,14 +90,14 @@ class ContactTest < ActiveJob::TestCase
assert contact.valid?
end
def test_email_verification_regex_error
Truemail.configure.default_validation_type = :regex
# def test_email_verification_regex_error
# Truemail.configure.default_validation_type = :regex
contact = valid_contact
contact.email = '`@internet.ee'
assert contact.invalid?
assert_equal I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'), contact.errors.messages[:email].first
end
# contact = valid_contact
# contact.email = '`@internet.ee'
# assert contact.invalid?
# assert_equal I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'), contact.errors.messages[:email].first
# end
def test_invalid_without_phone
contact = valid_contact

View file

@ -1,6 +1,8 @@
require 'test_helper'
class ForceDeleteTest < ActionMailer::TestCase
include ActiveJob::TestHelper
setup do
@domain = domains(:shop)
Setting.redemption_grace_period = 30
@ -356,7 +358,6 @@ class ForceDeleteTest < ActionMailer::TestCase
@domain.reload
assert @domain.force_delete_scheduled?
assert_equal 'invalid_email', @domain.template_name
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
notification = @domain.registrar.notifications.last
@ -375,7 +376,6 @@ class ForceDeleteTest < ActionMailer::TestCase
@domain.reload
assert @domain.force_delete_scheduled?
assert_equal 'invalid_email', @domain.template_name
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
notification = @domain.registrar.notifications.last
@ -398,12 +398,10 @@ class ForceDeleteTest < ActionMailer::TestCase
contact.verify_email
end
assert contact.email_verification_failed?
perform_check_force_delete_job(contact.id)
@domain.reload
assert @domain.force_delete_scheduled?
assert_equal 'invalid_email', @domain.template_name
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
assert_equal @domain.status_notes[DomainStatus::FORCE_DELETE], email
@ -411,6 +409,65 @@ class ForceDeleteTest < ActionMailer::TestCase
assert notification.text.include? asserted_text
end
def test_add_invalid_email_to_domain_status_notes
domain = domains(:airport)
domain.update(valid_to: Time.zone.parse('2012-08-05'),
statuses: %w[serverForceDelete serverRenewProhibited serverTransferProhibited],
force_delete_data: { 'template_name': 'invalid_email', 'force_delete_type': 'soft' },
status_notes: { "serverForceDelete": '`@internet2.ee' })
travel_to Time.zone.parse('2010-07-05')
email = '`@internet.ee'
invalid_emails = '`@internet2.ee `@internet.ee'
asserted_text = "Invalid email: #{invalid_emails}"
Truemail.configure.default_validation_type = :regex
contact_first = domain.admin_contacts.first
contact_first.update_attribute(:email_history, 'john@inbox.test')
contact_first.update_attribute(:email, email)
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
contact_first.verify_email
end
perform_check_force_delete_job(contact_first.id)
domain.reload
assert_equal domain.status_notes[DomainStatus::FORCE_DELETE], invalid_emails
notification = domain.registrar.notifications.last
assert_not notification.text.include? asserted_text
end
def test_remove_invalid_email_from_domain_status_notes
domain = domains(:airport)
domain.update(valid_to: Time.zone.parse('2012-08-05'),
statuses: %w[serverForceDelete serverRenewProhibited serverTransferProhibited],
force_delete_data: { 'template_name': 'invalid_email', 'force_delete_type': 'soft' },
status_notes: { "serverForceDelete": '`@internet2.ee `@internet.ee' })
travel_to Time.zone.parse('2010-07-05')
email = '`@internet2.ee'
invalid_email = '`@internet.ee'
asserted_text = "Invalid email: #{invalid_email}"
Truemail.configure.default_validation_type = :regex
contact_first = domain.admin_contacts.first
contact_first.update_attribute(:email_history, email)
contact_first.update_attribute(:email, 'john@inbox.test')
travel_to Time.zone.parse('2010-07-05 0:00:03')
contact_first.verify_email
perform_check_force_delete_job(contact_first.id)
domain.reload
assert_equal domain.status_notes[DomainStatus::FORCE_DELETE], invalid_email
notification = domain.registrar.notifications.last
assert notification.text.include? asserted_text
end
def test_domain_should_have_several_bounced_emails
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
assert_not @domain.force_delete_scheduled?
@ -421,19 +478,20 @@ class ForceDeleteTest < ActionMailer::TestCase
contact_one = @domain.admin_contacts.first
contact_one.update_attribute(:email, email_one)
contact_one.verify_email
perform_check_force_delete_job(contact_one.id)
assert contact_one.need_to_start_force_delete?
contact_two = @domain.admin_contacts.first
contact_two.update_attribute(:email, email_two)
contact_two.verify_email
perform_check_force_delete_job(contact_two.id)
assert contact_two.need_to_start_force_delete?
@domain.reload
assert @domain.force_delete_scheduled?
assert_equal 'invalid_email', @domain.template_name
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
assert @domain.status_notes[DomainStatus::FORCE_DELETE].include? email_one
@ -452,13 +510,12 @@ class ForceDeleteTest < ActionMailer::TestCase
@domain.reload
assert @domain.force_delete_scheduled?
assert_equal 'invalid_email', @domain.template_name
assert_equal Date.parse('2010-09-19'), @domain.force_delete_date.to_date
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
notification = @domain.registrar.notifications.last
assert notification.text.include? asserted_text
@domain.registrant.update(email: 'aaa@bbb.com')
@domain.registrant.update(email: 'aaa@bbb.com', email_history: email)
@domain.registrant.verify_email
assert @domain.registrant.need_to_lift_force_delete?
CheckForceDeleteLift.perform_now
@ -478,4 +535,12 @@ class ForceDeleteTest < ActionMailer::TestCase
@bounced_mail.diagnostic = 'smtp; 550 5.1.1 user unknown'
@bounced_mail.save!
end
private
def perform_check_force_delete_job(contact_id)
perform_enqueued_jobs do
CheckForceDeleteJob.perform_now([contact_id])
end
end
end

View file

@ -7,42 +7,26 @@ class RegistrantUserCreationTest < ActiveSupport::TestCase
first_name: 'JOHN',
last_name: 'SMITH'
}
RegistrantUser.find_or_create_by_api_data(user_data)
assert_difference 'RegistrantUser.count' do
RegistrantUser.find_or_create_by_api_data(user_data)
end
user = User.find_by(registrant_ident: 'EE-37710100070')
assert_equal('JOHN SMITH', user.username)
end
def test_find_or_create_by_api_data_creates_a_user_with_original_name
def test_find_or_create_by_api_data_updates_a_user_with_existing_ident
user_data = {
ident: '37710100070',
ident: '1234',
country_code: 'US',
first_name: 'John',
last_name: 'Smith'
last_name: 'Smith',
}
assert_no_difference 'RegistrantUser.count' do
RegistrantUser.find_or_create_by_api_data(user_data)
end
RegistrantUser.find_or_create_by_api_data(user_data)
user = User.find_by(registrant_ident: 'EE-37710100070')
user = User.find_by(registrant_ident: 'US-1234')
assert_equal('John Smith', user.username)
end
def test_updates_related_contacts_name_if_differs_from_e_identity
contact = contacts(:john)
contact.update(ident: '39708290276', ident_country_code: 'EE')
user_data = {
ident: '39708290276',
first_name: 'John',
last_name: 'Doe'
}
RegistrantUser.find_or_create_by_api_data(user_data)
user = User.find_by(registrant_ident: 'EE-39708290276')
assert_equal('John Doe', user.username)
contact.reload
assert_equal user.username, contact.name
end
end

View file

@ -32,58 +32,133 @@ class RegistrantUserTest < ActiveSupport::TestCase
assert_equal Country.new('US'), user.country
end
def test_should_update_org_contact_if_data_from_business_registry_dismatch
def test_should_update_contacts_if_names_dismatch
assert_equal 'US-1234', @user.registrant_ident
org = contacts(:acme_ltd)
org.ident_country_code = 'EE'
org.save(validate: false)
org.reload
registrars = [registrars(:bestnames), registrars(:goodnames)]
contacts = [contacts(:john), contacts(:william), contacts(:identical_to_william),
contacts(:acme_ltd), contacts(:registrar_ltd)]
contacts.each do |c|
if c.ident_type == 'priv'
c.ident = @user.ident
else
c.ident_country_code = 'EE'
c.registrar = registrars(:bestnames)
end
c.save(validate: false)
end
company = Company.new(org.ident, "ace")
company_one = Company.new(contacts(:acme_ltd).ident, 'ace')
company_two = Company.new(contacts(:registrar_ltd).ident, 'acer')
company_register = Minitest::Mock.new
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
citizen_country_code: 'USA' }])
@user.companies(company_register)
org.reload
Spy.on(@user, :companies).and_return([company_one, company_two])
@user.update_contacts
assert_equal org.name, company.company_name
contacts.each do |c|
c.reload
assert_equal @user.username, c.name if c.ident_type == 'priv'
assert @user.actions.find_by(operation: :update, contact_id: c.id)
end
bulk_action = @user.actions.where(operation: :bulk_update).last
assert_equal 4, bulk_action.subactions.size
registrars.each do |r|
notification = r.notifications.unread.order('created_at DESC').take
if r == registrars(:bestnames)
assert_equal '4 contacts have been updated by registrant', notification.text
assert_equal 'BulkAction', notification.attached_obj_type
assert_equal bulk_action.id, notification.attached_obj_id
assert_equal bulk_action.id, notification.action_id
else
assert_equal 'Contact william-002 has been updated by registrant', notification.text
refute notification.action_id
refute notification.attached_obj_id
refute notification.attached_obj_type
end
end
end
def test_queries_company_register_for_associated_companies
assert_equal 'US-1234', @user.registrant_ident
company = Company.new("acme", "ace")
company = Company.new('acme', 'ace')
company_register = Minitest::Mock.new
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
citizen_country_code: 'USA' }])
citizen_country_code: 'USA' }])
assert_equal [company], @user.companies(company_register)
company_register.verify
end
def test_should_return_zero_count_of_companies
assert_equal 'US-1234', @user.registrant_ident
contacts = [contacts(:john), contacts(:william), contacts(:identical_to_william),
contacts(:acme_ltd), contacts(:registrar_ltd)]
contacts.each do |c|
if c.ident_type == 'priv'
c.ident = @user.ident
c.name = @user.username
else
c.ident_country_code = 'EE'
end
c.save(validate: false)
end
company_one = Company.new(contacts(:acme_ltd).ident, 'Acme Ltd')
company_two = Company.new(contacts(:registrar_ltd).ident, 'Registrar Ltd')
Spy.on(@user, :companies).and_return([company_one, company_two])
response = @user.do_need_update_contacts?
assert_equal response[:counter], 0
end
def test_should_return_count_of_contacts_which_should_be_updated
assert_equal 'US-1234', @user.registrant_ident
contacts = [contacts(:john), contacts(:william), contacts(:identical_to_william),
contacts(:acme_ltd), contacts(:registrar_ltd)]
contacts.each do |c|
if c.ident_type == 'priv'
c.ident = @user.ident
else
c.ident_country_code = 'EE'
end
c.save(validate: false)
end
company_one = Company.new(contacts(:acme_ltd).ident, 'ace')
company_two = Company.new(contacts(:registrar_ltd).ident, 'acer')
Spy.on(@user, :companies).and_return([company_one, company_two])
response = @user.do_need_update_contacts?
assert_equal response[:counter], 5
end
def test_returns_contacts
Contact.stub(:registrant_user_contacts, %w(john jane)) do
assert_equal %w(john jane), @user.contacts
Contact.stub(:registrant_user_contacts, %w[john jane]) do
assert_equal %w[john jane], @user.contacts
end
end
def test_returns_direct_contacts
Contact.stub(:registrant_user_direct_contacts, %w(john jane)) do
assert_equal %w(john jane), @user.direct_contacts
Contact.stub(:registrant_user_direct_contacts, %w[john jane]) do
assert_equal %w[john jane], @user.direct_contacts
end
end
def test_returns_domains
Domain.stub(:registrant_user_domains, %w(shop airport)) do
assert_equal %w(shop airport), @user.domains
Domain.stub(:registrant_user_domains, %w[shop airport]) do
assert_equal %w[shop airport], @user.domains
end
end
def test_returns_administered_domains
Domain.stub(:registrant_user_administered_domains, %w(shop airport)) do
assert_equal %w(shop airport), @user.administered_domains
Domain.stub(:registrant_user_administered_domains, %w[shop airport]) do
assert_equal %w[shop airport], @user.administered_domains
end
end
end

View file

@ -48,16 +48,16 @@ class RegistrarTest < ActiveJob::TestCase
assert registrar.valid?
end
def test_email_verification_regex_error
Truemail.configure.default_validation_type = :regex
# def test_email_verification_regex_error
# Truemail.configure.default_validation_type = :regex
registrar = valid_registrar
registrar.email = '`@internet.ee'
registrar.billing_email = nil
# registrar = valid_registrar
# registrar.email = '`@internet.ee'
# registrar.billing_email = nil
assert registrar.invalid?
assert_equal I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'), registrar.errors.messages[:email].first
end
# assert registrar.invalid?
# assert_equal I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'), registrar.errors.messages[:email].first
# end
def test_billing_email_verification_valid
registrar = valid_registrar
@ -66,15 +66,15 @@ class RegistrarTest < ActiveJob::TestCase
assert registrar.valid?
end
def test_billing_email_verification_regex_error
Truemail.configure.default_validation_type = :regex
# def test_billing_email_verification_regex_error
# Truemail.configure.default_validation_type = :regex
registrar = valid_registrar
registrar.billing_email = '`@strangesentence@internet.ee'
# registrar = valid_registrar
# registrar.billing_email = '`@strangesentence@internet.ee'
assert registrar.invalid?
assert_equal I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'), registrar.errors.messages[:billing_email].first
end
# assert registrar.invalid?
# assert_equal I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'), registrar.errors.messages[:billing_email].first
# end
def test_invalid_without_accounting_customer_code
registrar = valid_registrar

View file

@ -29,4 +29,16 @@ class AdminAccountsSystemTest < ApplicationSystemTestCase
assert_text 'Account has been successfully updated'
assert_text '234'
end
def test_download_accounts_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
get admin_accounts_path(format: :csv)
assert_response :ok
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
assert_equal %(attachment; filename="accounts_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''accounts_#{Time.zone.now.to_formatted_s(:number)}.csv),
response.headers['Content-Disposition']
assert_equal file_fixture('accounts.csv').read, response.body
end
end

View file

@ -62,11 +62,10 @@ class ContactVersionsTest < ApplicationSystemTestCase
travel_to now
get admin_contact_versions_path(format: :csv)
assert_response :ok
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
assert_equal %(attachment; filename="contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''contact_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
response.headers['Content-Disposition']
assert_not_empty response.body
assert_equal file_fixture('contact_versions.csv').read, response.body
end
end

View file

@ -0,0 +1,22 @@
require 'application_system_test_case'
class ContactsCsvTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
Domain.destroy_all
Contact.all.each { |contact| contact.destroy unless contact.name == 'Acme Ltd' }
end
def test_download_contacts_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
contact = Contact.first
contact.created_at = Time.zone.now
contact.save(validate: false)
visit admin_contacts_url
click_link('CSV')
assert_equal "attachment; filename=\"contacts_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''contacts_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
assert_equal file_fixture('contacts.csv').read, page.body
end
end

View file

@ -98,7 +98,7 @@ class DomainVersionsTest < ApplicationSystemTestCase
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
assert_equal %(attachment; filename="domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''domain_history_#{Time.zone.now.to_formatted_s(:number)}.csv),
response.headers['Content-Disposition']
assert_not_empty response.body
assert_equal file_fixture('domain_versions.csv').read, response.body
end
def test_search_event_param

View file

@ -1,18 +1,21 @@
require 'application_system_test_case'
class AdminAreaCsvTest < ApplicationSystemTestCase
class DomainsCsvTest < ApplicationSystemTestCase
setup do
sign_in users(:admin)
Domain.all.each { |domain| domain.destroy unless domain.name == 'metro.test' }
end
def test_downloads_domain_list_as_csv
search_params = {"valid_to_lteq"=>nil}
expected_csv = Domain.includes(:registrar, :registrant).search(search_params).result.to_csv
def test_download_domains_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
domain = Domain.first
domain.created_at = Time.zone.now
domain.save(validate: false)
visit admin_domains_url
click_link('CSV')
assert_equal "attachment; filename=\"domains_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''domains_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
assert_equal expected_csv, page.body
assert_equal file_fixture('domains.csv').read, page.body
end
end

View file

@ -40,4 +40,14 @@ class AdminAreaInvoicesTest < ApplicationSystemTestCase
assert_current_path admin_invoice_path(@invoice)
assert_text 'Invoice has been sent'
end
def test_download_invoices_list_as_csv
travel_to Time.zone.parse('2010-07-05 10:30')
visit admin_invoices_url
click_link('CSV')
assert_equal "attachment; filename=\"invoices_#{Time.zone.now.to_formatted_s(:number)}.csv\"; filename*=UTF-8''invoices_#{Time.zone.now.to_formatted_s(:number)}.csv", response_headers['Content-Disposition']
assert_equal file_fixture('invoices.csv').read, page.body
end
end

View file

@ -0,0 +1,65 @@
require 'test_helper'
class CheckForceDeleteTaskTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
def setup
@contact = contacts(:john)
@invalid_contact = contacts(:invalid_email)
end
def test_enque_force_delete_when_three_invalid_records_by_mx
trumail_results = OpenStruct.new(success: false,
email: @contact.email,
domain: 'box.tests',
errors: { mx: 'target host(s) not found' })
Spy.on_instance_method(Actions::EmailCheck, :check_email).and_return(trumail_results)
Spy.on_instance_method(Actions::AAndAaaaEmailValidation, :call).and_return([])
action = Actions::EmailCheck.new(email: @contact.email,
validation_eventable: @contact,
check_level: 'mx')
3.times do
action.call
end
run_task
assert_enqueued_jobs 1
assert_enqueued_with(job: CheckForceDeleteJob, args: [[@contact.id]])
end
def test_enque_force_delete_when_invalid_record_by_regex
@invalid_contact.verify_email
run_task
assert_enqueued_jobs 1
assert_enqueued_with(job: CheckForceDeleteJob, args: [[@invalid_contact.id]])
end
def test_not_enque_force_delete
trumail_results = OpenStruct.new(success: false,
email: @contact.email,
domain: 'box.tests',
errors: { mx: 'target host(s) not found' })
Spy.on_instance_method(Actions::EmailCheck, :check_email).and_return(trumail_results)
Spy.on_instance_method(Actions::AAndAaaaEmailValidation, :call).and_return([])
action = Actions::EmailCheck.new(email: @contact.email,
validation_eventable: @contact,
check_level: 'mx')
2.times do
action.call
end
assert_enqueued_jobs 0
end
private
def run_task
Rake::Task['check_force_delete'].execute
end
end