diff --git a/test/integration/admin_area/domain_update_confirms_test.rb b/test/integration/admin_area/domain_update_confirms_test.rb new file mode 100644 index 000000000..9eb79685f --- /dev/null +++ b/test/integration/admin_area/domain_update_confirms_test.rb @@ -0,0 +1,80 @@ +require 'test_helper' +require 'application_system_test_case' + +class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase + setup do + WebMock.allow_net_connect! + sign_in users(:admin) + @domain = domains(:shop) + end + + def test_t + new_registrant = contacts(:william) + assert_not_equal new_registrant, @domain.registrant + + puts new_registrant.name + request_xml = <<-XML + + + + + + #{@domain.name} + + #{new_registrant.code} + + + + + + #{'test' * 2000} + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + @domain.reload + + puts @domain.registrant + end + + private + + def update_registrant_of_domain + new_registrant = contacts(:william) + assert_not_equal new_registrant, @domain.registrant + + @domain.registrant + request_xml = <<-XML + + + + + + #{@domain.name} + + #{new_registrant.code} + + + + + + #{'test' * 2000} + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + @domain.reload + + # puts response.body + puts @domain.registrant + end + +end \ No newline at end of file diff --git a/test/integration/repp/v1/contacts/tech_replace_test.rb b/test/integration/repp/v1/contacts/tech_replace_test.rb index dfc61f6e2..ed8c9d0cc 100644 --- a/test/integration/repp/v1/contacts/tech_replace_test.rb +++ b/test/integration/repp/v1/contacts/tech_replace_test.rb @@ -47,4 +47,22 @@ class ReppV1ContactsTechReplaceTest < ActionDispatch::IntegrationTest assert_equal 2304, json[:code] assert_equal 'New contact must be different from current', json[:message] end + + def test_domain_has_status_tech_change_prohibited + domain_shop = domains(:shop) + domain_shop_tech_contact_id = domain_shop.tech_domain_contacts[0][:contact_id] + old_contact = Contact.find_by(id: domain_shop_tech_contact_id) + new_contact = contacts(:john) + + domain_shop.update(statuses: [DomainStatus::SERVER_TECH_CHANGE_PROHIBITED]) + domain_shop.reload + assert domain_shop.statuses.include? DomainStatus::SERVER_TECH_CHANGE_PROHIBITED + + payload = { current_contact_id: old_contact.code, new_contact_id: new_contact.code } + patch "/repp/v1/domains/contacts", headers: @auth_headers, params: payload + json = JSON.parse(response.body, symbolize_names: true) + + assert_equal json[:data][:skipped_domains], ["shop.test"] + assert domain_shop.contacts.find_by(id: domain_shop_tech_contact_id).present? + end end diff --git a/test/integration/repp/v1/domains/renews_test.rb b/test/integration/repp/v1/domains/renews_test.rb index 3f78907db..fdebc62bd 100644 --- a/test/integration/repp/v1/domains/renews_test.rb +++ b/test/integration/repp/v1/domains/renews_test.rb @@ -41,4 +41,26 @@ class ReppV1DomainsRenewsTest < ActionDispatch::IntegrationTest assert @domain.valid_to, original_valid_to end + + def test_some_test + days_to_renew_domain_before_expire = setting_entries(:days_to_renew_domain_before_expire) + days_to_renew_domain_before_expire.update(value: '1') + days_to_renew_domain_before_expire.reload + + original_valid_to = @domain.valid_to + travel_to @domain.valid_to - 3.days + + one_year = billing_prices(:renew_one_year) + one_year.update(valid_from: @domain.valid_to - 5.days) + one_year.reload + + @auth_headers['Content-Type'] = 'application/json' + payload = { renew: { period: 1, period_unit: 'y' } } + post "/repp/v1/domains/#{@domain.name}/renew", headers: @auth_headers, params: payload.to_json + json = JSON.parse(response.body, symbolize_names: true) + + assert_response :bad_request + assert_equal 2304, json[:code] + assert_equal 'Object status prohibits operation', json[:message] + end end diff --git a/test/integration/repp/v1/registrar/nameservers_test.rb b/test/integration/repp/v1/registrar/nameservers_test.rb index f01769dfb..e58e4651c 100644 --- a/test/integration/repp/v1/registrar/nameservers_test.rb +++ b/test/integration/repp/v1/registrar/nameservers_test.rb @@ -74,4 +74,79 @@ class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest assert_equal 2005, json[:code] assert_equal 'IPv6 is invalid [ipv6]', json[:message] end + + def test_ipv4_isnt_array + nameserver = nameservers(:shop_ns1) + payload = { + "data": { + "id": nameserver.hostname, + "type": "nameserver", + "domains": ["shop.test", "airport.test", "library.test", "metro.test"], + "attributes": { + "hostname": nameserver.hostname, + "ipv4": "1.1.1.1", + "ipv6": ["2620:119:352::36"] + } + } + } + + put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload + json = JSON.parse(response.body, symbolize_names: true) + + assert_response :bad_request + assert_equal 2005, json[:code] + assert_equal 'IPv4 should be array [ipv4]', json[:message] + end + + def test_ipv6_isnt_array + nameserver = nameservers(:shop_ns1) + payload = { + "data": { + "id": nameserver.hostname, + "type": "nameserver", + "domains": ["shop.test", "airport.test", "library.test", "metro.test"], + "attributes": { + "hostname": nameserver.hostname, + "ipv4": ["1.1.1.1"], + "ipv6": "2620:119:352::36" + } + } + } + + put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload + json = JSON.parse(response.body, symbolize_names: true) + + assert_response :bad_request + assert_equal 2005, json[:code] + assert_equal 'IPv6 should be array [ipv6]', json[:message] + end + + def test_bulk_nameservers_change_in_array_of_domains + domain_shop = domains(:shop) + domain_airport = domains(:airport) + + payload = { + "data": { + "type": "nameserver", + "id": "ns1.bestnames.test", + "domains": ["shop.test", "airport.test"], + "attributes": { + "hostname": "ns4.bestnames.test", + "ipv4": ["192.168.1.1"], + "ipv6": ["2620:119:35::36"] + } + } + } + + put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload + json = JSON.parse(response.body, symbolize_names: true) + domain_airport.reload + domain_shop.reload + + refute domain_shop.nameservers.find_by(hostname: 'ns1.bestnames.test').present? + assert domain_shop.nameservers.find_by(hostname: 'ns4.bestnames.test').present? + assert_equal({ hostname: "ns4.bestnames.test", ipv4: ["192.168.1.1"], ipv6: ["2620:119:35::36"] }, json[:data][:attributes]) + assert json[:data][:affected_domains].include? 'airport.test' + assert json[:data][:affected_domains].include? 'shop.test' + end end