Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-03-27 15:50:59 +02:00
commit e35f445860
11 changed files with 75 additions and 33 deletions

View file

@ -10,6 +10,7 @@ group :red_green_refactor, halt_on_fail: true do
# end # end
guard :rspec, cmd: 'spring rspec --fail-fast', notification: false do guard :rspec, cmd: 'spring rspec --fail-fast', notification: false do
# guard :rspec, cmd: 'spring rspec', notification: false do
watch(%r{^spec/.+_spec\.rb$}) watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" } watch('spec/spec_helper.rb') { "spec" }

View file

@ -8,10 +8,15 @@ module Repp
end end
before do before do
next if Rails.env.test?
message = 'Certificate mismatch! Cert common name should be:'
request_name = ENV['HTTP_SSL_CLIENT_S_DN_CN']
if request.ip == ENV['webclient_ip'] if request.ip == ENV['webclient_ip']
error! 'Certificate mismatch', 401 if env['HTTP_SSL_CLIENT_S_DN_CN'] != 'webclient' webclient_cert_name = ENV['webclient_cert_common_name'] || 'webclient'
error! "#{message} #{webclient_cert_name}", 401 if webclient_cert_name != request_name
else else
error! 'Certificate mismatch', 401 if env['HTTP_SSL_CLIENT_S_DN_CN'] != @current_user.username error! "#{message} #{@current_user.username}", 401 if @current_user.username != request_name
end end
end end

View file

@ -153,7 +153,7 @@ class Epp::DomainsController < EppController
def find_domain def find_domain
domain_name = params[:parsed_frame].css('name').text.strip.downcase domain_name = params[:parsed_frame].css('name').text.strip.downcase
@domain = Epp::Domain.find_by(name: domain_name) @domain = Epp::Domain.where(name: domain_name).first
unless @domain unless @domain
epp_errors << { epp_errors << {

View file

@ -58,6 +58,9 @@ class Certificate < ActiveRecord::Base
errors.add(:base, I18n.t('failed_to_create_certificate')) errors.add(:base, I18n.t('failed_to_create_certificate'))
logger.error('FAILED TO CREATE CLIENT CERTIFICATE') logger.error('FAILED TO CREATE CLIENT CERTIFICATE')
logger.error(err) logger.error(err)
# rubocop:disable Rails/Output
puts "Certificate sign issue: #{err.inspect}" if Rails.env.test?
# rubocop:enable Rails/Output
return false return false
end end
end end

View file

@ -174,9 +174,9 @@ class Contact < ActiveRecord::Base
end end
def destroy_orphans def destroy_orphans
STDOUT << "#{Time.now.utc} - Destroying orphaned contacts\n" logger.info "#{Time.now.utc} - Destroying orphaned contacts\n"
count = find_orphans.destroy_all.count count = find_orphans.destroy_all.count
STDOUT << "#{Time.now.utc} - Successfully destroyed #{count} orphaned contacts\n" logger.info "#{Time.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
end end
end end
end end

View file

@ -241,39 +241,51 @@ class Domain < ActiveRecord::Base
# rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/MethodLength
def update_whois_body def update_whois_body
self.whois_body = <<-EOS self.whois_body = <<-EOS
This Whois Server contains information on This Whois Server contains information on
Estonian Top Level Domain ee TLD Estonian Top Level Domain ee TLD
domain: #{name} domain: #{name}
registrar: #{registrar} registrar: #{registrar}
status: status:
registered: registered: #{registered_at and registered_at.to_s(:db)}
changed: #{updated_at.to_s(:db)} changed: #{updated_at and updated_at.to_s(:db)}
expire: expire:
outzone: outzone:
delete: delete:
contact #{contacts_body}
name:
e-mail:
registrar:
created:
contact: nsset:
nserver:
nsset: registrar: #{registrar}
nserver: phone: #{registrar.phone}
address: #{registrar.address}
registrar: created: #{registrar.created_at.to_s(:db)}
org: changed: #{registrar.updated_at.to_s(:db)}
url:
phone:
address:
created:
changed:
EOS EOS
end end
# rubocop:enabled Metrics/MethodLength # rubocop:enable Metrics/MethodLength
def contacts_body
out = ''
admin_contacts.includes(:registrar).each do |c|
out << 'Admin contact:'
out << "name: #{c.name}"
out << "email: #{c.email}"
out << "registrar: #{c.registrar}"
out << "created: #{c.created_at.to_s(:db)}"
end
tech_contacts.includes(:registrar).each do |c|
out << 'Tech contact:'
out << "name: #{c.name}"
out << "email: #{c.email}"
out << "registrar: #{c.registrar}"
out << "created: #{c.created_at.to_s(:db)}"
end
out
end
def whois_server_update(name, whois_body) def whois_server_update(name, whois_body)
wd = Whois::Domain.find_or_initialize_by(name: name) wd = Whois::Domain.find_or_initialize_by(name: name)

View file

@ -42,7 +42,7 @@ class Epp::Contact < Contact
return super if frame.blank? return super if frame.blank?
custom_code = custom_code =
if frame.css('id').present? if frame.css('id').text.present?
"#{registrar.code}:#{frame.css('id').text.parameterize}" "#{registrar.code}:#{frame.css('id').text.parameterize}"
else else
nil nil

View file

@ -22,6 +22,7 @@ ca_key_password: 'your-root-key-password'
# Used only by EPP server, you can leave it empty when running admin server: # Used only by EPP server, you can leave it empty when running admin server:
webclient_ip: '127.0.0.1' webclient_ip: '127.0.0.1'
webclient_cert_common_name: 'webclient'
# DEPP configuration # DEPP configuration
show_ds_data_fields: 'false' show_ds_data_fields: 'false'

View file

@ -49,5 +49,6 @@ Rails.application.configure do
Bullet.enable = true Bullet.enable = true
Bullet.bullet_logger = true Bullet.bullet_logger = true
Bullet.raise = true # raise an error if n+1 query occurs Bullet.raise = true # raise an error if n+1 query occurs
# Bullet.unused_eager_loading_enable = false
end end
end end

View file

@ -25,6 +25,7 @@ namespace :db do
puts "\n---------------------------- Import seed ----------------------------------------\n" puts "\n---------------------------- Import seed ----------------------------------------\n"
Rake::Task['db:seed'].invoke Rake::Task['db:seed'].invoke
Rake::Task['zonefile:replace_procedure'].invoke
puts "\n All done!\n\n" puts "\n All done!\n\n"
end end

View file

@ -145,6 +145,24 @@ describe 'EPP Contact', epp: true do
Contact.last.code.should == 'registrar1:12345' Contact.last.code.should == 'registrar1:12345'
end end
it 'should generate server id when id is empty' do
response = create_request({ id: { value: '' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should_not == 'registrar1:'
end
it 'should generate server id when id is empty' do
response = create_request
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should_not == 'registrar1:'
end
it 'should return parameter value policy error for org' do it 'should return parameter value policy error for org' do
response = create_request({ postalInfo: { org: { value: 'should not save' } } }) response = create_request({ postalInfo: { org: { value: 'should not save' } } })
response[:msg].should == response[:msg].should ==