mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 07:52:04 +02:00
parent
e6069e06a9
commit
36760a3802
4 changed files with 86 additions and 6 deletions
|
@ -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('+', ' +') %>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
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