Merge branch 'repp-domains' of https://github.com/internetee/registry into repp-domains

This commit is contained in:
Karl Erik Õunapuu 2021-02-15 15:24:47 +02:00
commit c1763f80af
No known key found for this signature in database
GPG key ID: C9DD647298A34764
4 changed files with 195 additions and 0 deletions

View file

@ -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
<?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
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
<?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
# puts response.body
puts @domain.registrant
end
end

View file

@ -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

View file

@ -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

View file

@ -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