mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Add different ip version support to nameserver
This commit is contained in:
parent
a846a51444
commit
793b0d22ff
7 changed files with 18 additions and 13 deletions
|
@ -113,10 +113,10 @@ class Domain < ActiveRecord::Base
|
|||
if ns[:hostAddr]
|
||||
if ns[:hostAddr].is_a?(Array)
|
||||
ns[:hostAddr].each do |ip|
|
||||
attrs[:ip] = ip unless attrs[:ip]
|
||||
attrs[:ipv4] = ip unless attrs[:ipv4]
|
||||
end
|
||||
else
|
||||
attrs[:ip] = ns[:hostAddr]
|
||||
attrs[:ipv4] = ns[:hostAddr]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ class Nameserver < ActiveRecord::Base
|
|||
include EppErrors
|
||||
|
||||
EPP_CODE_MAP = {
|
||||
'2005' => ['Hostname is invalid', 'IP is invalid']
|
||||
'2005' => ['Hostname is invalid', 'IPv4 is invalid']
|
||||
}
|
||||
|
||||
EPP_ATTR_MAP = {
|
||||
|
@ -13,5 +13,5 @@ class Nameserver < ActiveRecord::Base
|
|||
has_and_belongs_to_many :domains
|
||||
|
||||
validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
|
||||
validates :ip, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_nil: true }
|
||||
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_nil: true }
|
||||
end
|
||||
|
|
|
@ -51,15 +51,15 @@ en:
|
|||
nameservers:
|
||||
out_of_range: 'Nameservers count must be between %{min}-%{max}'
|
||||
hostname_invalid: 'Hostname is invalid'
|
||||
ip_invalid: 'IP is invalid'
|
||||
ip_invalid: 'IPv4 is invalid'
|
||||
period:
|
||||
out_of_range: 'Period must add up to 1, 2 or 3 years'
|
||||
nameserver:
|
||||
attributes:
|
||||
hostname:
|
||||
invalid: 'Hostname is invalid'
|
||||
ip:
|
||||
invalid: 'IP is invalid'
|
||||
ipv4:
|
||||
invalid: 'IPv4 is invalid'
|
||||
attributes:
|
||||
domain:
|
||||
name: 'Domain name'
|
||||
|
|
6
db/migrate/20140813135408_add_ipv6_to_nameserver.rb
Normal file
6
db/migrate/20140813135408_add_ipv6_to_nameserver.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class AddIpv6ToNameserver < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :nameservers, :ip, :ipv4
|
||||
add_column :nameservers, :ipv6, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140813102245) do
|
||||
ActiveRecord::Schema.define(version: 20140813135408) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -108,10 +108,11 @@ ActiveRecord::Schema.define(version: 20140813102245) do
|
|||
|
||||
create_table "nameservers", force: true do |t|
|
||||
t.string "hostname"
|
||||
t.string "ip"
|
||||
t.string "ipv4"
|
||||
t.integer "ns_set_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "ipv6"
|
||||
end
|
||||
|
||||
create_table "nameservers_ns_sets", force: true do |t|
|
||||
|
|
|
@ -104,13 +104,13 @@ describe 'EPP Domain', epp: true do
|
|||
response = epp_request('domains/create_w_host_attrs.xml')
|
||||
expect(Domain.first.nameservers.count).to eq(2)
|
||||
ns = Domain.first.nameservers.first
|
||||
expect(ns.ip).to eq('192.0.2.2')
|
||||
expect(ns.ipv4).to eq('192.0.2.2')
|
||||
end
|
||||
|
||||
it 'returns error when nameserver has invalid ip' do
|
||||
response = epp_request('domains/create_w_invalid_ns_ip.xml')
|
||||
expect(response[:results][0][:result_code]).to eq '2005'
|
||||
expect(response[:results][0][:msg]).to eq 'IP is invalid'
|
||||
expect(response[:results][0][:msg]).to eq 'IPv4 is invalid'
|
||||
end
|
||||
|
||||
it 'creates a domain with period in days' do
|
||||
|
|
|
@ -43,8 +43,6 @@ module Epp
|
|||
|
||||
### REQUEST TEMPLATES ###
|
||||
|
||||
# THIS FEATURE IS EXPERIMENTAL AND NOT IN USE ATM
|
||||
|
||||
def domain_create_xml(xml_params={})
|
||||
xml_params[:nameservers] = xml_params[:nameservers] || [{hostObj: 'ns1.example.net'}, {hostObj: 'ns2.example.net'}]
|
||||
xml_params[:contacts] = xml_params[:contacts] || [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue