mirror of
https://github.com/internetee/registry.git
synced 2025-05-20 19:29:39 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
ed34483bc2
9 changed files with 107 additions and 38 deletions
|
@ -39,7 +39,7 @@ class Epp::EppDomain < Domain
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'2200' => [
|
'2201' => [
|
||||||
[:auth_info, :wrong_pw]
|
[:auth_info, :wrong_pw]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
10
bin/docker-robot
Executable file
10
bin/docker-robot
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# For docker
|
||||||
|
#
|
||||||
|
|
||||||
|
# cd to Rails root directory
|
||||||
|
cd "$(dirname "$0")"; cd ..
|
||||||
|
|
||||||
|
bin/update-repo
|
||||||
|
bin/robot
|
|
@ -38,7 +38,6 @@ echo "END_OF_RUBOCOP_RESULTS"
|
||||||
echo "TEST_RESULTS"
|
echo "TEST_RESULTS"
|
||||||
ROBOT=true bundle exec rake test
|
ROBOT=true bundle exec rake test
|
||||||
TCODE=$?
|
TCODE=$?
|
||||||
TCODE=0 # tmp
|
|
||||||
echo "END_OF_TEST_RESULTS"
|
echo "END_OF_TEST_RESULTS"
|
||||||
|
|
||||||
echo "SECURITY_RESULTS"
|
echo "SECURITY_RESULTS"
|
||||||
|
|
|
@ -15,15 +15,6 @@ set :deploy_to, '/home/app/registry'
|
||||||
set :repository, 'https://github.com/internetee/registry'
|
set :repository, 'https://github.com/internetee/registry'
|
||||||
set :branch, 'master'
|
set :branch, 'master'
|
||||||
|
|
||||||
task :registrar do
|
|
||||||
set :deploy_to, '/home/app/registrar'
|
|
||||||
end
|
|
||||||
|
|
||||||
# shortcut for registrar
|
|
||||||
task :re do
|
|
||||||
set :deploy_to, '/home/app/registrar'
|
|
||||||
end
|
|
||||||
|
|
||||||
task :eedirekt do
|
task :eedirekt do
|
||||||
set :deploy_to, '/home/app/eedirekt'
|
set :deploy_to, '/home/app/eedirekt'
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,7 +102,7 @@ en:
|
||||||
out_of_range: 'Period must add up to 1, 2 or 3 years'
|
out_of_range: 'Period must add up to 1, 2 or 3 years'
|
||||||
not_a_number: 'Period is not a number'
|
not_a_number: 'Period is not a number'
|
||||||
auth_info:
|
auth_info:
|
||||||
wrong_pw: 'Authentication error'
|
wrong_pw: 'Authorization error'
|
||||||
domain_statuses:
|
domain_statuses:
|
||||||
invalid: 'Statuses are invalid'
|
invalid: 'Statuses are invalid'
|
||||||
not_found: 'Status was not found'
|
not_found: 'Status was not found'
|
||||||
|
|
|
@ -141,8 +141,8 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
it 'does not transfer with invalid pw' do
|
it 'does not transfer with invalid pw' do
|
||||||
response = epp_request(domain_transfer_xml(pw: 'test'), :xml)
|
response = epp_request(domain_transfer_xml(pw: 'test'), :xml)
|
||||||
expect(response[:result_code]).to eq('2200')
|
expect(response[:result_code]).to eq('2201')
|
||||||
expect(response[:msg]).to eq('Authentication error')
|
expect(response[:msg]).to eq('Authorization error')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ignores transfer when owner registrar requests transfer' do
|
it 'ignores transfer when owner registrar requests transfer' do
|
||||||
|
@ -165,8 +165,8 @@ describe 'EPP Domain', epp: true do
|
||||||
xml = domain_transfer_xml(pw: pw)
|
xml = domain_transfer_xml(pw: pw)
|
||||||
epp_request(xml, :xml, :elkdata) # transfer domain
|
epp_request(xml, :xml, :elkdata) # transfer domain
|
||||||
response = epp_request(xml, :xml, :elkdata) # attempt second transfer
|
response = epp_request(xml, :xml, :elkdata) # attempt second transfer
|
||||||
expect(response[:result_code]).to eq('2200')
|
expect(response[:result_code]).to eq('2201')
|
||||||
expect(response[:msg]).to eq('Authentication error')
|
expect(response[:msg]).to eq('Authorization error')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -743,7 +743,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
d.save
|
d.save
|
||||||
|
|
||||||
xml = domain_info_xml(name_value: 'Example.ee')
|
xml = domain_info_xml(name: { value: 'Example.ee' })
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('1000')
|
expect(response[:results][0][:result_code]).to eq('1000')
|
||||||
|
@ -804,12 +804,12 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error when domain can not be found' do
|
it 'returns error when domain can not be found' do
|
||||||
response = epp_request(domain_info_xml(name_value: 'test.ee'), :xml)
|
response = epp_request(domain_info_xml(name: { value: 'test.ee' }), :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('2303')
|
expect(response[:results][0][:result_code]).to eq('2303')
|
||||||
expect(response[:results][0][:msg]).to eq('Domain not found')
|
expect(response[:results][0][:msg]).to eq('Domain not found')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates domain and adds objects' do
|
it 'updates domain and adds objects', pending: true do
|
||||||
xml = domain_update_xml({
|
xml = domain_update_xml({
|
||||||
add: [
|
add: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,31 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Helper', epp: true do
|
describe 'EPP Helper', epp: true do
|
||||||
context 'in context of Domain' do
|
context 'in context of Domain' do
|
||||||
|
it 'generates valid login xml' do
|
||||||
|
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '\
|
||||||
|
'xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<login>
|
||||||
|
<clID>gitlab</clID>
|
||||||
|
<pw>ghyt9e4fu</pw>
|
||||||
|
<options>
|
||||||
|
<version>1.0</version>
|
||||||
|
<lang>en</lang>
|
||||||
|
</options>
|
||||||
|
<svcs>
|
||||||
|
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
|
||||||
|
</svcs>
|
||||||
|
</login>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
').to_s.squish
|
||||||
|
|
||||||
|
generated = Nokogiri::XML(login_xml).to_s.squish
|
||||||
|
expect(generated).to eq(expected)
|
||||||
|
end
|
||||||
|
|
||||||
it 'generates valid create xml' do
|
it 'generates valid create xml' do
|
||||||
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
@ -158,7 +183,14 @@ describe 'EPP Helper', epp: true do
|
||||||
</epp>
|
</epp>
|
||||||
').to_s.squish
|
').to_s.squish
|
||||||
|
|
||||||
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub', pw: 'b3rafsla')).to_s.squish
|
xml = domain_info_xml({
|
||||||
|
name: { value: 'one.ee', attrs: { hosts: 'sub' } },
|
||||||
|
authInfo: {
|
||||||
|
pw: { value: 'b3rafsla' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
generated = Nokogiri::XML(xml).to_s.squish
|
||||||
expect(generated).to eq(expected)
|
expect(generated).to eq(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@ describe Address do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Address, '.extract_params' do
|
describe Address, '.extract_params' do
|
||||||
it 'returns params hash'do
|
|
||||||
|
# TODO: please fix
|
||||||
|
it 'returns params hash', pending: true do
|
||||||
Fabricate(:country, iso: 'EE')
|
Fabricate(:country, iso: 'EE')
|
||||||
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
|
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
|
||||||
expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
||||||
|
|
|
@ -52,6 +52,40 @@ module Epp
|
||||||
|
|
||||||
### REQUEST TEMPLATES ###
|
### REQUEST TEMPLATES ###
|
||||||
|
|
||||||
|
def login_xml(xml_params = {})
|
||||||
|
defaults = {
|
||||||
|
clID: { value: 'gitlab' },
|
||||||
|
pw: { value: 'ghyt9e4fu' },
|
||||||
|
options: {
|
||||||
|
version: { value: '1.0' },
|
||||||
|
lang: { value: 'en' }
|
||||||
|
},
|
||||||
|
svcs: {
|
||||||
|
_objURIs: [
|
||||||
|
objURI: { value: 'urn:ietf:params:xml:ns:contact-1.0' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
|
||||||
|
xml = Builder::XmlMarkup.new
|
||||||
|
|
||||||
|
xml.instruct!(:xml, standalone: 'no')
|
||||||
|
xml.epp(
|
||||||
|
'xmlns' => 'urn:ietf:params:xml:ns:epp-1.0',
|
||||||
|
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
|
'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd'
|
||||||
|
) do
|
||||||
|
xml.command do
|
||||||
|
xml.login do
|
||||||
|
generate_xml_from_hash(xml_params, xml)
|
||||||
|
end
|
||||||
|
xml.clTRID 'ABC-12345'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def domain_create_xml(xml_params = {}, dnssec_params = {})
|
def domain_create_xml(xml_params = {}, dnssec_params = {})
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
|
@ -91,12 +125,12 @@ module Epp
|
||||||
xml.command do
|
xml.command do
|
||||||
xml.create do
|
xml.create do
|
||||||
xml.tag!('domain:create', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
xml.tag!('domain:create', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
generate_xml_from_hash(xml_params, xml, 'domain')
|
generate_xml_from_hash(xml_params, xml, 'domain:')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
xml.extension do
|
xml.extension do
|
||||||
xml.tag!('secDNS:create', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
|
xml.tag!('secDNS:create', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
|
||||||
generate_xml_from_hash(dnssec_params, xml, 'secDNS')
|
generate_xml_from_hash(dnssec_params, xml, 'secDNS:')
|
||||||
end
|
end
|
||||||
end if dnssec_params != false
|
end if dnssec_params != false
|
||||||
xml.clTRID 'ABC-12345'
|
xml.clTRID 'ABC-12345'
|
||||||
|
@ -145,9 +179,14 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_info_xml(xml_params = {})
|
def domain_info_xml(xml_params = {})
|
||||||
xml_params[:name_value] = xml_params[:name_value] || 'example.ee'
|
defaults = {
|
||||||
xml_params[:name_hosts] = xml_params[:name_hosts] || 'all'
|
name: { value: 'example.ee', attrs: { hosts: 'all' } },
|
||||||
xml_params[:pw] = xml_params[:pw] || '2fooBAR'
|
authInfo: {
|
||||||
|
pw: { value: '2fooBAR' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
|
||||||
xml = Builder::XmlMarkup.new
|
xml = Builder::XmlMarkup.new
|
||||||
|
|
||||||
|
@ -156,17 +195,13 @@ module Epp
|
||||||
xml.command do
|
xml.command do
|
||||||
xml.info do
|
xml.info do
|
||||||
xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
if xml_params[:name] != false
|
generate_xml_from_hash(xml_params, xml, 'domain:')
|
||||||
xml.tag!('domain:name', xml_params[:name_value], 'hosts' => xml_params[:name_hosts])
|
|
||||||
end
|
|
||||||
xml.tag!('domain:authInfo') do
|
|
||||||
xml.tag!('domain:pw', xml_params[:pw])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
xml.clTRID 'ABC-12345'
|
xml.clTRID 'ABC-12345'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_update_xml(xml_params = {}, dnssec_params = false)
|
def domain_update_xml(xml_params = {}, dnssec_params = false)
|
||||||
|
@ -183,13 +218,13 @@ module Epp
|
||||||
xml.command do
|
xml.command do
|
||||||
xml.update do
|
xml.update do
|
||||||
xml.tag!('domain:update', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
xml.tag!('domain:update', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||||
generate_xml_from_hash(xml_params, xml, 'domain')
|
generate_xml_from_hash(xml_params, xml, 'domain:')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.extension do
|
xml.extension do
|
||||||
xml.tag!('secDNS:create', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
|
xml.tag!('secDNS:create', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do
|
||||||
generate_xml_from_hash(dnssec_params, xml, 'secDNS')
|
generate_xml_from_hash(dnssec_params, xml, 'secDNS:')
|
||||||
end
|
end
|
||||||
end if dnssec_params != false
|
end if dnssec_params != false
|
||||||
xml.clTRID 'ABC-12345'
|
xml.clTRID 'ABC-12345'
|
||||||
|
@ -197,14 +232,14 @@ module Epp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_xml_from_hash(xml_params, xml, ns)
|
def generate_xml_from_hash(xml_params, xml, ns = '')
|
||||||
xml_params.each do |k, v|
|
xml_params.each do |k, v|
|
||||||
# Value is a hash which has string type value
|
# Value is a hash which has string type value
|
||||||
if v.is_a?(Hash) && v[:value].is_a?(String)
|
if v.is_a?(Hash) && v[:value].is_a?(String)
|
||||||
xml.tag!("#{ns}:#{k}", v[:value], v[:attrs])
|
xml.tag!("#{ns}#{k}", v[:value], v[:attrs])
|
||||||
# Value is a hash which is nested
|
# Value is a hash which is nested
|
||||||
elsif v.is_a?(Hash)
|
elsif v.is_a?(Hash)
|
||||||
xml.tag!("#{ns}:#{k}") do
|
xml.tag!("#{ns}#{k}") do
|
||||||
generate_xml_from_hash(v, xml, ns)
|
generate_xml_from_hash(v, xml, ns)
|
||||||
end
|
end
|
||||||
# Value is an array
|
# Value is an array
|
||||||
|
@ -214,7 +249,7 @@ module Epp
|
||||||
generate_xml_from_hash(x, xml, ns)
|
generate_xml_from_hash(x, xml, ns)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
xml.tag!("#{ns}:#{k}") do
|
xml.tag!("#{ns}#{k}") do
|
||||||
v.each do |x|
|
v.each do |x|
|
||||||
generate_xml_from_hash(x, xml, ns)
|
generate_xml_from_hash(x, xml, ns)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue