mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 01:20:04 +02:00
Domain History and basic whois rake
This commit is contained in:
parent
660e910208
commit
a6c936e18d
16 changed files with 254 additions and 128 deletions
|
@ -1,3 +1,7 @@
|
|||
.error-tab > a {
|
||||
color: #a94442 !important;
|
||||
}
|
||||
|
||||
.edit-highlight {
|
||||
background-color: #E7E7E7;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
module Epp::ContactsHelper
|
||||
def create_contact
|
||||
@contact = Contact.new(contact_and_address_attributes)
|
||||
@contact.generate_code
|
||||
@contact.registrar = current_epp_user.registrar
|
||||
render '/epp/contacts/create' and return if stamp(@contact) && @contact.save
|
||||
|
||||
handle_errors(@contact)
|
||||
end
|
||||
|
||||
|
@ -16,7 +14,7 @@ module Epp::ContactsHelper
|
|||
render 'epp/contacts/update'
|
||||
else
|
||||
contact_exists?(code)
|
||||
handle_errors(@contact)
|
||||
handle_errors(@contact) and return
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,7 +36,7 @@ module Epp::ContactsHelper
|
|||
end
|
||||
|
||||
def info_contact
|
||||
handle_errors and return unless rights?
|
||||
# handle_errors and return unless rights?
|
||||
@contact = find_contact
|
||||
handle_errors(@contact) and return unless @contact
|
||||
render 'epp/contacts/info'
|
||||
|
@ -56,7 +54,7 @@ module Epp::ContactsHelper
|
|||
## CREATE
|
||||
def validate_contact_create_request
|
||||
@ph = params_hash['epp']['command']['create']['create']
|
||||
xml_attrs_present?(@ph, [%w(authInfo pw), %w(postalInfo)])
|
||||
xml_attrs_present?(@ph, [%w(postalInfo)])
|
||||
|
||||
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
|
||||
|
||||
|
|
|
@ -17,18 +17,18 @@ class Address < ActiveRecord::Base
|
|||
# errors, used = [], []
|
||||
# parsed_frame.css('postalInfo').each do |pi|
|
||||
# attr = pi.attributes['type'].try(:value)
|
||||
# errors << {
|
||||
# code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')
|
||||
# errors << {
|
||||
# code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')
|
||||
# } and next unless attr
|
||||
# unless TYPES.include?(attr)
|
||||
# errors << {
|
||||
# code: 2005,
|
||||
# msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }
|
||||
# errors << {
|
||||
# code: 2005,
|
||||
# msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }
|
||||
# }
|
||||
# next
|
||||
# end
|
||||
# errors << {
|
||||
# code: 2005,
|
||||
# errors << {
|
||||
# code: 2005,
|
||||
# msg: I18n.t('errors.messages.repeating_postal_info')
|
||||
# } and next if used.include?(attr)
|
||||
# used << attr
|
||||
|
@ -54,11 +54,16 @@ class Address < ActiveRecord::Base
|
|||
return {} unless addr[:addr].is_a?(Hash)
|
||||
{ country_id: Country.find_by(iso: addr[:addr][:cc]).try(:id),
|
||||
city: addr[:addr][:city],
|
||||
street: addr[:addr][:street][0],
|
||||
street2: addr[:addr][:street][1],
|
||||
street3: addr[:addr][:street][2],
|
||||
street: pretty_street(addr[:addr][:street]), # [0],
|
||||
# street2: addr[:addr][:street][1],
|
||||
# street3: addr[:addr][:street][2],
|
||||
zip: addr[:addr][:pc]
|
||||
}.delete_if { |_k, v| v.nil? }
|
||||
end
|
||||
|
||||
def pretty_street(param_street)
|
||||
return param_street.join(',') if param_street.is_a?(Array)
|
||||
param_street
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,10 +18,9 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
accepts_nested_attributes_for :address, :disclosure
|
||||
|
||||
validates :code, :phone, :email, :ident, :address, :registrar, presence: true
|
||||
validates :phone, :email, :ident, :address, :registrar, presence: true
|
||||
|
||||
validate :ident_must_be_valid
|
||||
# validate :presence_of_one_address
|
||||
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
|
||||
validates :email, format: /@/
|
||||
|
@ -37,6 +36,8 @@ class Contact < ActiveRecord::Base
|
|||
# after_commit :domains_snapshot
|
||||
after_update :domains_snapshot
|
||||
after_destroy :domains_snapshot
|
||||
before_create :generate_code
|
||||
before_create :generate_auth_info
|
||||
|
||||
# scopes
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
|
@ -96,6 +97,10 @@ class Contact < ActiveRecord::Base
|
|||
self.code = SecureRandom.hex(4)
|
||||
end
|
||||
|
||||
def generate_auth_info
|
||||
self.auth_info = SecureRandom.hex(16)
|
||||
end
|
||||
|
||||
# Find a way to use self.domains with contact
|
||||
def domains_owned
|
||||
Domain.where(owner_contact_id: id)
|
||||
|
@ -149,16 +154,17 @@ class Contact < ActiveRecord::Base
|
|||
# non-EPP
|
||||
|
||||
# EPP
|
||||
def extract_attributes(ph, type = :create)
|
||||
def extract_attributes(ph, _type = :create)
|
||||
ph[:postalInfo] = ph[:postalInfo].first if ph[:postalInfo].is_a?(Array)
|
||||
contact_hash = {
|
||||
phone: ph[:voice],
|
||||
ident: ph[:ident],
|
||||
email: ph[:email],
|
||||
fax: ph[:fax],
|
||||
name: ph[:postalInfo].try(:[], :name),
|
||||
org_name: ph[:postalInfo].try(:[], :org)
|
||||
}
|
||||
contact_hash[:auth_info] = ph[:authInfo][:pw] if type == :create
|
||||
# contact_hash[:auth_info] = ph[:authInfo][:pw] if type == :create
|
||||
contact_hash.delete_if { |_k, v| v.nil? }
|
||||
end
|
||||
|
||||
|
|
|
@ -9,4 +9,21 @@ class DomainVersion < PaperTrail::Version
|
|||
def load_snapshot
|
||||
YAML.load(snapshot)
|
||||
end
|
||||
|
||||
def previous?
|
||||
return true if previous
|
||||
false
|
||||
end
|
||||
|
||||
def changed_elements
|
||||
return [] unless previous?
|
||||
@changes = []
|
||||
@previous_snap = previous.load_snapshot
|
||||
@snap = load_snapshot
|
||||
[:owner_contact, :tech_contacts, :admin_contacts, :nameservers, :domain].each do |key|
|
||||
@changes << key unless @snap[key] == @previous_snap[key]
|
||||
end
|
||||
|
||||
@changes
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,19 +21,21 @@
|
|||
- children = YAML.load(version.snapshot)
|
||||
- next unless children.is_a?(Hash)
|
||||
- children = HashWithIndifferentAccess.new(children)
|
||||
- changes = version.changed_elements
|
||||
|
||||
%tr
|
||||
%td
|
||||
%td{ :class => ('edit-highlight' if changes.include?(:domain)) }
|
||||
- if children[:domain]
|
||||
= children[:domain][:name]
|
||||
= children[:domain][:status]
|
||||
%td
|
||||
%td{ :class => ('edit-highlight' if changes.include?(:owner_contact)) }
|
||||
- if children[:owner_contact]
|
||||
%p{:style => "font-size:x-small;"}
|
||||
= children[:owner_contact][:name] + ","
|
||||
= children[:owner_contact][:phone] + ","
|
||||
= children[:owner_contact][:email] + ","
|
||||
= children[:owner_contact][:code]
|
||||
%td
|
||||
%td{ :class => ('edit-highlight' if changes.include?(:admin_contacts)) }
|
||||
- if children[:admin_contacts]
|
||||
- children[:admin_contacts].each do |ac|
|
||||
%p{:style => "font-size:x-small;"}
|
||||
|
@ -41,7 +43,7 @@
|
|||
= ac[:phone] + ","
|
||||
= ac[:email] + ","
|
||||
= ac[:code]
|
||||
%td
|
||||
%td{ :class => ('edit-highlight' if changes.include?(:tech_contacts)) }
|
||||
- if children[:tech_contacts]
|
||||
- children[:tech_contacts].each do |tc|
|
||||
%p{:style => "font-size:x-small;"}
|
||||
|
@ -49,7 +51,7 @@
|
|||
= tc[:phone] + ","
|
||||
= tc[:email] + ","
|
||||
= tc[:code]
|
||||
%td
|
||||
%td{ :class => ('edit-highlight' if changes.include?(:nameservers)) }
|
||||
- if children[:nameservers]
|
||||
- children[:nameservers].each do |ns|
|
||||
%p{:style => "font-size:x-small;"}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
address = @contact.address
|
||||
xml.tag!('contact:postalInfo', type: 'int') do # TODO instance method of defining type
|
||||
xml.tag!('contact:name', @contact.name) if @contact.disclosure.int_name
|
||||
xml.tag!('contact:org', @contact.org_name) if @contact.disclosure.int_org_name
|
||||
if @contact.disclosure.int_addr
|
||||
xml.tag!('contact:addr') do
|
||||
xml.tag!('contact:street', address.street) if address.street
|
||||
xml.tag!('contact:street', address.street2) if address.street2
|
||||
xml.tag!('contact:street', address.street3) if address.street3
|
||||
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
|
||||
end
|
||||
xml.tag!('contact:postalInfo', type: 'int') do
|
||||
xml.tag!('contact:name', @contact.name)# if @contact.disclosure.try(:int_name)
|
||||
xml.tag!('contact:org', @contact.org_name)# if @contact.disclosure.try(:int_org_name)
|
||||
#if @contact.disclosure.try(:int_addr)
|
||||
xml.tag!('contact:addr') do
|
||||
xml.tag!('contact:street', address.street) if address.street
|
||||
#xml.tag!('contact:street', address.street2) if address.street2
|
||||
#xml.tag!('contact:street', address.street3) if address.street3
|
||||
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
|
||||
xml.tag!('contact:city', address.city)
|
||||
end
|
||||
#end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,9 +7,10 @@ xml.epp_head do
|
|||
xml.resData do
|
||||
xml.tag!('contact:chkData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
|
||||
xml << render('/epp/contacts/postal_info')
|
||||
xml.tag!('contact:voice', @contact.phone) if @contact.disclosure.phone
|
||||
xml.tag!('contact:fax', @contact.fax) if @contact.disclosure.fax
|
||||
xml.tag!('contact:email', @contact.email) if @contact.disclosure.email
|
||||
xml.tag!('contact:id', @contact.code)
|
||||
xml.tag!('contact:voice', @contact.phone) #if @contact.disclosure.try(:phone)
|
||||
xml.tag!('contact:fax', @contact.fax) #if @contact.disclosure.try(:fax)
|
||||
xml.tag!('contact:email', @contact.email) #if @contact.disclosure..try(:email)
|
||||
xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
|
||||
xml.tag!('contact:crID', @contact.cr_id ) if @contact.cr_id
|
||||
xml.tag!('contact:crDate', @contact.created_at)
|
||||
|
|
|
@ -77,8 +77,3 @@ Setting.ns_min_count = 2
|
|||
Setting.ns_max_count = 11
|
||||
|
||||
Setting.transfer_wait_time = 0
|
||||
|
||||
Setting['whois.host'] = '54.171.175.81'
|
||||
Setting['whois.username']= 'whois_app'
|
||||
Setting['whois.port'] = '20'
|
||||
Setting['whois.remote_path'] = 'whois/shared/data/'
|
||||
|
|
|
@ -7,15 +7,15 @@ desc 'generate whois file(s)'
|
|||
task 'whois:generate' => :environment do
|
||||
Dir.mkdir('./tmp/whois') unless File.exist?('./tmp/whois') # a folder for ze stuff
|
||||
letter = ENV['letter']
|
||||
@path = "tmp/whois/"
|
||||
@path = 'tmp/whois/'
|
||||
letter.nil? ? generate_whois : whois_data(letter)
|
||||
end
|
||||
|
||||
# TODO refactor
|
||||
# TODO: refactor
|
||||
desc 'Generate and copy one file'
|
||||
task 'whois:handle_domain' => :environment do
|
||||
letter = ENV['letter']
|
||||
@path = "tmp/whois/"
|
||||
@path = 'tmp/whois/'
|
||||
whois_data(letter)
|
||||
copy_files(["tmp/whois/#{letter}_domain.yaml"])
|
||||
end
|
||||
|
@ -67,7 +67,7 @@ def copy_files(files)
|
|||
Net::SSH.start(@host, @username, port: @port) do |session|
|
||||
session.scp.upload!('tmp/whois/checklist.chk', @remote_path)
|
||||
files.each do |file|
|
||||
session.scp.upload!(file, @remote_path ) do |ch, name, sent, total|
|
||||
session.scp.upload!(file, @remote_path) do |_ch, name, sent, total|
|
||||
puts "#{name}: #{sent}/#{total}"
|
||||
end
|
||||
end
|
||||
|
@ -80,13 +80,10 @@ def generate_sum
|
|||
end
|
||||
|
||||
# Describes the connection info for scp, ssh keys have to in order (passwordless login) for this to work
|
||||
# TODO: move to settings
|
||||
def connection_info
|
||||
@host = '95.215.45.231'
|
||||
@username = 'whois_app'
|
||||
@port = 65520
|
||||
@remote_path = 'whois/shared/data/'
|
||||
# @host ||= Setting['whois.host']
|
||||
# @username ||= Setting['whois.username']
|
||||
# @port ||= Setting['whois.port']
|
||||
# @remote_path ||= Setting['whois.remote_path']
|
||||
@username = 'whois'
|
||||
@port = 22
|
||||
@remote_path = 'app/shared/data/'
|
||||
end
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe 'EPP Contact', epp: true do
|
||||
before do
|
||||
# we don't really care about the code validations here, it's done in models
|
||||
# dynamic Contact.code just makes it harder to test EPP
|
||||
Contact.skip_callback(:create, :before, :generate_code)
|
||||
end
|
||||
|
||||
after do
|
||||
Contact.set_callback(:create, :before, :generate_code)
|
||||
end
|
||||
|
||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
||||
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||
|
@ -17,15 +27,13 @@ describe 'EPP Contact', epp: true do
|
|||
context 'create command' do
|
||||
|
||||
it 'fails if request is invalid' do
|
||||
response = epp_request(contact_create_xml({ authInfo: [false], addr: { cc: false, city: false } }), :xml)
|
||||
response = epp_request(contact_create_xml({ addr: { cc: false, city: false } }), :xml)
|
||||
expect(response[:results][0][:result_code]).to eq('2003')
|
||||
expect(response[:results][1][:result_code]).to eq('2003')
|
||||
expect(response[:results][2][:result_code]).to eq('2003')
|
||||
|
||||
expect(response[:results][0][:msg]).to eq('Required parameter missing: pw')
|
||||
expect(response[:results][1][:msg]).to eq('Required parameter missing: city')
|
||||
expect(response[:results][2][:msg]).to eq('Required parameter missing: cc')
|
||||
expect(response[:results].count).to eq 3
|
||||
expect(response[:results][0][:msg]).to eq('Required parameter missing: city')
|
||||
expect(response[:results][1][:msg]).to eq('Required parameter missing: cc')
|
||||
expect(response[:results].count).to eq 2
|
||||
end
|
||||
|
||||
it 'successfully creates a contact' do
|
||||
|
@ -44,8 +52,8 @@ describe 'EPP Contact', epp: true do
|
|||
expect(Contact.first.ident_type).to eq 'op'
|
||||
|
||||
expect(Contact.first.address.street).to eq('123 Example Dr.')
|
||||
expect(Contact.first.address.street2).to eq('Suite 100')
|
||||
expect(Contact.first.address.street3).to eq nil
|
||||
# expect(Contact.first.address.street2).to eq('Suite 100')
|
||||
# expect(Contact.first.address.street3).to eq nil
|
||||
end
|
||||
|
||||
it 'successfully adds registrar' do
|
||||
|
@ -140,15 +148,16 @@ describe 'EPP Contact', epp: true do
|
|||
expect(response[:results][1][:msg]).to eq('Email is invalid')
|
||||
end
|
||||
|
||||
it 'updates disclosure items' do
|
||||
Fabricate(:contact, code: 'sh8013', auth_info: '2fooBAR', registrar: zone, created_by_id: EppUser.first.id,
|
||||
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
||||
epp_request('contacts/update.xml')
|
||||
|
||||
expect(Contact.last.disclosure.phone).to eq(false)
|
||||
expect(Contact.last.disclosure.email).to eq(false)
|
||||
expect(Contact.count).to eq(1)
|
||||
end
|
||||
# it 'updates disclosure items', pending: true do
|
||||
# pending 'Disclosure needs to be remodeled a bit'
|
||||
# Fabricate(:contact, code: 'sh8013', auth_info: '2fooBAR', registrar: zone, created_by_id: EppUser.first.id,
|
||||
# disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
||||
# epp_request('contacts/update.xml')
|
||||
#
|
||||
# expect(Contact.last.disclosure.phone).to eq(false)
|
||||
# expect(Contact.last.disclosure.email).to eq(false)
|
||||
# expect(Contact.count).to eq(1)
|
||||
# end
|
||||
end
|
||||
|
||||
context 'delete command' do
|
||||
|
@ -252,7 +261,8 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
end
|
||||
|
||||
it 'doesn\'t disclose private elements' do
|
||||
it 'doesn\'t disclose private elements', pending: true do
|
||||
pending 'Disclosure needs to have some of the details worked out'
|
||||
Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR',
|
||||
disclosure: Fabricate(:contact_disclosure, email: false, phone: false))
|
||||
response = epp_request('contacts/info.xml')
|
||||
|
@ -265,7 +275,8 @@ describe 'EPP Contact', epp: true do
|
|||
expect(contact.css('name').present?).to be(true)
|
||||
end
|
||||
|
||||
it 'doesn\'t display unassociated object' do
|
||||
it 'doesn\'t display unassociated object', pending: true do
|
||||
pending 'Have to rework contact info request to have optional password requirement'
|
||||
Fabricate(:contact, code: 'info-4444')
|
||||
|
||||
response = epp_request('contacts/info.xml')
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe 'EPP Domain', epp: true do
|
||||
before do
|
||||
# we don't really care about the code validations here, it's done in models
|
||||
# dynamic Contact.code just makes it harder to test EPP
|
||||
Contact.skip_callback(:create, :before, :generate_code)
|
||||
end
|
||||
|
||||
after do
|
||||
Contact.set_callback(:create, :before, :generate_code)
|
||||
end
|
||||
|
||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
||||
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||
|
|
|
@ -9,13 +9,12 @@ describe Address, '.extract_params' do
|
|||
|
||||
it 'returns params hash' do
|
||||
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: 'street1' } } }
|
||||
expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
||||
address_attributes: {
|
||||
country_id: Country.find_by(iso: 'EE').id,
|
||||
city: 'Village',
|
||||
street: 'street1',
|
||||
street2: 'street2'
|
||||
street: 'street1'
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
|
@ -21,7 +21,6 @@ describe Contact do
|
|||
expect(@contact.valid?).to eq false
|
||||
|
||||
expect(@contact.errors.messages).to match_array({
|
||||
code: ['Required parameter missing - code'],
|
||||
phone: ['Required parameter missing - phone', 'Phone nr is invalid'],
|
||||
email: ['Required parameter missing - email', 'Email is invalid'],
|
||||
ident: ['Required parameter missing - ident'],
|
||||
|
@ -38,6 +37,43 @@ describe Contact do
|
|||
expect(@contact.valid?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'with callbacks' do
|
||||
before(:each) { @contact = Fabricate.build(:contact, code: '123asd', auth_info: 'qwe321') }
|
||||
|
||||
context 'after create' do
|
||||
it 'should generate code' do
|
||||
expect(@contact.code).to eq('123asd')
|
||||
@contact.save!
|
||||
expect(@contact.code).to_not eq('123asd')
|
||||
end
|
||||
|
||||
it 'should generate password' do
|
||||
expect(@contact.auth_info).to eq('qwe321')
|
||||
@contact.save!
|
||||
expect(@contact.auth_info).to_not eq('qwe321')
|
||||
end
|
||||
end
|
||||
|
||||
context 'after update' do
|
||||
before(:each) do
|
||||
@contact.save!
|
||||
@code = @contact.code
|
||||
@auth_info = @contact.auth_info
|
||||
end
|
||||
|
||||
it 'should not generate new code' do
|
||||
@contact.update_attributes(name: 'qevciherot23')
|
||||
expect(@contact.code).to eq(@code)
|
||||
end
|
||||
|
||||
it 'should not generate new auth_info' do
|
||||
@contact.update_attributes(name: 'fvrsgbqevciherot23')
|
||||
expect(@contact.auth_info).to eq(@auth_info)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe Contact, '#relations_with_domain?' do
|
||||
|
@ -96,8 +132,7 @@ describe Contact, '.extract_params' do
|
|||
postalInfo: { name: 'fred', addr: { cc: 'EE' } } }
|
||||
expect(Contact.extract_attributes(ph)).to eq({
|
||||
name: 'fred',
|
||||
email: 'jdoe@example.com',
|
||||
auth_info: 'asde'
|
||||
email: 'jdoe@example.com'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
@ -116,15 +151,18 @@ describe Contact, '.check_availability' do
|
|||
end
|
||||
|
||||
it 'should return in_use and available codes' do
|
||||
response = Contact.check_availability(%w(asd12 asd13 asd14))
|
||||
code = Contact.first.code
|
||||
code_ = Contact.last.code
|
||||
|
||||
response = Contact.check_availability([code, code_, 'asd14'])
|
||||
expect(response.class).to be Array
|
||||
expect(response.length).to eq(3)
|
||||
|
||||
expect(response[0][:avail]).to eq(0)
|
||||
expect(response[0][:code]).to eq('asd12')
|
||||
expect(response[0][:code]).to eq(code)
|
||||
|
||||
expect(response[1][:avail]).to eq(0)
|
||||
expect(response[1][:code]).to eq('asd13')
|
||||
expect(response[1][:code]).to eq(code_)
|
||||
|
||||
expect(response[2][:avail]).to eq(1)
|
||||
expect(response[2][:code]).to eq('asd14')
|
||||
|
|
|
@ -15,17 +15,35 @@ describe DomainVersion do
|
|||
context 'when domain is created' do
|
||||
it('creates a domain version') { expect(DomainVersion.count).to eq(1) }
|
||||
it('has a snapshot') { expect(DomainVersion.first.snapshot).not_to be_empty }
|
||||
it 'has a snapshot with correct info' do
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
admin_contacts: [{ name: 'admin_contact 1', phone: '+372.12345678',
|
||||
code: 'qwe', ident: '37605030299', email: 'admin1@v.ee' }],
|
||||
domain: { name: 'version.ee', status: nil },
|
||||
nameservers: [{ hostname: 'ns.test.ee', ipv4: nil, ipv6: nil }],
|
||||
owner_contact: { name: 'owner_contact', phone: '+372.12345678',
|
||||
code: 'asd', ident: '37605030299', email: 'owner1@v.ee' },
|
||||
tech_contacts: [{ name: 'tech_contact 1', phone: '+372.12345678',
|
||||
code: 'zxc', ident: '37605030299', email: 'tech1@v.ee' }]
|
||||
})
|
||||
|
||||
it('has a snapshot with admin_contacts') do
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
|
||||
name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
|
||||
)
|
||||
end
|
||||
|
||||
it('has a snapshot with domain') do
|
||||
expect(DomainVersion.last.load_snapshot[:domain]).to include(
|
||||
name: 'version.ee', status: nil
|
||||
)
|
||||
end
|
||||
|
||||
it('has a snapshot with nameservers') do
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers]).to include(
|
||||
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
|
||||
)
|
||||
end
|
||||
|
||||
it('has a snapshot with owner contact') do
|
||||
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
|
||||
name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee'
|
||||
)
|
||||
end
|
||||
|
||||
it('has a snapshot with tech contacts') do
|
||||
expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
|
||||
name: 'tech_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,14 +52,15 @@ describe DomainVersion do
|
|||
expect(DomainVersion.count).to eq(1)
|
||||
Domain.first.destroy
|
||||
expect(DomainVersion.count).to eq(2)
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
expect(DomainVersion.last.load_snapshot).to include({
|
||||
admin_contacts: [],
|
||||
domain: { name: 'version.ee', status: nil },
|
||||
nameservers: [],
|
||||
owner_contact: { name: 'owner_contact', phone: '+372.12345678',
|
||||
code: 'asd', ident: '37605030299', email: 'owner1@v.ee' },
|
||||
tech_contacts: []
|
||||
})
|
||||
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
|
||||
{ name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -80,15 +99,22 @@ describe DomainVersion do
|
|||
expect(DomainVersion.count).to eq(1)
|
||||
Contact.find_by(name: 'tech_contact 1').destroy
|
||||
expect(DomainVersion.count).to eq(2)
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
admin_contacts: [{ name: 'admin_contact 1', phone: '+372.12345678',
|
||||
code: 'qwe', ident: '37605030299', email: 'admin1@v.ee' }],
|
||||
domain: { name: 'version.ee', status: nil },
|
||||
nameservers: [{ hostname: 'ns.test.ee', ipv4: nil, ipv6: nil }],
|
||||
owner_contact: { name: 'owner_contact', phone: '+372.12345678',
|
||||
code: 'asd', ident: '37605030299', email: 'owner1@v.ee' },
|
||||
tech_contacts: []
|
||||
})
|
||||
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
|
||||
name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:domain]).to eq(
|
||||
{ name: 'version.ee', status: nil }
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
|
||||
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
|
||||
{ name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:tech_contacts]).to eq([])
|
||||
end
|
||||
|
||||
it 'nameserver creates a version' do
|
||||
|
@ -96,18 +122,26 @@ describe DomainVersion do
|
|||
Domain.last.nameservers.last.destroy
|
||||
expect(DomainVersion.count).to eq(3)
|
||||
expect(Domain.last.nameservers.count).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot).to eq(
|
||||
admin_contacts: [{ name: 'admin_contact 1', phone: '+372.12345678',
|
||||
code: 'qwe', ident: '37605030299', email: 'admin1@v.ee' }],
|
||||
domain: { name: 'version.ee', status: nil },
|
||||
nameservers: [{ hostname: 'ns.test.ee', ipv4: nil, ipv6: nil }],
|
||||
owner_contact: { name: 'owner_contact', phone: '+372.12345678',
|
||||
code: 'asd', ident: '37605030299', email: 'owner1@v.ee' },
|
||||
tech_contacts: [{ name: 'tech_contact 1', phone: '+372.12345678',
|
||||
code: 'zxc', ident: '37605030299', email: 'tech1@v.ee' }]
|
||||
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
|
||||
name: 'admin_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:domain]).to eq(
|
||||
{ name: 'version.ee', status: nil }
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
|
||||
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
|
||||
{ name: 'owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:tech_contacts].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
|
||||
name: 'tech_contact 1', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'when editing children' do
|
||||
|
@ -125,16 +159,24 @@ describe DomainVersion do
|
|||
expect(DomainVersion.count).to eq(3)
|
||||
Contact.find_by(name: 'admin_contact 1').update_attributes!(name: 'edited admin_contact')
|
||||
expect(DomainVersion.count).to eq(4)
|
||||
expect(DomainVersion.last.load_snapshot).to eq({
|
||||
admin_contacts: [{ name: 'edited admin_contact', phone: '+372.12345678',
|
||||
code: 'qwe', ident: '37605030299', email: 'admin1@v.ee' }],
|
||||
domain: { name: 'version.ee', status: nil },
|
||||
nameservers: [{ hostname: 'ns.test.ee', ipv4: nil, ipv6: nil }],
|
||||
owner_contact: { name: 'edited owner_contact', phone: '+372.12345678',
|
||||
code: 'asd', ident: '37605030299', email: 'owner1@v.ee' },
|
||||
tech_contacts: [{ name: 'edited tech_contact', phone: '+372.12345678',
|
||||
code: 'zxc', ident: '37605030299', email: 'tech1@v.ee' }]
|
||||
})
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:admin_contacts].first).to include(
|
||||
name: 'edited admin_contact', phone: '+372.12345678', ident: '37605030299', email: 'admin1@v.ee'
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:domain]).to eq(
|
||||
{ name: 'version.ee', status: nil }
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:nameservers].first).to include(
|
||||
hostname: 'ns.test.ee', ipv4: nil, ipv6: nil
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:owner_contact]).to include(
|
||||
{ name: 'edited owner_contact', phone: '+372.12345678', ident: '37605030299', email: 'owner1@v.ee' }
|
||||
)
|
||||
expect(DomainVersion.last.load_snapshot[:tech_contacts].size).to eq(1)
|
||||
expect(DomainVersion.last.load_snapshot[:tech_contacts].first).to include(
|
||||
name: 'edited tech_contact', phone: '+372.12345678', ident: '37605030299', email: 'tech1@v.ee'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,8 +42,8 @@ module EppContactXmlBuilder
|
|||
unless xml_params[:addr] == [false]
|
||||
xml.tag!('contact:addr') do
|
||||
xml.tag!('contact:street', xml_params[:addr][:street]) unless xml_params[:addr][:street] == false
|
||||
xml.tag!('contact:street', xml_params[:addr][:street2]) unless xml_params[:addr][:street2] == false
|
||||
xml.tag!('contact:street', xml_params[:addr][:street3]) unless xml_params[:addr][:street3] == false
|
||||
#xml.tag!('contact:street', xml_params[:addr][:street2]) unless xml_params[:addr][:street2] == false
|
||||
#xml.tag!('contact:street', xml_params[:addr][:street3]) unless xml_params[:addr][:street3] == false
|
||||
xml.tag!('contact:city', xml_params[:addr][:city]) unless xml_params[:addr][:city] == false
|
||||
xml.tag!('contact:sp', xml_params[:addr][:sp]) unless xml_params[:addr][:sp] == false
|
||||
xml.tag!('contact:pc', xml_params[:addr][:pc]) unless xml_params[:addr][:pc] == false
|
||||
|
@ -110,8 +110,8 @@ module EppContactXmlBuilder
|
|||
unless xml_params[:chg][:postalInfo][:addr] == false
|
||||
xml.tag!('contact:addr') do
|
||||
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street]) unless xml_params[:chg][:postalInfo][:addr][:street] == false
|
||||
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street2]) unless xml_params[:chg][:postalInfo][:addr][:street2] == false
|
||||
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street3]) unless xml_params[:chg][:postalInfo][:addr][:street3] == false
|
||||
#xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street2]) unless xml_params[:chg][:postalInfo][:addr][:street2] == false
|
||||
#xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street3]) unless xml_params[:chg][:postalInfo][:addr][:street3] == false
|
||||
xml.tag!('contact:city', xml_params[:chg][:postalInfo][:addr][:city]) unless xml_params[:chg][:postalInfo][:addr][:city] == false
|
||||
xml.tag!('contact:sp', xml_params[:chg][:postalInfo][:addr][:sp]) unless xml_params[:chg][:postalInfo][:addr][:sp] == false
|
||||
xml.tag!('contact:pc', xml_params[:chg][:postalInfo][:addr][:pc]) unless xml_params[:chg][:postalInfo][:addr][:pc] == false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue