mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
commit
afc65b39c7
8 changed files with 122 additions and 6 deletions
|
@ -1,3 +1,6 @@
|
|||
22.12.2016
|
||||
* Return business registry code and country for 'org' type registrants in WHOIS and Rest-WHOIS
|
||||
|
||||
16.12.2016
|
||||
* Allow contact address processing to be configurable via admin
|
||||
* EPP XML schema namespace "urn:ietf:params:xml:ns:epp-1.0" replaced with "https://epp.tld.ee/schema/epp-ee-1.0.xsd"
|
||||
|
|
|
@ -15,6 +15,7 @@ class Contact < ActiveRecord::Base
|
|||
has_paper_trail class_name: "ContactVersion", meta: { children: :children_log }
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
alias_attribute :kind, :ident_type
|
||||
|
||||
accepts_nested_attributes_for :legal_documents
|
||||
|
||||
|
@ -583,4 +584,9 @@ class Contact < ActiveRecord::Base
|
|||
self[attr_name.to_sym] = nil
|
||||
end
|
||||
end
|
||||
|
||||
def reg_no
|
||||
return if priv?
|
||||
ident
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,8 @@ class WhoisRecord < ActiveRecord::Base
|
|||
'ok' => 'ok (paid and in zone)'
|
||||
}
|
||||
|
||||
registrant = domain.registrant
|
||||
|
||||
@disclosed = []
|
||||
h[:name] = domain.name
|
||||
h[:status] = domain.statuses.map { |x| status_map[x] || x }
|
||||
|
@ -50,11 +52,17 @@ class WhoisRecord < ActiveRecord::Base
|
|||
h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s)
|
||||
h[:delete] = [domain.delete_at, domain.force_delete_at].compact.min.try(:to_date).try(:to_s)
|
||||
|
||||
h[:registrant] = registrant.name
|
||||
h[:registrant_kind] = registrant.kind
|
||||
|
||||
h[:registrant] = domain.registrant.name
|
||||
h[:email] = domain.registrant.email
|
||||
@disclosed << [:email, domain.registrant.email]
|
||||
h[:registrant_changed] = domain.registrant.updated_at.try(:to_s, :iso8601)
|
||||
if registrant.org?
|
||||
h[:registrant_reg_no] = registrant.reg_no
|
||||
h[:registrant_ident_country_code] = registrant.ident_country_code
|
||||
end
|
||||
|
||||
h[:email] = registrant.email
|
||||
@disclosed << [:email, registrant.email]
|
||||
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
|
||||
|
||||
h[:admin_contacts] = []
|
||||
domain.admin_contacts.each do |ac|
|
||||
|
@ -82,14 +90,14 @@ class WhoisRecord < ActiveRecord::Base
|
|||
h[:registrar_address] = domain.registrar.address
|
||||
h[:registrar_changed] = domain.registrar.updated_at.try(:to_s, :iso8601)
|
||||
|
||||
h[:nameservers] = domain.nameservers.pluck(:hostname).uniq.select(&:present?)
|
||||
h[:nameservers] = domain.nameservers.hostnames.uniq.select(&:present?)
|
||||
h[:nameservers_changed] = domain.nameservers.pluck(:updated_at).max.try(:to_s, :iso8601)
|
||||
|
||||
h[:dnssec_keys] = domain.dnskeys.map{|key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
|
||||
h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil
|
||||
|
||||
|
||||
h[:disclosed] = @disclosed # later we can replace
|
||||
h[:disclosed] = @disclosed
|
||||
h
|
||||
end
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ delete: <%= json['delete'].to_s.tr('T',' ').sub('+', ' +') %>
|
|||
|
||||
Registrant:
|
||||
name: <%= json['registrant'] %>
|
||||
org id: <%= json['registrant_reg_no'] %>
|
||||
country: <%= json['registrant_ident_country_code'] %>
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= json['registrant_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
|
||||
|
|
|
@ -12,5 +12,14 @@ FactoryGirl.define do
|
|||
ident_type 'priv'
|
||||
ident_country_code 'EE'
|
||||
registrar
|
||||
|
||||
factory :contact_private_entity do
|
||||
ident_type 'priv'
|
||||
end
|
||||
|
||||
factory :contact_legal_entity do
|
||||
ident_type 'org'
|
||||
ident '12345678' # valid reg no for .ee
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :registrant, parent: :contact, class: Registrant do
|
||||
name 'test'
|
||||
|
||||
factory :registrant_private_entity, class: Registrant, parent: :contact_private_entity
|
||||
factory :registrant_legal_entity, class: Registrant, parent: :contact_legal_entity
|
||||
end
|
||||
end
|
||||
|
|
|
@ -361,6 +361,8 @@ describe Contact, '.destroy_orphans' do
|
|||
end
|
||||
|
||||
RSpec.describe Contact, db: false do
|
||||
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
||||
|
||||
describe '::names' do
|
||||
before :example do
|
||||
expect(described_class).to receive(:pluck).with(:name).and_return('names')
|
||||
|
@ -463,4 +465,20 @@ RSpec.describe Contact, db: false do
|
|||
expect(address_removed).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reg_no' do
|
||||
subject(:reg_no) { contact.reg_no }
|
||||
|
||||
context 'when contact is legal entity' do
|
||||
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
|
||||
|
||||
specify { expect(reg_no).to eq('1234') }
|
||||
end
|
||||
|
||||
context 'when contact is private entity' do
|
||||
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
|
||||
|
||||
specify { expect(reg_no).to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
67
spec/models/whois_record_spec.rb
Normal file
67
spec/models/whois_record_spec.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WhoisRecord do
|
||||
describe '::generate_json', db: false do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant) }
|
||||
let(:domain) { FactoryGirl.build_stubbed(:domain, registrant: registrant) }
|
||||
let(:whois_record) { described_class.new }
|
||||
subject(:generated_json) { whois_record.generate_json }
|
||||
|
||||
before do
|
||||
allow(whois_record).to receive(:domain).and_return(domain)
|
||||
end
|
||||
|
||||
it 'generates registrant kind' do
|
||||
expect(registrant).to receive(:kind).and_return('test kind')
|
||||
expect(generated_json[:registrant_kind]).to eq('test kind')
|
||||
end
|
||||
|
||||
describe 'reg no' do
|
||||
subject(:reg_no) { generated_json[:registrant_reg_no] }
|
||||
|
||||
before do
|
||||
allow(registrant).to receive(:reg_no).and_return('test reg no')
|
||||
end
|
||||
|
||||
context 'when registrant is legal entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) }
|
||||
|
||||
it 'is present' do
|
||||
expect(reg_no).to eq('test reg no')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when registrant is private entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) }
|
||||
|
||||
it 'is absent' do
|
||||
expect(reg_no).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'country code' do
|
||||
subject(:country_code) { generated_json[:registrant_ident_country_code] }
|
||||
|
||||
before do
|
||||
allow(registrant).to receive(:ident_country_code).and_return('test country code')
|
||||
end
|
||||
|
||||
context 'when registrant is legal entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) }
|
||||
|
||||
it 'is present' do
|
||||
expect(country_code).to eq('test country code')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when registrant is private entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) }
|
||||
|
||||
it 'is absent' do
|
||||
expect(country_code).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue