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

This commit is contained in:
Priit Tark 2015-06-16 16:45:13 +03:00
commit 88d1b46094
19 changed files with 313 additions and 300 deletions

View file

@ -16,13 +16,13 @@ class Admin::DomainsController < AdminController
end end
def update def update
add_prefix_to_statuses dp = ignore_empty_statuses
if @domain.update(domain_params) if @domain.update(dp)
flash[:notice] = I18n.t('domain_updated') flash[:notice] = I18n.t('domain_updated')
redirect_to [:admin, @domain] redirect_to [:admin, @domain]
else else
@domain.domain_statuses.build if @domain.domain_statuses.empty? build_associations
flash.now[:alert] = I18n.t('failed_to_update_domain') flash.now[:alert] = I18n.t('failed_to_update_domain')
render 'edit' render 'edit'
end end
@ -53,21 +53,23 @@ class Admin::DomainsController < AdminController
end end
def domain_params def domain_params
params.require(:domain).permit( if params[:domain]
domain_statuses_attributes: [:id, :value, :description, :_destroy] params.require(:domain).permit({ statuses: [] })
) else
{statuses: []}
end
end end
def build_associations def build_associations
@domain.domain_statuses.build if @domain.domain_statuses.empty? @server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
@server_statuses = @domain.domain_statuses.select(&:server_status?) @server_statuses = [nil] if @server_statuses.empty?
@server_statuses << @domain.domain_statuses.build if @server_statuses.empty? @other_statuses = @domain.statuses.select { |x| !DomainStatus::SERVER_STATUSES.include?(x) }
end end
def add_prefix_to_statuses def ignore_empty_statuses
domain_params[:domain_statuses_attributes].each do |_k, hash| dp = domain_params
hash[:value] = hash[:value].prepend('server') if hash[:value].present? dp[:statuses].reject! { |x| x.blank? }
end dp
end end
end end

View file

@ -2,7 +2,7 @@ class AdminUser < User
validates :username, :country_code, :roles, presence: true validates :username, :country_code, :roles, presence: true
validates :identity_code, uniqueness: true, allow_blank: true validates :identity_code, uniqueness: true, allow_blank: true
validates :identity_code, presence: true, if: -> { country_code == 'EE' } validates :identity_code, presence: true, if: -> { country_code == 'EE' }
validates :email, presence: true validates :email, presence: true
validates :password, :password_confirmation, presence: true, if: :new_record? validates :password, :password_confirmation, presence: true, if: :new_record?
validates :password_confirmation, presence: true, if: :encrypted_password_changed? validates :password_confirmation, presence: true, if: :encrypted_password_changed?
validate :validate_identity_code, if: -> { country_code == 'EE' } validate :validate_identity_code, if: -> { country_code == 'EE' }

View file

@ -68,13 +68,16 @@ class Domain < ActiveRecord::Base
true true
end end
before_save :manage_automatic_statuses
before_save :touch_always_version before_save :touch_always_version
def touch_always_version def touch_always_version
self.updated_at = Time.zone.now self.updated_at = Time.zone.now
end end
after_save :manage_automatic_statuses
after_save :update_whois_record after_save :update_whois_record
after_initialize -> { self.statuses = [] if statuses.nil? }
validates :name_dirty, domain_name: true, uniqueness: true validates :name_dirty, domain_name: true, uniqueness: true
validates :puny_label, length: { maximum: 63 } validates :puny_label, length: { maximum: 63 }
validates :period, numericality: { only_integer: true } validates :period, numericality: { only_integer: true }
@ -124,6 +127,12 @@ class Domain < ActiveRecord::Base
validate :validate_nameserver_ips validate :validate_nameserver_ips
validate :statuses_uniqueness
def statuses_uniqueness
return if statuses.uniq == statuses
errors.add(:statuses, :taken)
end
attr_accessor :registrant_typeahead, :update_me, :deliver_emails, attr_accessor :registrant_typeahead, :update_me, :deliver_emails,
:epp_pending_update, :epp_pending_delete :epp_pending_update, :epp_pending_delete
@ -159,9 +168,10 @@ class Domain < ActiveRecord::Base
d = Domain.where('valid_to <= ?', Time.zone.now) d = Domain.where('valid_to <= ?', Time.zone.now)
d.each do |x| d.each do |x|
next unless x.expirable? next unless x.expirable?
x.domain_statuses.create(value: DomainStatus::EXPIRED) x.statuses << DomainStatus::EXPIRED
# TODO: This should be managed by automatic_statuses # TODO: This should be managed by automatic_statuses
x.domain_statuses.where(value: DomainStatus::OK).destroy_all x.statuses.delete(DomainStatus::OK)
x.save(validate: false)
end end
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{d.count} domains\n" unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} - Successfully expired #{d.count} domains\n" unless Rails.env.test?
@ -173,9 +183,10 @@ class Domain < ActiveRecord::Base
d = Domain.where('outzone_at <= ?', Time.zone.now) d = Domain.where('outzone_at <= ?', Time.zone.now)
d.each do |x| d.each do |x|
next unless x.server_holdable? next unless x.server_holdable?
x.domain_statuses.create(value: DomainStatus::SERVER_HOLD) x.statuses << DomainStatus::SERVER_HOLD
# TODO: This should be managed by automatic_statuses # TODO: This should be managed by automatic_statuses
x.domain_statuses.where(value: DomainStatus::OK).destroy_all x.statuses.delete(DomainStatus::OK)
x.save
end end
STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test?
@ -186,9 +197,10 @@ class Domain < ActiveRecord::Base
d = Domain.where('delete_at <= ?', Time.zone.now) d = Domain.where('delete_at <= ?', Time.zone.now)
d.each do |x| d.each do |x|
x.domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if x.delete_candidateable? x.statuses << DomainStatus::DELETE_CANDIDATE if x.delete_candidateable?
# TODO: This should be managed by automatic_statuses # TODO: This should be managed by automatic_statuses
x.domain_statuses.where(value: DomainStatus::OK).destroy_all x.statuses.delete(DomainStatus::OK)
x.save
end end
return if Rails.env.test? return if Rails.env.test?
@ -199,8 +211,8 @@ class Domain < ActiveRecord::Base
STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test?
c = 0 c = 0
DomainStatus.where(value: DomainStatus::DELETE_CANDIDATE).each do |x| Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x|
x.domain.destroy x.destroy
c += 1 c += 1
end end
@ -237,28 +249,22 @@ class Domain < ActiveRecord::Base
domain_transfers.find_by(status: DomainTransfer::PENDING) domain_transfers.find_by(status: DomainTransfer::PENDING)
end end
def can_be_deleted?
(domain_statuses.pluck(:value) & %W(
#{DomainStatus::SERVER_DELETE_PROHIBITED}
)).empty?
end
def expirable? def expirable?
return false if valid_to > Time.zone.now return false if valid_to > Time.zone.now
domain_statuses.where(value: DomainStatus::EXPIRED).empty? !statuses.include?(DomainStatus::EXPIRED)
end end
def server_holdable? def server_holdable?
return false if outzone_at > Time.zone.now return false if outzone_at > Time.zone.now
return false if domain_statuses.where(value: DomainStatus::SERVER_HOLD).any? return false if statuses.include?(DomainStatus::SERVER_HOLD)
return false if domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).any? return false if statuses.include?(DomainStatus::SERVER_MANUAL_INZONE)
true true
end end
def delete_candidateable? def delete_candidateable?
return false if delete_at > Time.zone.now return false if delete_at > Time.zone.now
return false if domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).any? return false if statuses.include?(DomainStatus::DELETE_CANDIDATE)
return false if domain_statuses.where(value: DomainStatus::SERVER_DELETE_PROHIBITED).any? return false if statuses.include?(DomainStatus::SERVER_DELETE_PROHIBITED)
true true
end end
@ -269,7 +275,7 @@ class Domain < ActiveRecord::Base
end end
end end
return false if domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).any? return false if statuses.include?(DomainStatus::DELETE_CANDIDATE)
true true
end end
@ -282,15 +288,13 @@ class Domain < ActiveRecord::Base
def clean_pendings! def clean_pendings!
preclean_pendings preclean_pendings
self.pending_json = {} self.pending_json = {}
domain_statuses.where(value: DomainStatus::PENDING_UPDATE).destroy_all statuses.delete(DomainStatus::PENDING_UPDATE)
domain_statuses.where(value: DomainStatus::PENDING_DELETE).destroy_all statuses.delete(DomainStatus::PENDING_DELETE)
save save
end end
def pending_update? def pending_update?
(domain_statuses.pluck(:value) & %W( statuses.include?(DomainStatus::PENDING_UPDATE)
#{DomainStatus::PENDING_UPDATE}
)).present?
end end
def pending_update! def pending_update!
@ -310,8 +314,8 @@ class Domain < ActiveRecord::Base
self.pending_json = pending_json_cache self.pending_json = pending_json_cache
self.registrant_verification_token = token self.registrant_verification_token = token
self.registrant_verification_asked_at = asked_at self.registrant_verification_asked_at = asked_at
self.statuses = [DomainStatus::PENDING_UPDATE]
self.pending_json[:domain] = changes_cache self.pending_json[:domain] = changes_cache
domain_statuses.create(value: DomainStatus::PENDING_UPDATE)
end end
def registrant_update_confirmable?(token) def registrant_update_confirmable?(token)
@ -335,7 +339,7 @@ class Domain < ActiveRecord::Base
end end
def force_deletable? def force_deletable?
domain_statuses.where(value: DomainStatus::FORCE_DELETE).empty? !statuses.include?(DomainStatus::FORCE_DELETE)
end end
def registrant_verification_asked? def registrant_verification_asked?
@ -350,9 +354,7 @@ class Domain < ActiveRecord::Base
end end
def pending_delete? def pending_delete?
(domain_statuses.pluck(:value) & %W( statuses.include?(DomainStatus::PENDING_DELETE)
#{DomainStatus::PENDING_DELETE}
)).present?
end end
def pending_delete! def pending_delete!
@ -360,7 +362,9 @@ class Domain < ActiveRecord::Base
self.epp_pending_delete = true # for epp self.epp_pending_delete = true # for epp
return true unless registrant_verification_asked? return true unless registrant_verification_asked?
domain_statuses.create(value: DomainStatus::PENDING_DELETE) statuses = [DomainStatus::PENDING_DELETE]
save(validate: false) # should check if this did succeed
DomainMailer.pending_deleted(self).deliver_now DomainMailer.pending_deleted(self).deliver_now
end end
@ -440,41 +444,38 @@ class Domain < ActiveRecord::Base
end end
def set_force_delete def set_force_delete
domain_statuses.where(value: DomainStatus::FORCE_DELETE).first_or_create statuses << DomainStatus::FORCE_DELETE
domain_statuses.where(value: DomainStatus::SERVER_RENEW_PROHIBITED).first_or_create statuses << DomainStatus::SERVER_RENEW_PROHIBITED
domain_statuses.where(value: DomainStatus::SERVER_TRANSFER_PROHIBITED).first_or_create statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
domain_statuses.where(value: DomainStatus::SERVER_UPDATE_PROHIBITED).first_or_create statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).first_or_create statuses << DomainStatus::SERVER_MANUAL_INZONE
domain_statuses.where(value: DomainStatus::PENDING_DELETE).first_or_create statuses << DomainStatus::PENDING_DELETE
domain_statuses.where(value: DomainStatus::CLIENT_DELETE_PROHIBITED).destroy_all statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
domain_statuses.where(value: DomainStatus::SERVER_DELETE_PROHIBITED).destroy_all statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
domain_statuses.reload
self.force_delete_at = Time.zone.now + Setting.redemption_grace_period.days unless force_delete_at self.force_delete_at = Time.zone.now + Setting.redemption_grace_period.days unless force_delete_at
save(validate: false) save(validate: false)
end end
def unset_force_delete def unset_force_delete
domain_statuses.where(value: DomainStatus::FORCE_DELETE).destroy_all statuses.delete(DomainStatus::FORCE_DELETE)
domain_statuses.where(value: DomainStatus::SERVER_RENEW_PROHIBITED).destroy_all statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
domain_statuses.where(value: DomainStatus::SERVER_TRANSFER_PROHIBITED).destroy_all statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
domain_statuses.where(value: DomainStatus::SERVER_UPDATE_PROHIBITED).destroy_all statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
domain_statuses.where(value: DomainStatus::SERVER_MANUAL_INZONE).destroy_all statuses.delete(DomainStatus::SERVER_MANUAL_INZONE)
domain_statuses.where(value: DomainStatus::PENDING_DELETE).destroy_all statuses.delete(DomainStatus::PENDING_DELETE)
domain_statuses.reload
self.force_delete_at = nil self.force_delete_at = nil
save(validate: false) save(validate: false)
end end
def manage_automatic_statuses def manage_automatic_statuses
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable? # domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
if domain_statuses.empty? && valid? if statuses.empty? && valid?
domain_statuses.create(value: DomainStatus::OK) statuses << DomainStatus::OK
elsif domain_statuses.length > 1 || !valid? elsif statuses.length > 1 || !valid?
domain_statuses.find_by(value: DomainStatus::OK).try(:destroy) statuses.delete(DomainStatus::OK)
end end
# otherwise domain_statuses are in old state for domain object
domain_statuses.reload
end end
def children_log def children_log

View file

@ -124,7 +124,7 @@ class DomainStatus < ActiveRecord::Base
end end
def statuses_for_admin def statuses_for_admin
SERVER_STATUSES.map { |x| x.sub('server', '') } SERVER_STATUSES.map { |x| [x.sub('server', ''), x] }
end end
end end
end end

View file

@ -110,10 +110,12 @@ class Epp::Domain < Domain
at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y' at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y'
# at[:statuses] = domain_statuses_attrs(frame, action)
# binding.pry
at[:nameservers_attributes] = nameservers_attrs(frame, action) at[:nameservers_attributes] = nameservers_attrs(frame, action)
at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action) at[:admin_domain_contacts_attributes] = admin_domain_contacts_attrs(frame, action)
at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action) at[:tech_domain_contacts_attributes] = tech_domain_contacts_attrs(frame, action)
at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action) # at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
if new_record? if new_record?
dnskey_frame = frame.css('extension create') dnskey_frame = frame.css('extension create')
@ -235,24 +237,6 @@ class Epp::Domain < Domain
attrs attrs
end end
def domain_status_list_from(frame)
status_list = []
frame.css('status').each do |x|
unless DomainStatus::CLIENT_STATUSES.include?(x['s'])
add_epp_error('2303', 'status', x['s'], [:domain_statuses, :not_found])
next
end
status_list << {
value: x['s'],
description: x.text
}
end
status_list
end
# rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/CyclomaticComplexity
def dnskeys_attrs(frame, action) def dnskeys_attrs(frame, action)
@ -336,14 +320,10 @@ class Epp::Domain < Domain
if action == 'rem' if action == 'rem'
to_destroy = [] to_destroy = []
status_list.each do |x| status_list.each do |x|
status = domain_statuses.find_by(value: x[:value]) if statuses.include?(x)
if status.blank? to_destroy << x
add_epp_error('2303', 'status', x[:value], [:domain_statuses, :not_found])
else else
to_destroy << { add_epp_error('2303', 'status', x, [:domain_statuses, :not_found])
id: status.id,
_destroy: 1
}
end end
end end
@ -362,10 +342,7 @@ class Epp::Domain < Domain
next next
end end
status_list << { status_list << x['s']
value: x['s'],
description: x.text
}
end end
status_list status_list
@ -392,13 +369,13 @@ class Epp::Domain < Domain
at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes] at[:admin_domain_contacts_attributes] += at_add[:admin_domain_contacts_attributes]
at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes] at[:tech_domain_contacts_attributes] += at_add[:tech_domain_contacts_attributes]
at[:dnskeys_attributes] += at_add[:dnskeys_attributes] at[:dnskeys_attributes] += at_add[:dnskeys_attributes]
at[:domain_statuses_attributes] += at_add[:domain_statuses_attributes] at[:statuses] = statuses - domain_statuses_attrs(frame.css('rem'), 'rem') + domain_statuses_attrs(frame.css('add'), 'add')
# at[:statuses] += at_add[:domain_statuses_attributes]
if verify && frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes' if verify && frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes'
registrant_verification_asked!(frame.to_s, current_user.id) registrant_verification_asked!(frame.to_s, current_user.id)
end end
self.deliver_emails = true # turn on email delivery for epp self.deliver_emails = true # turn on email delivery for epp
errors.empty? && super(at) errors.empty? && super(at)
end end
@ -406,8 +383,8 @@ class Epp::Domain < Domain
preclean_pendings preclean_pendings
user = ApiUser.find(pending_json['current_user_id']) user = ApiUser.find(pending_json['current_user_id'])
frame = Nokogiri::XML(pending_json['frame']) frame = Nokogiri::XML(pending_json['frame'])
domain_statuses.where(value: DomainStatus::PENDING_UPDATE).destroy_all statuses.delete(DomainStatus::PENDING_UPDATE)
domain_statuses.reload
if update(frame, user, false) if update(frame, user, false)
clean_pendings! clean_pendings!
end end
@ -450,8 +427,8 @@ class Epp::Domain < Domain
self.period = period self.period = period
self.period_unit = unit self.period_unit = unit
domain_statuses.where(value: DomainStatus::SERVER_HOLD).destroy_all statuses.delete(DomainStatus::SERVER_HOLD)
domain_statuses.where(value: DomainStatus::EXPIRED).destroy_all statuses.delete(DomainStatus::EXPIRED)
save save
end end
@ -693,9 +670,7 @@ class Epp::Domain < Domain
begin begin
errors.add(:base, :domain_status_prohibits_operation) errors.add(:base, :domain_status_prohibits_operation)
return false return false
end if (domain_statuses.pluck(:value) & %W( end if statuses.include?(DomainStatus::CLIENT_DELETE_PROHIBITED)
#{DomainStatus::CLIENT_DELETE_PROHIBITED}
)).any?
true true
end end

View file

@ -20,11 +20,11 @@ class WhoisRecord < ActiveRecord::Base
includes( includes(
domain: [ domain: [
:registrant, :registrant,
:registrar, :registrar,
:nameservers, :nameservers,
{ tech_contacts: :registrar }, { tech_contacts: :registrar },
{ admin_contacts: :registrar } { admin_contacts: :registrar }
] ]
) )
end end
end end
@ -34,19 +34,23 @@ class WhoisRecord < ActiveRecord::Base
h = HashWithIndifferentAccess.new h = HashWithIndifferentAccess.new
return h if domain.blank? return h if domain.blank?
status_map = {
'ok' => 'ok (paid and in zone)'
}
@disclosed = [] @disclosed = []
h[:name] = domain.name h[:name] = domain.name
h[:registrant] = domain.registrant.name h[:registrant] = domain.registrant.name
h[:status] = domain.domain_statuses.map(&:human_value).join(', ') h[:status] = domain.statuses.map { |x| status_map[x] || x }.join(', ')
h[:registered] = domain.registered_at.try(:to_s, :iso8601) h[:registered] = domain.registered_at.try(:to_s, :iso8601)
h[:updated_at] = domain.updated_at.try(:to_s, :iso8601) h[:updated_at] = domain.updated_at.try(:to_s, :iso8601)
h[:valid_to] = domain.valid_to.try(:to_s, :iso8601) h[:valid_to] = domain.valid_to.try(:to_s, :iso8601)
# update registar triggers when adding new attributes # update registar triggers when adding new attributes
h[:registrar] = domain.registrar.name h[:registrar] = domain.registrar.name
h[:registrar_phone] = domain.registrar.phone h[:registrar_phone] = domain.registrar.phone
h[:registrar_address] = domain.registrar.address h[:registrar_address] = domain.registrar.address
h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601) h[:registrar_update_at] = domain.registrar.updated_at.try(:to_s, :iso8601)
h[:admin_contacts] = [] h[:admin_contacts] = []
domain.admin_contacts.each do |ac| domain.admin_contacts.each do |ac|

View file

@ -1,26 +1,29 @@
#domain-statuses #domain-statuses
= f.fields_for :domain_statuses, @server_statuses do |status_fields| - @server_statuses.each do |x|
.panel.panel-default .panel.panel-default
.panel-heading.clearfix .panel-heading.clearfix
.pull-left= t(:status) .pull-left= t(:status)
.pull-right .pull-right
= link_to(t(:add_another), '#', class: 'btn btn-primary btn-xs add-domain-status') = link_to(t(:add_another), '#', class: 'btn btn-primary btn-xs add-domain-status')
= link_to(t(:delete), '#', class: 'btn btn-danger btn-xs destroy') = link_to(t(:delete), '#', class: 'btn btn-danger btn-xs destroy-status')
.panel-body .panel-body
.errors
= render 'shared/errors', object: status_fields.object
- if status_fields.object.errors.any?
%hr
.form-group .form-group
= status_fields.label :value, class: 'col-md-2 control-label' = f.label 'status', class: 'col-md-2 control-label'
.col-md-10 .col-md-10
= status_fields.select :value, options_for_select(DomainStatus.statuses_for_admin, status_fields.object.value.try(:sub, 'server', '')), {include_blank: true}, {class: 'form-control'} = select_tag 'domain[statuses][]', options_for_select(DomainStatus.statuses_for_admin, x), include_blank: true, class: 'form-control'
.form-group .form-group
= status_fields.label :description, class: 'col-md-2 control-label' = label_tag t(:description), nil, class: 'col-md-2 control-label'
.col-md-10 .col-md-10
= status_fields.text_field :description, class: 'form-control', autocomplete: 'off' = text_field_tag :description, nil, class: 'form-control', autocomplete: 'off'
- @other_statuses.each do |x|
= hidden_field_tag 'domain[statuses][]', x, readonly: true
:coffee :coffee
$("#domain-statuses").nestedAttributes $("#domain-statuses").nestedAttributes
bindAddTo: $(".add-domain-status") bindAddTo: $(".add-domain-status")
afterAdd: (item) ->
item.find(".errors").html "" $('.destroy-status').on 'click', (e) ->
e.preventDefault()
if $('.panel').length > 1
$(this).parents('.panel').remove()
else
$(this).parents('.panel').find('select').val('')

View file

@ -1,5 +1,4 @@
- panel_class = @domain.errors.messages[:domain_statuses] ? 'panel-danger' : 'panel-default' #domain_statuses.panel.panel-default
#domain_statuses.panel{class: panel_class}
.panel-heading.clearfix .panel-heading.clearfix
= t(:statuses) = t(:statuses)
.table-responsive .table-responsive
@ -9,12 +8,7 @@
%th{class: 'col-xs-6'}= t(:status) %th{class: 'col-xs-6'}= t(:status)
%th{class: 'col-xs-6'}= t(:description) %th{class: 'col-xs-6'}= t(:description)
%tbody %tbody
- @domain.domain_statuses.each do |x| - @domain.statuses.each do |x|
%tr %tr
%td= x.value %td= x
%td= x.description %td
- if @domain.errors.messages[:domain_statuses]
%tfoot
- @domain.errors.messages[:domain_statuses].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -8,9 +8,8 @@ xml.epp_head do
xml.tag!('domain:infData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do xml.tag!('domain:infData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
xml.tag!('domain:name', @domain.name) xml.tag!('domain:name', @domain.name)
xml.tag!('domain:roid', @domain.roid) xml.tag!('domain:roid', @domain.roid)
@domain.domain_statuses.each do |ds| @domain.statuses.each do |s|
xml.tag!('domain:status', ds.description, 's' => ds.value) unless ds.description.blank? xml.tag!('domain:status', 's' => s)
xml.tag!('domain:status', 's' => ds.value) if ds.description.blank?
end end
xml.tag!('domain:registrant', @domain.registrant_code) xml.tag!('domain:registrant', @domain.registrant_code)

View file

@ -100,6 +100,8 @@ en:
invalid: 'Statuses are invalid' invalid: 'Statuses are invalid'
not_found: 'Status was not found' not_found: 'Status was not found'
taken: 'Status already exists on this domain' taken: 'Status already exists on this domain'
statuses:
taken: 'Status already exists on this domain'
registrar: registrar:
blank: 'Registrar is missing' blank: 'Registrar is missing'
dnskeys: dnskeys:

View file

@ -0,0 +1,15 @@
class RefactorDomainStatuses < ActiveRecord::Migration
def self.up
Domain.all.each do |x|
x.statuses = []
x.domain_statuses.each do |ds|
x.statuses << ds.value
end
x.save
end
end
def self.down
raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -0,0 +1,5 @@
class AddStatusesToDomain < ActiveRecord::Migration
def change
add_column :domains, :statuses, :string, array: true
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150611124920) do ActiveRecord::Schema.define(version: 20150612123111) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -19,7 +19,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
create_table "account_activities", force: :cascade do |t| create_table "account_activities", force: :cascade do |t|
t.integer "account_id" t.integer "account_id"
t.integer "invoice_id" t.integer "invoice_id"
t.decimal "sum", precision: 10, scale: 2 t.decimal "sum", precision: 8, scale: 2
t.string "currency" t.string "currency"
t.integer "bank_transaction_id" t.integer "bank_transaction_id"
t.datetime "created_at" t.datetime "created_at"
@ -36,7 +36,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
create_table "accounts", force: :cascade do |t| create_table "accounts", force: :cascade do |t|
t.integer "registrar_id" t.integer "registrar_id"
t.string "account_type" t.string "account_type"
t.decimal "balance", precision: 10, scale: 2, default: 0.0, null: false t.decimal "balance", precision: 8, scale: 2, default: 0.0, null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "currency" t.string "currency"
@ -98,7 +98,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.string "buyer_name" t.string "buyer_name"
t.string "document_no" t.string "document_no"
t.string "description" t.string "description"
t.decimal "sum", precision: 10, scale: 2 t.decimal "sum", precision: 8, scale: 2
t.string "reference_no" t.string "reference_no"
t.datetime "paid_at" t.datetime "paid_at"
t.datetime "created_at" t.datetime "created_at"
@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.string "vk_rec_id" t.string "vk_rec_id"
t.string "vk_stamp" t.string "vk_stamp"
t.string "vk_t_no" t.string "vk_t_no"
t.decimal "vk_amount", precision: 10, scale: 2 t.decimal "vk_amount", precision: 8, scale: 2
t.string "vk_curr" t.string "vk_curr"
t.string "vk_rec_acc" t.string "vk_rec_acc"
t.string "vk_rec_name" t.string "vk_rec_name"
@ -203,6 +203,12 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.string "updator_str" t.string "updator_str"
end end
create_table "data_migrations", id: false, force: :cascade do |t|
t.string "version", null: false
end
add_index "data_migrations", ["version"], name: "unique_data_migrations", unique: true, using: :btree
create_table "delegation_signers", force: :cascade do |t| create_table "delegation_signers", force: :cascade do |t|
t.integer "domain_id" t.integer "domain_id"
t.string "key_tag" t.string "key_tag"
@ -307,6 +313,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.string "registrant_verification_token" t.string "registrant_verification_token"
t.json "pending_json" t.json "pending_json"
t.datetime "force_delete_at" t.datetime "force_delete_at"
t.string "statuses", array: true
end end
add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree
@ -329,10 +336,10 @@ ActiveRecord::Schema.define(version: 20150611124920) do
create_table "invoice_items", force: :cascade do |t| create_table "invoice_items", force: :cascade do |t|
t.integer "invoice_id" t.integer "invoice_id"
t.string "description", null: false t.string "description", null: false
t.string "unit" t.string "unit"
t.integer "amount" t.integer "amount"
t.decimal "price", precision: 10, scale: 2 t.decimal "price", precision: 8, scale: 2
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "creator_str" t.string "creator_str"
@ -342,20 +349,20 @@ ActiveRecord::Schema.define(version: 20150611124920) do
add_index "invoice_items", ["invoice_id"], name: "index_invoice_items_on_invoice_id", using: :btree add_index "invoice_items", ["invoice_id"], name: "index_invoice_items_on_invoice_id", using: :btree
create_table "invoices", force: :cascade do |t| create_table "invoices", force: :cascade do |t|
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "invoice_type", null: false t.string "invoice_type", null: false
t.datetime "due_date", null: false t.datetime "due_date", null: false
t.string "payment_term" t.string "payment_term"
t.string "currency", null: false t.string "currency", null: false
t.string "description" t.string "description"
t.string "reference_no" t.string "reference_no"
t.decimal "vat_prc", precision: 10, scale: 2, null: false t.decimal "vat_prc", precision: 8, scale: 2, null: false
t.datetime "paid_at" t.datetime "paid_at"
t.integer "seller_id" t.integer "seller_id"
t.string "seller_name", null: false t.string "seller_name", null: false
t.string "seller_reg_no" t.string "seller_reg_no"
t.string "seller_iban", null: false t.string "seller_iban", null: false
t.string "seller_bank" t.string "seller_bank"
t.string "seller_swift" t.string "seller_swift"
t.string "seller_vat_no" t.string "seller_vat_no"
@ -369,7 +376,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.string "seller_email" t.string "seller_email"
t.string "seller_contact_name" t.string "seller_contact_name"
t.integer "buyer_id" t.integer "buyer_id"
t.string "buyer_name", null: false t.string "buyer_name", null: false
t.string "buyer_reg_no" t.string "buyer_reg_no"
t.string "buyer_country_code" t.string "buyer_country_code"
t.string "buyer_state" t.string "buyer_state"
@ -383,7 +390,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.string "updator_str" t.string "updator_str"
t.integer "number" t.integer "number"
t.datetime "cancelled_at" t.datetime "cancelled_at"
t.decimal "sum_cache", precision: 10, scale: 2 t.decimal "sum_cache", precision: 8, scale: 2
end end
add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree
@ -995,7 +1002,7 @@ ActiveRecord::Schema.define(version: 20150611124920) do
t.text "crt" t.text "crt"
t.string "type" t.string "type"
t.string "registrant_ident" t.string "registrant_ident"
t.string "encrypted_password", default: "" t.string "encrypted_password", default: "", null: false
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.integer "failed_attempts", default: 0, null: false t.integer "failed_attempts", default: 0, null: false
t.datetime "locked_at" t.datetime "locked_at"

View file

@ -41,7 +41,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
ret text; ret text;
BEGIN BEGIN
-- define filters -- define filters
include_filter = '%' || i_origin; include_filter = '%.' || i_origin;
-- for %.%.% -- for %.%.%
IF i_origin ~ '\.' THEN IF i_origin ~ '\.' THEN
@ -198,7 +198,7 @@ CREATE TABLE account_activities (
id integer NOT NULL, id integer NOT NULL,
account_id integer, account_id integer,
invoice_id integer, invoice_id integer,
sum numeric(10,2), sum numeric(8,2),
currency character varying, currency character varying,
bank_transaction_id integer, bank_transaction_id integer,
created_at timestamp without time zone, created_at timestamp without time zone,
@ -236,7 +236,7 @@ CREATE TABLE accounts (
id integer NOT NULL, id integer NOT NULL,
registrar_id integer, registrar_id integer,
account_type character varying, account_type character varying,
balance numeric(10,2) DEFAULT 0 NOT NULL, balance numeric(8,2) DEFAULT 0.0 NOT NULL,
created_at timestamp without time zone, created_at timestamp without time zone,
updated_at timestamp without time zone, updated_at timestamp without time zone,
currency character varying, currency character varying,
@ -394,7 +394,7 @@ CREATE TABLE bank_transactions (
buyer_name character varying, buyer_name character varying,
document_no character varying, document_no character varying,
description character varying, description character varying,
sum numeric(10,2), sum numeric(8,2),
reference_no character varying, reference_no character varying,
paid_at timestamp without time zone, paid_at timestamp without time zone,
created_at timestamp without time zone, created_at timestamp without time zone,
@ -435,7 +435,7 @@ CREATE TABLE banklink_transactions (
vk_rec_id character varying, vk_rec_id character varying,
vk_stamp character varying, vk_stamp character varying,
vk_t_no character varying, vk_t_no character varying,
vk_amount numeric(10,2), vk_amount numeric(8,2),
vk_curr character varying, vk_curr character varying,
vk_rec_acc character varying, vk_rec_acc character varying,
vk_rec_name character varying, vk_rec_name character varying,
@ -639,6 +639,15 @@ CREATE SEQUENCE countries_id_seq
ALTER SEQUENCE countries_id_seq OWNED BY countries.id; ALTER SEQUENCE countries_id_seq OWNED BY countries.id;
--
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE data_migrations (
version character varying NOT NULL
);
-- --
-- Name: delegation_signers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- Name: delegation_signers; Type: TABLE; Schema: public; Owner: -; Tablespace:
-- --
@ -884,7 +893,8 @@ CREATE TABLE domains (
registrant_verification_asked_at timestamp without time zone, registrant_verification_asked_at timestamp without time zone,
registrant_verification_token character varying, registrant_verification_token character varying,
pending_json json, pending_json json,
force_delete_at timestamp without time zone force_delete_at timestamp without time zone,
statuses character varying[]
); );
@ -950,7 +960,7 @@ CREATE TABLE invoice_items (
description character varying NOT NULL, description character varying NOT NULL,
unit character varying, unit character varying,
amount integer, amount integer,
price numeric(10,2), price numeric(8,2),
created_at timestamp without time zone, created_at timestamp without time zone,
updated_at timestamp without time zone, updated_at timestamp without time zone,
creator_str character varying, creator_str character varying,
@ -991,7 +1001,7 @@ CREATE TABLE invoices (
currency character varying NOT NULL, currency character varying NOT NULL,
description character varying, description character varying,
reference_no character varying, reference_no character varying,
vat_prc numeric(10,2) NOT NULL, vat_prc numeric(8,2) NOT NULL,
paid_at timestamp without time zone, paid_at timestamp without time zone,
seller_id integer, seller_id integer,
seller_name character varying NOT NULL, seller_name character varying NOT NULL,
@ -1024,7 +1034,7 @@ CREATE TABLE invoices (
updator_str character varying, updator_str character varying,
number integer, number integer,
cancelled_at timestamp without time zone, cancelled_at timestamp without time zone,
sum_cache numeric(10,2) sum_cache numeric(8,2)
); );
@ -2286,7 +2296,7 @@ CREATE TABLE pricelists (
id integer NOT NULL, id integer NOT NULL,
"desc" character varying, "desc" character varying,
category character varying, category character varying,
price_cents numeric(8,2) DEFAULT 0 NOT NULL, price_cents numeric(8,2) DEFAULT 0.0 NOT NULL,
price_currency character varying DEFAULT 'EUR'::character varying NOT NULL, price_currency character varying DEFAULT 'EUR'::character varying NOT NULL,
valid_from timestamp without time zone, valid_from timestamp without time zone,
valid_to timestamp without time zone, valid_to timestamp without time zone,
@ -2550,7 +2560,7 @@ CREATE TABLE users (
crt text, crt text,
type character varying, type character varying,
registrant_ident character varying, registrant_ident character varying,
encrypted_password character varying DEFAULT ''::character varying, encrypted_password character varying DEFAULT ''::character varying NOT NULL,
remember_created_at timestamp without time zone, remember_created_at timestamp without time zone,
failed_attempts integer DEFAULT 0 NOT NULL, failed_attempts integer DEFAULT 0 NOT NULL,
locked_at timestamp without time zone locked_at timestamp without time zone
@ -4377,6 +4387,13 @@ CREATE INDEX index_whois_records_on_domain_id ON whois_records USING btree (doma
CREATE INDEX index_whois_records_on_registrar_id ON whois_records USING btree (registrar_id); CREATE INDEX index_whois_records_on_registrar_id ON whois_records USING btree (registrar_id);
--
-- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (version);
-- --
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
-- --
@ -4592,8 +4609,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150227092508');
INSERT INTO schema_migrations (version) VALUES ('20150227113121'); INSERT INTO schema_migrations (version) VALUES ('20150227113121');
INSERT INTO schema_migrations (version) VALUES ('20150302130224');
INSERT INTO schema_migrations (version) VALUES ('20150302161712'); INSERT INTO schema_migrations (version) VALUES ('20150302161712');
INSERT INTO schema_migrations (version) VALUES ('20150303130729'); INSERT INTO schema_migrations (version) VALUES ('20150303130729');
@ -4652,8 +4667,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150417082723');
INSERT INTO schema_migrations (version) VALUES ('20150421134820'); INSERT INTO schema_migrations (version) VALUES ('20150421134820');
INSERT INTO schema_migrations (version) VALUES ('20150422090645');
INSERT INTO schema_migrations (version) VALUES ('20150422092514'); INSERT INTO schema_migrations (version) VALUES ('20150422092514');
INSERT INTO schema_migrations (version) VALUES ('20150422132631'); INSERT INTO schema_migrations (version) VALUES ('20150422132631');
@ -4698,8 +4711,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150519115050');
INSERT INTO schema_migrations (version) VALUES ('20150519140853'); INSERT INTO schema_migrations (version) VALUES ('20150519140853');
INSERT INTO schema_migrations (version) VALUES ('20150519142542');
INSERT INTO schema_migrations (version) VALUES ('20150519144118'); INSERT INTO schema_migrations (version) VALUES ('20150519144118');
INSERT INTO schema_migrations (version) VALUES ('20150520163237'); INSERT INTO schema_migrations (version) VALUES ('20150520163237');
@ -4708,12 +4719,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150520164507');
INSERT INTO schema_migrations (version) VALUES ('20150521120145'); INSERT INTO schema_migrations (version) VALUES ('20150521120145');
INSERT INTO schema_migrations (version) VALUES ('20150522164020');
INSERT INTO schema_migrations (version) VALUES ('20150525075550');
INSERT INTO schema_migrations (version) VALUES ('20150603141054');
INSERT INTO schema_migrations (version) VALUES ('20150603141549'); INSERT INTO schema_migrations (version) VALUES ('20150603141549');
INSERT INTO schema_migrations (version) VALUES ('20150603211318'); INSERT INTO schema_migrations (version) VALUES ('20150603211318');
@ -4728,3 +4733,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150610144547');
INSERT INTO schema_migrations (version) VALUES ('20150611124920'); INSERT INTO schema_migrations (version) VALUES ('20150611124920');
INSERT INTO schema_migrations (version) VALUES ('20150612123111');

View file

@ -224,6 +224,7 @@ namespace :import do
legacy_id legacy_id
legacy_registrar_id legacy_registrar_id
legacy_registrant_id legacy_registrant_id
statuses
) )
domain_contact_columns = %w( domain_contact_columns = %w(
@ -263,7 +264,7 @@ namespace :import do
legacy_domain_id legacy_domain_id
) )
domains, nameservers, dnskeys, domain_statuses, domain_contacts = [], [], [], [], [] domains, nameservers, dnskeys, domain_contacts = [], [], [], []
existing_domain_ids = Domain.pluck(:legacy_id) existing_domain_ids = Domain.pluck(:legacy_id)
user = "rake-#{`whoami`.strip} #{ARGV.join ' '}" user = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
count = 0 count = 0
@ -281,6 +282,20 @@ namespace :import do
count += 1 count += 1
begin begin
# domain statuses
domain_statuses = []
ok = true
x.object_states.each do |state|
next if state.name.blank?
domain_statuses << state.name
ok = false
end
# OK status is default
if ok
domain_statuses << DomainStatus::OK
end
domains << [ domains << [
x.object_registry.name.try(:strip), x.object_registry.name.try(:strip),
x.object_registry.try(:crdate), x.object_registry.try(:crdate),
@ -296,7 +311,8 @@ namespace :import do
user, user,
x.id, x.id,
x.object_registry.try(:crid), x.object_registry.try(:crid),
x.registrant x.registrant,
domain_statuses
] ]
# admin contacts # admin contacts
@ -321,31 +337,6 @@ namespace :import do
] ]
end end
# domain statuses
ok = true
x.object_states.each do |state|
next if state.name.blank?
domain_statuses << [
state.desc,
state.name,
user,
user,
x.id
]
ok = false
end
# OK status is default
if ok
domain_statuses << [
nil,
DomainStatus::OK,
user,
user,
x.id
]
end
# nameservers # nameservers
x.nsset.hosts.each do |host| x.nsset.hosts.each do |host|
ip_maps = host.host_ipaddr_maps ip_maps = host.host_ipaddr_maps
@ -384,9 +375,8 @@ namespace :import do
Domain.import domain_columns, domains, validate: false Domain.import domain_columns, domains, validate: false
Nameserver.import nameserver_columns, nameservers, validate: false Nameserver.import nameserver_columns, nameservers, validate: false
Dnskey.import dnskey_columns, dnskeys, validate: false Dnskey.import dnskey_columns, dnskeys, validate: false
DomainStatus.import domain_status_columns, domain_statuses, validate: false
DomainContact.import domain_contact_columns, domain_contacts, validate: false DomainContact.import domain_contact_columns, domain_contacts, validate: false
domains, nameservers, dnskeys, domain_statuses, domain_contacts = [], [], [], [], [] domains, nameservers, dnskeys, domain_contacts = [], [], [], []
end end
rescue => e rescue => e
puts "ERROR on index #{index}" puts "ERROR on index #{index}"
@ -397,7 +387,6 @@ namespace :import do
Domain.import domain_columns, domains, validate: false Domain.import domain_columns, domains, validate: false
Nameserver.import nameserver_columns, nameservers, validate: false Nameserver.import nameserver_columns, nameservers, validate: false
Dnskey.import dnskey_columns, dnskeys, validate: false Dnskey.import dnskey_columns, dnskeys, validate: false
DomainStatus.import domain_status_columns, domain_statuses, validate: false
DomainContact.import domain_contact_columns, domain_contacts, validate: false DomainContact.import domain_contact_columns, domain_contacts, validate: false
puts '-----> Updating relations...' puts '-----> Updating relations...'
@ -461,16 +450,6 @@ namespace :import do
"AND domain_id IS NULL" "AND domain_id IS NULL"
) )
# statuses
ActiveRecord::Base.connection.execute(
"UPDATE domain_statuses "\
"SET domain_id = domains.id "\
"FROM domains "\
"WHERE domains.legacy_id = legacy_domain_id "\
"AND legacy_domain_id IS NOT NULL "\
"AND domain_id IS NULL"
)
puts '-----> Generating dnskey digests...' puts '-----> Generating dnskey digests...'
Dnskey.all.each do |x| Dnskey.all.each do |x|

View file

@ -317,7 +317,7 @@ describe 'EPP Domain', epp: true do
response = epp_plain_request(xml) response = epp_plain_request(xml)
response[:msg].should == 'Command completed successfully' response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000' response[:result_code].should == '1000'
Domain.first.valid_to.should be_within(5).of(1.year.since) Domain.first.valid_to.should be_within(60).of(1.year.since)
end end
it 'does not create a domain with invalid period' do it 'does not create a domain with invalid period' do
@ -1501,7 +1501,8 @@ describe 'EPP Domain', epp: true do
end end
it 'should not allow any update when status pending update' do it 'should not allow any update when status pending update' do
domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) domain.statuses << DomainStatus::PENDING_UPDATE
domain.save
existing_pw = domain.auth_info existing_pw = domain.auth_info
@ -1592,11 +1593,10 @@ describe 'EPP Domain', epp: true do
new_contact = d.tech_contacts.find_by(code: 'FIXED:MAK21') new_contact = d.tech_contacts.find_by(code: 'FIXED:MAK21')
new_contact.should be_truthy new_contact.should be_truthy
d.domain_statuses.count.should == 2 d.statuses.count.should == 2
d.domain_statuses.first.description.should == 'Payment overdue.' d.statuses.include?('clientHold').should == true
d.domain_statuses.first.value.should == 'clientHold' d.statuses.include?('clientUpdateProhibited').should == true
d.domain_statuses.last.value.should == 'clientUpdateProhibited'
d.dnskeys.count.should == 2 d.dnskeys.count.should == 2
response = epp_plain_request(xml) response = epp_plain_request(xml)
@ -1621,39 +1621,39 @@ describe 'EPP Domain', epp: true do
response[:results][2][:msg].should == 'Contact already exists on this domain [contact_code_cache]' response[:results][2][:msg].should == 'Contact already exists on this domain [contact_code_cache]'
response[:results][2][:value].should == 'FIXED:MAK21' response[:results][2][:value].should == 'FIXED:MAK21'
response[:results][3][:msg].should == 'Status already exists on this domain [value]' # response[:results][3][:msg].should == 'Status already exists on this domain [value]'
if response[:results][3][:value] == 'clientHold' # if response[:results][3][:value] == 'clientHold'
response[:results][3][:value].should == 'clientHold' # response[:results][3][:value].should == 'clientHold'
else # else
response[:results][3][:value].should == 'clientUpdateProhibited' # response[:results][3][:value].should == 'clientUpdateProhibited'
end # end
response[:results][4][:msg].should == 'Status already exists on this domain [value]' # response[:results][4][:msg].should == 'Status already exists on this domain [value]'
if response[:results][4][:value] == 'clientHold' # if response[:results][4][:value] == 'clientHold'
response[:results][4][:value].should == 'clientHold' # response[:results][4][:value].should == 'clientHold'
else # else
response[:results][4][:value].should == 'clientUpdateProhibited' # response[:results][4][:value].should == 'clientUpdateProhibited'
end # end
response[:results][5][:msg].should == 'Public key already exists [public_key]' response[:results][3][:msg].should == 'Public key already exists [public_key]'
if response[:results][5][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' if response[:results][3][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
response[:results][5][:value].should == response[:results][3][:value].should ==
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
else else
response[:results][5][:value].should == response[:results][3][:value].should ==
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
end end
response[:results][6][:msg].should == 'Public key already exists [public_key]' response[:results][4][:msg].should == 'Public key already exists [public_key]'
if response[:results][6][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' if response[:results][4][:value] == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
response[:results][6][:value].should == response[:results][4][:value].should ==
'700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
else else
response[:results][6][:value].should == response[:results][4][:value].should ==
'841936717ae427ace63c28d04918569a841936717ae427ace63c28d0' '841936717ae427ace63c28d04918569a841936717ae427ace63c28d0'
end end
d.domain_statuses.count.should == 2 d.statuses.count.should == 2
end end
it 'updates domain with registrant change what triggers action pending' do it 'updates domain with registrant change what triggers action pending' do
@ -1729,8 +1729,8 @@ describe 'EPP Domain', epp: true do
new_contact = d.tech_contacts.find_by(code: 'FIXED:PENDINGMAK21') new_contact = d.tech_contacts.find_by(code: 'FIXED:PENDINGMAK21')
new_contact.should_not be_truthy # aka should not add new contact new_contact.should_not be_truthy # aka should not add new contact
d.domain_statuses.count.should == 1 d.statuses.count.should == 1
d.domain_statuses.first.value.should == 'pendingUpdate' d.statuses.first.should == 'pendingUpdate'
d.dnskeys.count.should == 0 d.dnskeys.count.should == 0
end end
@ -1840,10 +1840,11 @@ describe 'EPP Domain', epp: true do
response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000' response[:results][0][:result_code].should == '1000'
d.reload
d.dnskeys.count.should == 1 d.dnskeys.count.should == 1
d.domain_statuses.count.should == 1 d.statuses.count.should == 1
d.domain_statuses.first.value.should == 'clientUpdateProhibited' d.statuses.first.should == 'clientUpdateProhibited'
rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com') rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com')
rem_ns.should be_falsey rem_ns.should be_falsey
@ -1862,13 +1863,17 @@ describe 'EPP Domain', epp: true do
response[:results][1][:value].should == 'FIXED:CITIZEN_1234' response[:results][1][:value].should == 'FIXED:CITIZEN_1234'
response[:results][2][:result_code].should == '2303' response[:results][2][:result_code].should == '2303'
response[:results][2][:msg].should == 'Status was not found' response[:results][2][:msg].should == 'DS was not found'
response[:results][2][:value].should == 'clientHold' response[:results][2][:value].should == '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f'
response[:results][3][:result_code].should == '2303'
response[:results][3][:msg].should == 'Status was not found'
response[:results][3][:value].should == 'clientHold'
end end
it 'does not remove server statuses' do it 'does not remove server statuses' do
d = Domain.last domain.statuses << DomainStatus::SERVER_HOLD
d.domain_statuses.create(value: DomainStatus::SERVER_HOLD) domain.save
xml = domain_update_xml({ xml = domain_update_xml({
name: { value: domain.name }, name: { value: domain.name },
@ -2079,9 +2084,10 @@ describe 'EPP Domain', epp: true do
Domain.start_expire_period Domain.start_expire_period
Domain.start_redemption_grace_period Domain.start_redemption_grace_period
domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1 domain.reload
domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1 domain.statuses.include?(DomainStatus::EXPIRED).should == true
domain.domain_statuses.where(value: DomainStatus::OK).count.should == 0 domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
domain.statuses.include?(DomainStatus::OK).should == false
exp_date = domain.valid_to.to_date exp_date = domain.valid_to.to_date
@ -2095,9 +2101,10 @@ describe 'EPP Domain', epp: true do
response[:results][0][:msg].should == 'Command completed successfully' response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000' response[:results][0][:result_code].should == '1000'
domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0 domain.reload
domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0 domain.statuses.include?(DomainStatus::EXPIRED).should == false
domain.domain_statuses.where(value: DomainStatus::OK).count.should == 1 domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
domain.statuses.include?(DomainStatus::OK).should == true
domain.reload domain.reload
domain.valid_to.should be_within(5).of(new_valid_to) domain.valid_to.should be_within(5).of(new_valid_to)
@ -2122,7 +2129,7 @@ describe 'EPP Domain', epp: true do
### INFO ### ### INFO ###
it 'returns domain info' do it 'returns domain info' do
domain.domain_statuses.build(value: DomainStatus::CLIENT_HOLD, description: 'Payment overdue.') domain.statuses << DomainStatus::CLIENT_HOLD
domain.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A') domain.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
domain.dnskeys.build( domain.dnskeys.build(
@ -2157,7 +2164,6 @@ describe 'EPP Domain', epp: true do
inf_data = response[:parsed].css('resData infData') inf_data = response[:parsed].css('resData infData')
inf_data.css('name').text.should == domain.name inf_data.css('name').text.should == domain.name
inf_data.css('status').text.should == 'Payment overdue.'
inf_data.css('status').first[:s].should == 'clientHold' inf_data.css('status').first[:s].should == 'clientHold'
inf_data.css('registrant').text.should == domain.registrant_code inf_data.css('registrant').text.should == domain.registrant_code
inf_data.css('roid').text.should == domain.roid inf_data.css('roid').text.should == domain.roid
@ -2318,7 +2324,8 @@ describe 'EPP Domain', epp: true do
end end
it 'does not delete domain with specific status' do it 'does not delete domain with specific status' do
domain.domain_statuses.create(value: DomainStatus::CLIENT_DELETE_PROHIBITED) domain.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
domain.save
response = epp_plain_request(@epp_xml.domain.delete({ response = epp_plain_request(@epp_xml.domain.delete({
name: { value: domain.name } name: { value: domain.name }
@ -2336,7 +2343,8 @@ describe 'EPP Domain', epp: true do
end end
it 'does not delete domain with pending delete' do it 'does not delete domain with pending delete' do
domain.domain_statuses.create(value: DomainStatus::PENDING_DELETE) domain.statuses << DomainStatus::PENDING_DELETE
domain.save
response = epp_plain_request(@epp_xml.domain.delete({ response = epp_plain_request(@epp_xml.domain.delete({
name: { value: domain.name } name: { value: domain.name }

View file

@ -22,11 +22,12 @@ feature 'DomainDeleteConfirm', type: :feature do
context 'as unknown user with domain with token' do context 'as unknown user with domain with token' do
before :all do before :all do
@domain = Fabricate( @domain = Fabricate(
:domain, :domain,
registrant_verification_token: '123', registrant_verification_token: '123',
registrant_verification_asked_at: Time.zone.now registrant_verification_asked_at: Time.zone.now
) )
@domain.domain_statuses.create(value: DomainStatus::PENDING_DELETE) @domain.statuses << DomainStatus::PENDING_DELETE
@domain.save
end end
it 'should see warning info if token is missing in request' do it 'should see warning info if token is missing in request' do

View file

@ -22,11 +22,12 @@ feature 'DomainUpdateConfirm', type: :feature do
context 'as unknown user with domain with update token' do context 'as unknown user with domain with update token' do
before :all do before :all do
@domain = Fabricate( @domain = Fabricate(
:domain, :domain,
registrant_verification_token: '123', registrant_verification_token: '123',
registrant_verification_asked_at: Time.zone.now registrant_verification_asked_at: Time.zone.now
) )
@domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) @domain.statuses << DomainStatus::PENDING_UPDATE
@domain.save
end end
it 'should see warning info if token is missing in request' do it 'should see warning info if token is missing in request' do

View file

@ -96,50 +96,60 @@ describe Domain do
it 'should expire domains' do it 'should expire domains' do
Domain.start_expire_period Domain.start_expire_period
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0 @domain.statuses.include?(DomainStatus::EXPIRED).should == false
@domain.valid_to = Time.zone.now - 10.days @domain.valid_to = Time.zone.now - 10.days
@domain.save @domain.save
Domain.start_expire_period Domain.start_expire_period
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1 @domain.reload
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
Domain.start_expire_period Domain.start_expire_period
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1 @domain.reload
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
end end
it 'should start redemption grace period' do it 'should start redemption grace period' do
Domain.start_redemption_grace_period Domain.start_redemption_grace_period
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0 @domain.reload
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
@domain.outzone_at = Time.zone.now @domain.outzone_at = Time.zone.now
@domain.domain_statuses.create(value: DomainStatus::SERVER_MANUAL_INZONE) # this prohibits server_hold @domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold
@domain.save @domain.save
Domain.start_redemption_grace_period Domain.start_redemption_grace_period
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0 @domain.reload
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false
@domain.domain_statuses.destroy_all @domain.statuses = []
@domain.save
Domain.start_redemption_grace_period Domain.start_redemption_grace_period
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1 @domain.reload
@domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true
end end
it 'should start delete period' do it 'should start delete period' do
Domain.start_delete_period Domain.start_delete_period
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 0 @domain.reload
@domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == false
@domain.delete_at = Time.zone.now @domain.delete_at = Time.zone.now
@domain.domain_statuses.create(value: DomainStatus::SERVER_DELETE_PROHIBITED) # this prohibits delete_candidate @domain.statuses << DomainStatus::SERVER_DELETE_PROHIBITED # this prohibits delete_candidate
@domain.save @domain.save
Domain.start_delete_period Domain.start_delete_period
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 0 @domain.reload
@domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == false
@domain.domain_statuses.destroy_all @domain.statuses = []
@domain.save
Domain.start_delete_period Domain.start_delete_period
@domain.reload
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 1 @domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == true
end end
it 'should destroy delete candidates' do it 'should destroy delete candidates' do
@ -159,15 +169,16 @@ describe Domain do
end end
it 'should set force delete time' do it 'should set force delete time' do
@domain.statuses = ['ok']
@domain.set_force_delete @domain.set_force_delete
@domain.domain_statuses.count.should == 6 @domain.statuses.count.should == 6
fda = Time.zone.now + Setting.redemption_grace_period fda = Time.zone.now + Setting.redemption_grace_period.days
@domain.force_delete_at.should be_within(20).of(fda) @domain.force_delete_at.should be_within(20).of(fda)
@domain.unset_force_delete @domain.unset_force_delete
@domain.domain_statuses.count.should == 1 @domain.statuses.count.should == 1
@domain.force_delete_at.should be_nil @domain.force_delete_at.should be_nil
end end
@ -175,7 +186,7 @@ describe Domain do
before :all do before :all do
@domain.registrant_verification_token = 123 @domain.registrant_verification_token = 123
@domain.registrant_verification_asked_at = Time.zone.now @domain.registrant_verification_asked_at = Time.zone.now
@domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) @domain.statuses << DomainStatus::PENDING_UPDATE
end end
it 'should be registrant update confirm ready' do it 'should be registrant update confirm ready' do
@ -187,7 +198,7 @@ describe Domain do
end end
it 'should not be registrant update confirm ready when no correct status' do it 'should not be registrant update confirm ready when no correct status' do
@domain.domain_statuses.delete_all @domain.statuses = []
@domain.registrant_update_confirmable?('123').should == false @domain.registrant_update_confirmable?('123').should == false
end end
end end
@ -196,7 +207,7 @@ describe Domain do
before :all do before :all do
@domain.registrant_verification_token = 123 @domain.registrant_verification_token = 123
@domain.registrant_verification_asked_at = Time.zone.now @domain.registrant_verification_asked_at = Time.zone.now
@domain.domain_statuses.create(value: DomainStatus::PENDING_UPDATE) @domain.statuses << DomainStatus::PENDING_UPDATE
end end
it 'should be registrant update confirm ready' do it 'should be registrant update confirm ready' do
@ -208,7 +219,7 @@ describe Domain do
end end
it 'should not be registrant update confirm ready when no correct status' do it 'should not be registrant update confirm ready when no correct status' do
@domain.domain_statuses.delete_all @domain.statuses = []
@domain.registrant_update_confirmable?('123').should == false @domain.registrant_update_confirmable?('123').should == false
end end
end end
@ -441,24 +452,23 @@ describe Domain do
it 'manages statuses automatically' do it 'manages statuses automatically' do
d = Fabricate(:domain) d = Fabricate(:domain)
expect(d.domain_statuses.count).to eq(1) expect(d.statuses.count).to eq(1)
expect(d.domain_statuses.first.value).to eq(DomainStatus::OK) expect(d.statuses.first).to eq(DomainStatus::OK)
d.period = 2 d.period = 2
d.save d.save
d.reload d.reload
expect(d.statuses.count).to eq(1)
expect(d.statuses.first).to eq(DomainStatus::OK)
expect(d.domain_statuses.count).to eq(1) d.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
expect(d.domain_statuses.first.reload.value).to eq(DomainStatus::OK)
d.domain_statuses.build(value: DomainStatus::CLIENT_DELETE_PROHIBITED)
d.save d.save
d.reload d.reload
expect(d.domain_statuses.count).to eq(1) expect(d.statuses.count).to eq(1)
expect(d.domain_statuses.first.value).to eq(DomainStatus::CLIENT_DELETE_PROHIBITED) expect(d.statuses.first).to eq(DomainStatus::CLIENT_DELETE_PROHIBITED)
end end
with_versioning do with_versioning do