mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
commit
97ca7198fa
7 changed files with 77 additions and 72 deletions
|
@ -51,4 +51,4 @@ class UpdateWhoisRecordJob < Que::Job
|
|||
def delete_blocked(name)
|
||||
delete_reserved(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,6 +36,7 @@ class WhoisRecord < ActiveRecord::Base
|
|||
registrant = domain.registrant
|
||||
|
||||
@disclosed = []
|
||||
h[:disclaimer] = disclaimer_text if disclaimer_text.present?
|
||||
h[:name] = domain.name
|
||||
h[:status] = domain.statuses.map { |x| status_map[x] || x }
|
||||
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
|
||||
|
@ -120,4 +121,10 @@ class WhoisRecord < ActiveRecord::Base
|
|||
def destroy_whois_record
|
||||
Whois::Record.where(name: name).delete_all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def disclaimer_text
|
||||
Setting.registry_whois_disclaimer
|
||||
end
|
||||
end
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
= render 'setting_row', var: :registry_state
|
||||
= render 'setting_row', var: :registry_zip
|
||||
= render 'setting_row', var: :registry_country_code
|
||||
= render 'setting_row', var: :registry_whois_disclaimer
|
||||
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<%- if json['disclaimer'].present? -%>
|
||||
<%= json['disclaimer'].scan(/\S.{0,72}\S(?=\s|$)|\S+/).join("\n") %>
|
||||
<%- end -%>
|
||||
Estonia .ee Top Level Domain WHOIS server
|
||||
|
||||
Domain:
|
||||
|
@ -23,18 +26,18 @@ changed: <%= json['registrant_changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
|||
<%- if json['admin_contacts'].present? -%>
|
||||
Administrative contact:
|
||||
<%- for contact in json['admin_contacts'] -%>
|
||||
name: <%= contact['name'] %>
|
||||
name: Not Disclosed
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: Not Disclosed
|
||||
<%- end -%>
|
||||
|
||||
<%- end -%>
|
||||
<% if json['tech_contacts'].present? %>
|
||||
Technical contact:
|
||||
<%- for contact in json['tech_contacts'] -%>
|
||||
name: <%= contact['name'] %>
|
||||
name: Not Disclosed
|
||||
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
|
||||
changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %>
|
||||
changed: Not Disclosed
|
||||
<%- end -%>
|
||||
|
||||
<%- end -%>
|
||||
|
|
|
@ -72,4 +72,5 @@ if con.present? && con.table_exists?('settings')
|
|||
Setting.save_default(:registry_bank_code, '689')
|
||||
Setting.save_default(:registry_swift, 'LHVBEE22')
|
||||
Setting.save_default(:registry_invoice_contact, 'Martti Õigus')
|
||||
Setting.save_default(:registry_whois_disclaimer, 'Search results may not be used for commercial, advertising, recompilation, repackaging, redistribution, reuse, obscuring or other similar activities.')
|
||||
end
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WhoisRecord do
|
||||
describe '::generate_json', db: false do
|
||||
let(:registrant) { build_stubbed(:registrant) }
|
||||
let(:domain) { 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) { 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) { 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) { 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) { build_stubbed(:registrant_private_entity) }
|
||||
|
||||
it 'is absent' do
|
||||
expect(country_code).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
60
test/models/whois_record_test.rb
Normal file
60
test/models/whois_record_test.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
require 'test_helper'
|
||||
|
||||
class WhoisRecordTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:shop)
|
||||
@record = WhoisRecord.new(domain: @domain)
|
||||
@record.populate
|
||||
end
|
||||
|
||||
def test_generated_json_has_expected_values
|
||||
expected_disclaimer_text = <<-TEXT.squish
|
||||
Search results may not be used for commercial, advertising, recompilation,
|
||||
repackaging, redistribution, reuse, obscuring or other similar activities.
|
||||
TEXT
|
||||
|
||||
expected_partial_hash = {
|
||||
disclaimer: expected_disclaimer_text,
|
||||
name: 'shop.test',
|
||||
registrant: 'John',
|
||||
registrant_kind: 'priv',
|
||||
email: 'john@inbox.test',
|
||||
expire: '2010-07-05',
|
||||
nameservers: ['ns1.bestnames.test', 'ns2.bestnames.test'],
|
||||
registrar_address: 'Main Street, New York, New York, 12345',
|
||||
dnssec_keys: [],
|
||||
}
|
||||
|
||||
expected_partial_hash.each do |key, value|
|
||||
assert_equal(value, @record.generated_json[key])
|
||||
end
|
||||
end
|
||||
|
||||
def test_generated_body_has_justified_disclaimer
|
||||
expected_disclaimer = begin
|
||||
'Search results may not be used for commercial, advertising, recompilation,\n' \
|
||||
'repackaging, redistribution, reuse, obscuring or other similar activities.'
|
||||
end
|
||||
expected_technical_contact = begin
|
||||
'Technical contact:\n' \
|
||||
'name: Not Disclosed\n' \
|
||||
'email: Not Disclosed - Visit www.internet.ee for webbased WHOIS\n' \
|
||||
'changed: Not Disclosed'
|
||||
end
|
||||
|
||||
regexp_contact = Regexp.new(expected_technical_contact, Regexp::MULTILINE)
|
||||
regexp_disclaimer = Regexp.new(expected_disclaimer, Regexp::MULTILINE)
|
||||
|
||||
assert_match(regexp_disclaimer, @record.body)
|
||||
assert_match(regexp_contact, @record.body)
|
||||
end
|
||||
|
||||
def test_whois_record_has_no_disclaimer_if_Setting_is_blank
|
||||
Setting.stubs(:registry_whois_disclaimer, '') do
|
||||
refute(@record.json['disclaimer'])
|
||||
refute_match(/Search results may not be used for commercial/, @record.body)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue