Merge branch 'registry-475-refactor-zones' into registry-475

This commit is contained in:
Artur Beljajev 2017-04-22 18:00:31 +03:00
commit 91a99ac1da
82 changed files with 1574 additions and 1263 deletions

View file

@ -5,10 +5,10 @@
//= require 'select2-bootstrap'
@import shared/fonts
@import shared/general
@import forms
@import typeaheadjs
@import selectize
@import selectize.bootstrap3
// @import bootstrap-datepicker3
@import admin/admin
@import admin/bootstrap-dialog-fix

View file

@ -0,0 +1,7 @@
input[type=number]::-webkit-inner-spin-button {
display: none;
}
input[type=number] {
-moz-appearance: textfield;
}

View file

@ -0,0 +1,63 @@
module Admin
module DNS
class ZonesController < AdminController
load_and_authorize_resource(class: DNS::Zone)
before_action :load_zone, only: %i[edit update destroy]
def index
@zones = ::DNS::Zone.all
end
def new
@zone = ::DNS::Zone.new
end
def create
@zone = ::DNS::Zone.new(zone_params)
if @zone.save
flash[:notice] = t('.created')
redirect_to_index
else
render :new
end
end
def edit
@zone = ::DNS::Zone.find(params[:id])
end
def update
if @zone.update(zone_params)
flash[:notice] = t('.updated')
redirect_to_index
else
render :edit
end
end
def destroy
@zone.destroy!
flash[:notice] = t('.destroyed')
redirect_to_index
end
private
def load_zone
@zone = ::DNS::Zone.find(params[:id])
end
def zone_params
params.require(:zone).permit(
:origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email,
:master_nameserver, :ns_records, :a_records, :a4_records
)
end
def redirect_to_index
redirect_to admin_zones_url
end
end
end
end

View file

@ -1,60 +0,0 @@
class Admin::ZonefileSettingsController < AdminController
load_and_authorize_resource
before_action :set_zonefile_setting, only: [:update, :edit]
def index
@zonefile_settings = ZonefileSetting.all
end
def new
@zonefile_setting = ZonefileSetting.new
end
def create
@zonefile_setting = ZonefileSetting.new(zonefile_setting_params)
if @zonefile_setting.save
flash[:notice] = I18n.t('record_created')
redirect_to admin_zonefile_settings_path
else
flash.now[:alert] = I18n.t('failed_to_create_record')
render 'new'
end
end
def edit
@zonefile_setting = ZonefileSetting.find(params[:id])
end
def update
if @zonefile_setting.update(zonefile_setting_params)
flash[:notice] = I18n.t('record_updated')
redirect_to admin_zonefile_settings_path
else
flash.now[:alert] = I18n.t('failed_to_update_record')
render 'edit'
end
end
def destroy
if @zonefile_setting.destroy
flash[:notice] = I18n.t('record_deleted')
redirect_to admin_zonefile_settings_path
else
flash.now[:alert] = I18n.t('failed_to_delete_record')
render 'edit'
end
end
private
def set_zonefile_setting
@zonefile_setting = ZonefileSetting.find(params[:id])
end
def zonefile_setting_params
params.require(:zonefile_setting).permit(
:origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email,
:master_nameserver, :ns_records, :a_records, :a4_records
)
end
end

View file

@ -3,7 +3,7 @@ class Admin::ZonefilesController < ApplicationController
# TODO: Refactor this
def create
if ZonefileSetting.origins.include?(params[:origin])
if DNS::Zone.origins.include?(params[:origin])
@zonefile = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{params[:origin]}')"

View file

@ -1,28 +1,30 @@
class Registrar::AccountActivitiesController < RegistrarController
load_and_authorize_resource
class Registrar
class AccountActivitiesController < BaseController
load_and_authorize_resource
def index # rubocop: disable Metrics/AbcSize
params[:q] ||= {}
account = current_user.registrar.cash_account
def index # rubocop: disable Metrics/AbcSize
params[:q] ||= {}
account = current_user.registrar.cash_account
ca_cache = params[:q][:created_at_lteq]
begin
end_time = params[:q][:created_at_lteq].try(:to_date)
params[:q][:created_at_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
@q = account.activities.includes(:invoice).search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
respond_to do |format|
format.html { @account_activities = @q.result.page(params[:page]) }
format.csv do
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
ca_cache = params[:q][:created_at_lteq]
begin
end_time = params[:q][:created_at_lteq].try(:to_date)
params[:q][:created_at_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
end
params[:q][:created_at_lteq] = ca_cache
@q = account.activities.includes(:invoice).search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
respond_to do |format|
format.html { @account_activities = @q.result.page(params[:page]) }
format.csv do
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
end
end
params[:q][:created_at_lteq] = ca_cache
end
end
end

View file

@ -0,0 +1,40 @@
class Registrar
class BaseController < ApplicationController
before_action :authenticate_user!, :check_ip
include Registrar::ApplicationHelper
helper_method :depp_controller?
def depp_controller?
false
end
def check_ip
return unless current_user
unless current_user.is_a? ApiUser
sign_out(current_user)
return
end
return if Rails.env.development?
registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip)
return if registrar_ip_whitelisted
flash[:alert] = t('ip_is_not_whitelisted')
sign_out(current_user)
redirect_to registrar_login_path and return
end
helper_method :head_title_sufix
def head_title_sufix
t(:registrar_head_title_sufix)
end
protected
def current_ability
@current_ability ||= Ability.new(current_user, request.remote_ip)
end
end
end

View file

@ -1,142 +1,144 @@
class Registrar::ContactsController < Registrar::DeppController # EPP controller
before_action :init_epp_contact
helper_method :address_processing?
class Registrar
class ContactsController < DeppController
before_action :init_epp_contact
helper_method :address_processing?
def index
authorize! :view, Depp::Contact
def index
authorize! :view, Depp::Contact
params[:q] ||= {}
params[:q].delete_if { |_k, v| v.blank? }
params[:q] ||= {}
params[:q].delete_if { |_k, v| v.blank? }
search_params = params[:q].deep_dup
search_params = params[:q].deep_dup
if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant')
search_params[:registrant_domains_id_not_null] = 1
end
if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant')
search_params[:registrant_domains_id_not_null] = 1
end
if search_params.length == 1 && search_params[:name_matches].present?
@contacts = Contact.find_by(name: search_params[:name_matches])
end
if search_params.length == 1 && search_params[:name_matches].present?
@contacts = Contact.find_by(name: search_params[:name_matches])
end
if params[:statuses_contains]
contacts = current_user.registrar.contacts.includes(:registrar).where(
if params[:statuses_contains]
contacts = current_user.registrar.contacts.includes(:registrar).where(
"contacts.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
)
else
)
else
contacts = current_user.registrar.contacts.includes(:registrar)
end
normalize_search_parameters do
@q = contacts.search(search_params)
@contacts = @q.result(distinct: :true).page(params[:page])
end
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
end
def download_list
authorize! :view, Depp::Contact
params[:q] ||= {}
params[:q].delete_if { |_k, v| v.blank? }
if params[:q].length == 1 && params[:q][:name_matches].present?
@contacts = Contact.find_by(name: params[:q][:name_matches])
end
contacts = current_user.registrar.contacts.includes(:registrar)
end
contacts = contacts.filter_by_states(params[:statuses_contains]) if params[:statuses_contains]
normalize_search_parameters do
@q = contacts.search(search_params)
@contacts = @q.result(distinct: :true).page(params[:page])
end
normalize_search_parameters do
@q = contacts.search(params[:q])
@contacts = @q.result.page(params[:page])
end
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
end
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
def download_list
authorize! :view, Depp::Contact
params[:q] ||= {}
params[:q].delete_if { |_k, v| v.blank? }
if params[:q].length == 1 && params[:q][:name_matches].present?
@contacts = Contact.find_by(name: params[:q][:name_matches])
end
contacts = current_user.registrar.contacts.includes(:registrar)
contacts = contacts.filter_by_states(params[:statuses_contains]) if params[:statuses_contains]
normalize_search_parameters do
@q = contacts.search(params[:q])
@contacts = @q.result.page(params[:page])
end
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
respond_to do |format|
respond_to do |format|
format.csv { render text: @contacts.to_csv }
format.pdf do
pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false))
send_data pdf, filename: 'contacts.pdf'
pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false))
send_data pdf, filename: 'contacts.pdf'
end
end
end
def new
authorize! :create, Depp::Contact
@contact = Depp::Contact.new
end
def show
authorize! :view, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def edit
authorize! :edit, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def create
authorize! :create, Depp::Contact
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.save
redirect_to registrar_contact_url(@contact.id)
else
render 'new'
end
end
end
def update
authorize! :edit, Depp::Contact
@contact = Depp::Contact.new(params[:depp_contact])
def new
authorize! :create, Depp::Contact
@contact = Depp::Contact.new
end
def show
authorize! :view, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def edit
authorize! :edit, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def create
authorize! :create, Depp::Contact
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.save
redirect_to registrar_contact_url(@contact.id)
else
render 'new'
end
end
def update
authorize! :edit, Depp::Contact
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.update_attributes(params[:depp_contact])
redirect_to registrar_contact_url(@contact.id)
else
render 'edit'
end
end
def delete
authorize! :delete, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
def destroy
authorize! :delete, Depp::Contact
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.delete
redirect_to registrar_contacts_url, notice: t(:destroyed)
else
render 'delete'
end
end
private
def init_epp_contact
Depp::Contact.user = depp_current_user
end
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
if @contact.update_attributes(params[:depp_contact])
redirect_to registrar_contact_url(@contact.id)
else
render 'edit'
end
end
yield
def delete
authorize! :delete, Depp::Contact
@contact = Depp::Contact.find_by_id(params[:id])
end
params[:q][:valid_to_lteq] = ca_cache
end
def destroy
authorize! :delete, Depp::Contact
@contact = Depp::Contact.new(params[:depp_contact])
def address_processing?
Contact.address_processing?
if @contact.delete
redirect_to registrar_contacts_url, notice: t(:destroyed)
else
render 'delete'
end
end
private
def init_epp_contact
Depp::Contact.user = depp_current_user
end
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
yield
params[:q][:valid_to_lteq] = ca_cache
end
def address_processing?
Contact.address_processing?
end
end
end

View file

@ -1,11 +1,13 @@
class Registrar::DashboardController < RegistrarController
authorize_resource class: false
class Registrar
class DashboardController < BaseController
authorize_resource class: false
def show
if can?(:show, :poll)
redirect_to registrar_poll_url and return
elsif can?(:show, Invoice)
redirect_to registrar_invoices_url and return
def show
if can?(:show, :poll)
redirect_to registrar_poll_url and return
elsif can?(:show, Invoice)
redirect_to registrar_invoices_url and return
end
end
end
end

View file

@ -1,26 +1,28 @@
class Registrar::DepositsController < RegistrarController
authorize_resource class: false
class Registrar
class DepositsController < BaseController
authorize_resource class: false
def new
@deposit = Deposit.new
end
def new
@deposit = Deposit.new
end
def create
@deposit = Deposit.new(deposit_params.merge(registrar: current_user.registrar))
@invoice = @deposit.issue_prepayment_invoice
def create
@deposit = Deposit.new(deposit_params.merge(registrar: current_user.registrar))
@invoice = @deposit.issue_prepayment_invoice
if @invoice && @invoice.persisted?
flash[:notice] = t(:please_pay_the_following_invoice)
redirect_to [:registrar, @invoice]
else
flash.now[:alert] = t(:failed_to_create_record)
render 'new'
if @invoice && @invoice.persisted?
flash[:notice] = t(:please_pay_the_following_invoice)
redirect_to [:registrar, @invoice]
else
flash.now[:alert] = t(:failed_to_create_record)
render 'new'
end
end
private
def deposit_params
params.require(:deposit).permit(:amount, :description)
end
end
private
def deposit_params
params.require(:deposit).permit(:amount, :description)
end
end

View file

@ -1,34 +1,37 @@
class Registrar::DeppController < RegistrarController # EPP controller
helper_method :depp_current_user
class Registrar
class DeppController < BaseController
helper_method :depp_current_user
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |exception|
logger.error 'COULD NOT CONNECT TO REGISTRY'
logger.error exception.backtrace.join("\n")
redirect_to registrar_login_url, alert: t(:no_connection_to_registry)
end
before_action :authenticate_user
def authenticate_user
redirect_to registrar_login_url and return unless depp_current_user
end
def depp_controller?
true
end
def depp_current_user
return nil unless current_user
@depp_current_user ||= Depp::User.new(
tag: current_user.username,
password: current_user.password
)
end
def response_ok?
@data.css('result').each do |x|
success_codes = %(1000, 1001, 1300, 1301)
return false unless success_codes.include?(x['code'])
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |exception|
logger.error 'COULD NOT CONNECT TO REGISTRY'
logger.error exception.backtrace.join("\n")
redirect_to registrar_login_url, alert: t(:no_connection_to_registry)
end
before_action :authenticate_user
def authenticate_user
redirect_to registrar_login_url and return unless depp_current_user
end
def depp_controller?
true
end
def depp_current_user
return nil unless current_user
@depp_current_user ||= Depp::User.new(
tag: current_user.username,
password: current_user.password
)
end
def response_ok?
@data.css('result').each do |x|
success_codes = %(1000, 1001, 1300, 1301)
return false unless success_codes.include?(x['code'])
end
true
end
true
end
end

View file

@ -1,191 +1,194 @@
class Registrar::DomainsController < Registrar::DeppController # EPP controller
before_action :init_domain, except: :new
helper_method :contacts
class Registrar
class DomainsController < DeppController
before_action :init_domain, except: :new
helper_method :contacts
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/AbcSize
# rubocop: disable Metrics/MethodLength
def index
authorize! :view, Depp::Domain
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/AbcSize
# rubocop: disable Metrics/MethodLength
def index
authorize! :view, Depp::Domain
params[:q] ||= {}
params[:q].delete_if { |_k, v| v.blank? }
if params[:q].length == 1 && params[:q][:name_matches].present?
@domain = Domain.find_by(name: params[:q][:name_matches])
if @domain
redirect_to info_registrar_domains_url(domain_name: @domain.name) and return
params[:q] ||= {}
params[:q].delete_if { |_k, v| v.blank? }
if params[:q].length == 1 && params[:q][:name_matches].present?
@domain = Domain.find_by(name: params[:q][:name_matches])
if @domain
redirect_to info_registrar_domains_url(domain_name: @domain.name) and return
end
end
end
if params[:statuses_contains]
domains = current_user.registrar.domains.includes(:registrar, :registrant).where(
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
)
else
domains = current_user.registrar.domains.includes(:registrar, :registrant)
end
if params[:statuses_contains]
domains = current_user.registrar.domains.includes(:registrar, :registrant).where(
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
)
else
domains = current_user.registrar.domains.includes(:registrar, :registrant)
end
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
if @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
# if we do not get any results, add wildcards to the name field and search again
n_cache = params[:q][:name_matches]
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
end
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
respond_to do |format|
format.html
format.csv do
domain_presenters = []
@domains.find_each do |domain|
domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
if @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
# if we do not get any results, add wildcards to the name field and search again
n_cache = params[:q][:name_matches]
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
end
end
csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters, view: view_context).to_s
send_data(csv)
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
respond_to do |format|
format.html
format.csv do
domain_presenters = []
@domains.find_each do |domain|
domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
end
csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters, view: view_context).to_s
send_data(csv)
end
end
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/AbcSize
def info
authorize! :info, Depp::Domain
@data = @domain.info(params[:domain_name]) if params[:domain_name]
if response_ok?
render 'info'
else
flash[:alert] = @data.css('msg').text
redirect_to registrar_domains_url and return
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/AbcSize
def check
authorize! :check, Depp::Domain
if params[:domain_name]
@data = @domain.check(params[:domain_name])
render 'check_index' and return unless response_ok?
else
render 'check_index'
end
end
def new
authorize! :create, Depp::Domain
@domain_params = Depp::Domain.default_params
end
def create
authorize! :create, Depp::Domain
@domain_params = params[:domain]
@data = @domain.create(@domain_params)
if response_ok?
redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
else
render 'new'
end
end
def edit
authorize! :update, Depp::Domain
@data = @domain.info(params[:domain_name])
@domain_params = Depp::Domain.construct_params_from_server_data(@data)
end
def update
authorize! :update, Depp::Domain
@domain_params = params[:domain]
@data = @domain.update(@domain_params)
if response_ok?
redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
else
params[:domain_name] = @domain_params[:name]
render 'new'
end
end
def delete
authorize! :delete, Depp::Domain
end
def destroy
authorize! :delete, Depp::Domain
@data = @domain.delete(params[:domain])
@results = @data.css('result')
if response_ok?
redirect_to info_registrar_domains_url(domain_name: params[:domain][:name])
else
params[:domain_name] = params[:domain][:name]
render 'delete'
end
end
def renew
authorize! :renew, Depp::Domain
if params[:domain_name] && params[:cur_exp_date]
@data = @domain.renew(params)
render 'renew_index' and return unless response_ok?
else
render 'renew_index'
end
end
def transfer
authorize! :transfer, Depp::Domain
if request.post? && params[:domain_name]
@data = @domain.transfer(params)
render 'transfer_index' and return unless response_ok?
else
render 'transfer_index'
end
end
def search_contacts
authorize! :create, Depp::Domain
scope = current_user.registrar.contacts.limit(10)
if params[:query].present?
escaped_str = ActiveRecord::Base.connection.quote_string params[:query]
scope = scope.where("name ilike '%#{escaped_str}%' OR code ilike '%#{escaped_str}%' ")
def info
authorize! :info, Depp::Domain
@data = @domain.info(params[:domain_name]) if params[:domain_name]
if response_ok?
render 'info'
else
flash[:alert] = @data.css('msg').text
redirect_to registrar_domains_url and return
end
end
render json: scope.pluck(:name, :code).map { |c| {display_key: "#{c.second} #{c.first}", value: c.second} }
end
private
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
def contacts
current_user.registrar.contacts
end
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
def check
authorize! :check, Depp::Domain
if params[:domain_name]
@data = @domain.check(params[:domain_name])
render 'check_index' and return unless response_ok?
else
render 'check_index'
end
end
yield
def new
authorize! :create, Depp::Domain
@domain_params = Depp::Domain.default_params
end
params[:q][:valid_to_lteq] = ca_cache
def create
authorize! :create, Depp::Domain
@domain_params = params[:domain]
@data = @domain.create(@domain_params)
if response_ok?
redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
else
render 'new'
end
end
def edit
authorize! :update, Depp::Domain
@data = @domain.info(params[:domain_name])
@domain_params = Depp::Domain.construct_params_from_server_data(@data)
end
def update
authorize! :update, Depp::Domain
@domain_params = params[:domain]
@data = @domain.update(@domain_params)
if response_ok?
redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
else
params[:domain_name] = @domain_params[:name]
render 'new'
end
end
def delete
authorize! :delete, Depp::Domain
end
def destroy
authorize! :delete, Depp::Domain
@data = @domain.delete(params[:domain])
@results = @data.css('result')
if response_ok?
redirect_to info_registrar_domains_url(domain_name: params[:domain][:name])
else
params[:domain_name] = params[:domain][:name]
render 'delete'
end
end
def renew
authorize! :renew, Depp::Domain
if params[:domain_name] && params[:cur_exp_date]
@data = @domain.renew(params)
render 'renew_index' and return unless response_ok?
else
render 'renew_index'
end
end
def transfer
authorize! :transfer, Depp::Domain
if request.post? && params[:domain_name]
@data = @domain.transfer(params)
render 'transfer_index' and return unless response_ok?
else
render 'transfer_index'
end
end
def search_contacts
authorize! :create, Depp::Domain
scope = current_user.registrar.contacts.limit(10)
if params[:query].present?
escaped_str = ActiveRecord::Base.connection.quote_string params[:query]
scope = scope.where("name ilike '%#{escaped_str}%' OR code ilike '%#{escaped_str}%' ")
end
render json: scope.pluck(:name, :code).map { |c| { display_key: "#{c.second} #{c.first}", value: c.second } }
end
private
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
def contacts
current_user.registrar.contacts
end
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
yield
params[:q][:valid_to_lteq] = ca_cache
end
end
end

View file

@ -1,71 +1,74 @@
class Registrar::InvoicesController < RegistrarController
load_and_authorize_resource
class Registrar
class InvoicesController < BaseController
load_and_authorize_resource
before_action :set_invoice, only: [:show, :forward, :download_pdf]
before_action :set_invoice, only: [:show, :forward, :download_pdf]
def index
params[:q] ||= {}
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
def index
params[:q] ||= {}
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
normalize_search_parameters do
@q = invoices.search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@invoices = @q.result.page(params[:page])
end
end
def show; end
def forward
@invoice.billing_email = @invoice.buyer.billing_email
return unless request.post?
@invoice.billing_email = params[:invoice][:billing_email]
if @invoice.forward(render_to_string('pdf', layout: false))
flash[:notice] = t(:invoice_forwared)
redirect_to([:registrar, @invoice])
else
flash.now[:alert] = t(:failed_to_forward_invoice)
end
end
def cancel
if @invoice.cancel
flash[:notice] = t(:record_updated)
redirect_to([:registrar, @invoice])
else
flash.now[:alert] = t(:failed_to_update_record)
render :show
end
end
def download_pdf
pdf = @invoice.pdf(render_to_string('pdf', layout: false))
send_data pdf, filename: @invoice.pdf_name
end
private
def set_invoice
@invoice = Invoice.find(params[:id])
end
def normalize_search_parameters
params[:q][:sum_cache_gteq].gsub!(',', '.') if params[:q][:sum_cache_gteq]
params[:q][:sum_cache_lteq].gsub!(',', '.') if params[:q][:sum_cache_lteq]
ca_cache = params[:q][:due_date_lteq]
begin
end_time = params[:q][:due_date_lteq].try(:to_date)
params[:q][:due_date_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
normalize_search_parameters do
@q = invoices.search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@invoices = @q.result.page(params[:page])
end
end
yield
def show;
end
params[:q][:due_date_lteq] = ca_cache
def forward
@invoice.billing_email = @invoice.buyer.billing_email
return unless request.post?
@invoice.billing_email = params[:invoice][:billing_email]
if @invoice.forward(render_to_string('pdf', layout: false))
flash[:notice] = t(:invoice_forwared)
redirect_to([:registrar, @invoice])
else
flash.now[:alert] = t(:failed_to_forward_invoice)
end
end
def cancel
if @invoice.cancel
flash[:notice] = t(:record_updated)
redirect_to([:registrar, @invoice])
else
flash.now[:alert] = t(:failed_to_update_record)
render :show
end
end
def download_pdf
pdf = @invoice.pdf(render_to_string('pdf', layout: false))
send_data pdf, filename: @invoice.pdf_name
end
private
def set_invoice
@invoice = Invoice.find(params[:id])
end
def normalize_search_parameters
params[:q][:sum_cache_gteq].gsub!(',', '.') if params[:q][:sum_cache_gteq]
params[:q][:sum_cache_lteq].gsub!(',', '.') if params[:q][:sum_cache_lteq]
ca_cache = params[:q][:due_date_lteq]
begin
end_time = params[:q][:due_date_lteq].try(:to_date)
params[:q][:due_date_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
yield
params[:q][:due_date_lteq] = ca_cache
end
end
end

View file

@ -1,18 +1,20 @@
class Registrar::KeyrelaysController < Registrar::DeppController # EPP controller
def show
authorize! :view, Depp::Keyrelay
end
class Registrar
class KeyrelaysController < DeppController
def show
authorize! :view, Depp::Keyrelay
end
def create
authorize! :create, Depp::Keyrelay
keyrelay = Depp::Keyrelay.new(current_user: depp_current_user)
@data = keyrelay.keyrelay(params)
def create
authorize! :create, Depp::Keyrelay
keyrelay = Depp::Keyrelay.new(current_user: depp_current_user)
@data = keyrelay.keyrelay(params)
if response_ok?
flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully', 'show' => true }]
redirect_to registrar_keyrelay_path
else
render 'show'
if response_ok?
flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully', 'show' => true }]
redirect_to registrar_keyrelay_path
else
render 'show'
end
end
end
end

View file

@ -1,46 +1,48 @@
class Registrar::PaymentsController < RegistrarController
protect_from_forgery except: :back
class Registrar
class PaymentsController < BaseController
protect_from_forgery except: :back
skip_authorization_check # actually anyone can pay, no problems at all
skip_before_action :authenticate_user!, :check_ip, only: [:back]
before_action :check_bank
skip_authorization_check # actually anyone can pay, no problems at all
skip_before_action :authenticate_user!, :check_ip, only: [:back]
before_action :check_bank
# to handle existing model we should
# get invoice_id and then get number
# build BankTransaction without connection with right reference number
# do not connect transaction and invoice
def pay
invoice = Invoice.find(params[:invoice_id])
@bank_link = BankLink::Request.new(params[:bank], invoice, self)
@bank_link.make_transaction
end
# connect invoice and transaction
# both back and IPN
def back
@bank_link = BankLink::Response.new(params[:bank], params)
if @bank_link.valid? && @bank_link.ok?
@bank_link.complete_payment
if @bank_link.invoice.binded?
flash[:notice] = t(:pending_applied)
else
flash[:alert] = t(:something_wrong)
end
else
flash[:alert] = t(:something_wrong)
# to handle existing model we should
# get invoice_id and then get number
# build BankTransaction without connection with right reference number
# do not connect transaction and invoice
def pay
invoice = Invoice.find(params[:invoice_id])
@bank_link = BankLink::Request.new(params[:bank], invoice, self)
@bank_link.make_transaction
end
redirect_to registrar_invoice_path(@bank_link.invoice)
end
private
def banks
ENV['payments_banks'].split(",").map(&:strip)
end
def check_bank
raise StandardError.new("Not Implemented bank") unless banks.include?(params[:bank])
end
# connect invoice and transaction
# both back and IPN
def back
@bank_link = BankLink::Response.new(params[:bank], params)
if @bank_link.valid? && @bank_link.ok?
@bank_link.complete_payment
if @bank_link.invoice.binded?
flash[:notice] = t(:pending_applied)
else
flash[:alert] = t(:something_wrong)
end
else
flash[:alert] = t(:something_wrong)
end
redirect_to registrar_invoice_path(@bank_link.invoice)
end
private
def banks
ENV['payments_banks'].split(",").map(&:strip)
end
def check_bank
raise StandardError.new("Not Implemented bank") unless banks.include?(params[:bank])
end
end
end

View file

@ -1,56 +1,61 @@
class Registrar::PollsController < Registrar::DeppController # EPP controller
authorize_resource class: false
before_action :init_epp_xml
class Registrar
class PollsController < DeppController
authorize_resource class: false
before_action :init_epp_xml
def show
if Rails.env.test? # Stub for depp server request
@data = Object.new
def @data.css(key)
; [];
end
else
@data = depp_current_user.request(@ex.poll)
end
end
def destroy
@data = depp_current_user.request(@ex.poll(poll: {
value: '', attrs: { op: 'ack', msgID: params[:id] }
}))
@results = @data.css('result')
def show
if Rails.env.test? # Stub for depp server request
@data = Object.new
def @data.css(key); []; end
else
@data = depp_current_user.request(@ex.poll)
render 'show'
end
# TODO: Keyrelay is disabled for now
# def confirm_keyrelay
# authorize! :confirm, :keyrelay
# domain_params = params[:domain]
# @data = @domain.confirm_keyrelay(domain_params)
# if response_ok?
# redirect_to info_registrar_domains_url(domain_name: domain_params[:name])
# else
# @results = @data.css('result')
# @data = depp_current_user.request(@ex.poll)
# render 'show'
# end
# end
def confirm_transfer
domain_params = params[:domain]
@data = @domain.confirm_transfer(domain_params)
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
private
def init_epp_xml
@ex = EppXml::Session.new(cl_trid_prefix: depp_current_user.tag)
@domain = Depp::Domain.new(current_user: depp_current_user)
end
end
def destroy
@data = depp_current_user.request(@ex.poll(poll: {
value: '', attrs: { op: 'ack', msgID: params[:id] }
}))
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
# TODO: Keyrelay is disabled for now
# def confirm_keyrelay
# authorize! :confirm, :keyrelay
# domain_params = params[:domain]
# @data = @domain.confirm_keyrelay(domain_params)
# if response_ok?
# redirect_to info_registrar_domains_url(domain_name: domain_params[:name])
# else
# @results = @data.css('result')
# @data = depp_current_user.request(@ex.poll)
# render 'show'
# end
# end
def confirm_transfer
domain_params = params[:domain]
@data = @domain.confirm_transfer(domain_params)
@results = @data.css('result')
@data = depp_current_user.request(@ex.poll)
render 'show'
end
private
def init_epp_xml
@ex = EppXml::Session.new(cl_trid_prefix: depp_current_user.tag)
@domain = Depp::Domain.new(current_user: depp_current_user)
end
end

View file

@ -1,188 +1,194 @@
class Registrar::SessionsController < Devise::SessionsController
layout 'registrar/application'
helper_method :depp_controller?
def depp_controller?
false
end
class Registrar
class SessionsController < Devise::SessionsController
helper_method :depp_controller?
before_action :check_ip
def login
@depp_user = Depp::User.new
end
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def create
@depp_user = Depp::User.new(params[:depp_user].merge(pki: !(Rails.env.development? || Rails.env.test?)))
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'].blank?
@depp_user.errors.add(:base, :webserver_missing_user_name_directive)
def depp_controller?
false
end
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_CERT'].blank?
@depp_user.errors.add(:base, :webserver_missing_client_cert_directive)
before_action :check_ip
def login
@depp_user = Depp::User.new
end
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'] == '(null)'
@depp_user.errors.add(:base, :webserver_user_name_directive_should_be_required)
end
# rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def create
@depp_user = Depp::User.new(params[:depp_user].merge(pki: !(Rails.env.development? || Rails.env.test?)))
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_CERT'] == '(null)'
@depp_user.errors.add(:base, :webserver_client_cert_directive_should_be_required)
end
@api_user = ApiUser.find_by(username: params[:depp_user][:tag], password: params[:depp_user][:password])
unless @api_user
@depp_user.errors.add(:base, t(:no_such_user))
render 'login' and return
end
if @depp_user.pki
unless @api_user.registrar_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
@depp_user.errors.add(:base, :invalid_cert)
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'].blank?
@depp_user.errors.add(:base, :webserver_missing_user_name_directive)
end
end
if @depp_user.errors.none?
if @api_user.active?
sign_in @api_user
redirect_to registrar_root_url
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_CERT'].blank?
@depp_user.errors.add(:base, :webserver_missing_client_cert_directive)
end
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'] == '(null)'
@depp_user.errors.add(:base, :webserver_user_name_directive_should_be_required)
end
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_CERT'] == '(null)'
@depp_user.errors.add(:base, :webserver_client_cert_directive_should_be_required)
end
@api_user = ApiUser.find_by(username: params[:depp_user][:tag], password: params[:depp_user][:password])
unless @api_user
@depp_user.errors.add(:base, t(:no_such_user))
render 'login' and return
end
if @depp_user.pki
unless @api_user.registrar_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
@depp_user.errors.add(:base, :invalid_cert)
end
end
if @depp_user.errors.none?
if @api_user.active?
sign_in @api_user
redirect_to registrar_root_url
else
@depp_user.errors.add(:base, :not_active)
render 'login'
end
else
@depp_user.errors.add(:base, :not_active)
render 'login'
end
else
render 'login'
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize
def switch_user
@api_user = ApiUser.find(params[:id])
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize
unless Rails.env.development?
unless @api_user.registrar.registrar_ip_white?(request.ip)
flash[:alert] = I18n.t(:ip_is_not_whitelisted)
redirect_to :back and return
def switch_user
@api_user = ApiUser.find(params[:id])
unless Rails.env.development?
unless @api_user.registrar.registrar_ip_white?(request.ip)
flash[:alert] = I18n.t(:ip_is_not_whitelisted)
redirect_to :back and return
end
end
sign_in @api_user if @api_user.identity_code == current_user.identity_code
redirect_to registrar_root_url
end
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/PerceivedComplexity
def id
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
if @user
sign_in(@user, event: :authentication)
redirect_to registrar_root_url
else
flash[:alert] = t('no_such_user')
redirect_to registrar_login_url
end
end
sign_in @api_user if @api_user.identity_code == current_user.identity_code
redirect_to registrar_root_url
end
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/PerceivedComplexity
def id
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
if @user
sign_in(@user, event: :authentication)
redirect_to registrar_root_url
else
flash[:alert] = t('no_such_user')
redirect_to registrar_login_url
end
end
def login_mid
@user = User.new
end
# rubocop:disable Metrics/MethodLength
def mid
phone = params[:user][:phone]
endpoint = "#{ENV['sk_digi_doc_service_endpoint']}"
client = Digidoc::Client.new(endpoint)
client.logger = Rails.application.config.logger unless Rails.env.test?
# country_codes = {'+372' => 'EST'}
phone.gsub!('+372', '')
response = client.authenticate(
phone: "+372#{phone}",
message_to_display: 'Authenticating',
service_name: ENV['sk_digi_doc_service_name'] || 'Testing'
)
if response.faultcode
render json: { message: response.detail.message }, status: :unauthorized
return
def login_mid
@user = User.new
end
@user = find_user_by_idc(response.user_id_code)
# rubocop:disable Metrics/MethodLength
def mid
phone = params[:user][:phone]
endpoint = "#{ENV['sk_digi_doc_service_endpoint']}"
client = Digidoc::Client.new(endpoint)
client.logger = Rails.application.config.logger unless Rails.env.test?
if @user.persisted?
session[:user_id_code] = response.user_id_code
session[:mid_session_code] = client.session_code
# country_codes = {'+372' => 'EST'}
phone.gsub!('+372', '')
response = client.authenticate(
phone: "+372#{phone}",
message_to_display: 'Authenticating',
service_name: ENV['sk_digi_doc_service_name'] || 'Testing'
)
render json: {
message: t(:confirmation_sms_was_sent_to_your_phone_verification_code_is, { code: response.challenge_id })
}, status: :ok
else
render json: { message: t(:no_such_user) }, status: :unauthorized
if response.faultcode
render json: { message: response.detail.message }, status: :unauthorized
return
end
@user = find_user_by_idc(response.user_id_code)
if @user.persisted?
session[:user_id_code] = response.user_id_code
session[:mid_session_code] = client.session_code
render json: {
message: t(:confirmation_sms_was_sent_to_your_phone_verification_code_is, { code: response.challenge_id })
}, status: :ok
else
render json: { message: t(:no_such_user) }, status: :unauthorized
end
end
end
# rubocop:enable Metrics/MethodLength
# rubocop: disable Metrics/AbcSize
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/MethodLength
def mid_status
endpoint = "#{ENV['sk_digi_doc_service_endpoint']}"
client = Digidoc::Client.new(endpoint)
client.logger = Rails.application.config.logger unless Rails.env.test?
client.session_code = session[:mid_session_code]
auth_status = client.authentication_status
# rubocop:enable Metrics/MethodLength
case auth_status.status
when 'OUTSTANDING_TRANSACTION'
render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok
when 'USER_AUTHENTICATED'
@user = find_user_by_idc(session[:user_id_code])
sign_in @user
flash[:notice] = t(:welcome)
flash.keep(:notice)
render js: "window.location = '#{registrar_root_url}'"
when 'NOT_VALID'
render json: { message: t(:user_signature_is_invalid) }, status: :bad_request
when 'EXPIRED_TRANSACTION'
render json: { message: t(:session_timeout) }, status: :bad_request
when 'USER_CANCEL'
render json: { message: t(:user_cancelled) }, status: :bad_request
when 'MID_NOT_READY'
render json: { message: t(:mid_not_ready) }, status: :bad_request
when 'PHONE_ABSENT'
render json: { message: t(:phone_absent) }, status: :bad_request
when 'SENDING_ERROR'
render json: { message: t(:sending_error) }, status: :bad_request
when 'SIM_ERROR'
render json: { message: t(:sim_error) }, status: :bad_request
when 'INTERNAL_ERROR'
render json: { message: t(:internal_error) }, status: :bad_request
else
render json: { message: t(:internal_error) }, status: :bad_request
# rubocop: disable Metrics/AbcSize
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/MethodLength
def mid_status
endpoint = "#{ENV['sk_digi_doc_service_endpoint']}"
client = Digidoc::Client.new(endpoint)
client.logger = Rails.application.config.logger unless Rails.env.test?
client.session_code = session[:mid_session_code]
auth_status = client.authentication_status
case auth_status.status
when 'OUTSTANDING_TRANSACTION'
render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok
when 'USER_AUTHENTICATED'
@user = find_user_by_idc(session[:user_id_code])
sign_in @user
flash[:notice] = t(:welcome)
flash.keep(:notice)
render js: "window.location = '#{registrar_root_url}'"
when 'NOT_VALID'
render json: { message: t(:user_signature_is_invalid) }, status: :bad_request
when 'EXPIRED_TRANSACTION'
render json: { message: t(:session_timeout) }, status: :bad_request
when 'USER_CANCEL'
render json: { message: t(:user_cancelled) }, status: :bad_request
when 'MID_NOT_READY'
render json: { message: t(:mid_not_ready) }, status: :bad_request
when 'PHONE_ABSENT'
render json: { message: t(:phone_absent) }, status: :bad_request
when 'SENDING_ERROR'
render json: { message: t(:sending_error) }, status: :bad_request
when 'SIM_ERROR'
render json: { message: t(:sim_error) }, status: :bad_request
when 'INTERNAL_ERROR'
render json: { message: t(:internal_error) }, status: :bad_request
else
render json: { message: t(:internal_error) }, status: :bad_request
end
end
end
# rubocop: enable Metrics/AbcSize
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/MethodLength
def find_user_by_idc(idc)
return User.new unless idc
ApiUser.find_by(identity_code: idc) || User.new
end
# rubocop: enable Metrics/AbcSize
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/MethodLength
private
def find_user_by_idc(idc)
return User.new unless idc
ApiUser.find_by(identity_code: idc) || User.new
end
def check_ip
return if Rails.env.development?
return if WhiteIp.registrar_ip_white?(request.ip)
render text: t('access_denied') and return
private
def check_ip
return if Rails.env.development?
return if WhiteIp.registrar_ip_white?(request.ip)
render text: t('access_denied') and return
end
end
end

View file

@ -1,23 +1,25 @@
class Registrar::XmlConsolesController < Registrar::DeppController # EPP controller
authorize_resource class: false
class Registrar
class XmlConsolesController < DeppController
authorize_resource class: false
def show
end
def create
begin
@result = depp_current_user.server.request(params[:payload])
rescue
@result = 'CONNECTION ERROR - Is the EPP server running?'
def show
end
render :show
end
def load_xml
cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests'
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
render text: xml
def create
begin
@result = depp_current_user.server.request(params[:payload])
rescue
@result = 'CONNECTION ERROR - Is the EPP server running?'
end
render :show
end
def load_xml
cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests'
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
render text: xml
end
end
end

View file

@ -1,37 +0,0 @@
class RegistrarController < ApplicationController
before_action :authenticate_user!, :check_ip
layout 'registrar/application'
include Registrar::ApplicationHelper
helper_method :depp_controller?
def depp_controller?
false
end
def check_ip
return unless current_user
unless current_user.is_a? ApiUser
sign_out(current_user)
return
end
return if Rails.env.development?
registrar_ip_whitelisted = current_user.registrar.registrar_ip_white?(request.ip)
return if registrar_ip_whitelisted
flash[:alert] = t('ip_is_not_whitelisted')
sign_out(current_user)
redirect_to registrar_login_path and return
end
helper_method :head_title_sufix
def head_title_sufix
t(:registrar_head_title_sufix)
end
private
def current_ability
@current_ability ||= Ability.new(current_user, request.remote_ip)
end
end

View file

@ -93,7 +93,7 @@ class Ability
can :manage, Setting
can :manage, BlockedDomain
can :manage, ReservedDomain
can :manage, ZonefileSetting
can :manage, DNS::Zone
can :manage, DomainVersion
can :manage, ContactVersion
can :manage, Pricelist

5
app/models/dns.rb Normal file
View file

@ -0,0 +1,5 @@
module DNS
def self.use_relative_model_naming?
true
end
end

48
app/models/dns/zone.rb Normal file
View file

@ -0,0 +1,48 @@
module DNS
class Zone < ActiveRecord::Base
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
validates :origin, uniqueness: true
before_destroy :check_for_dependencies
def check_for_dependencies
dc = Domain.where("name ILIKE ?", "%.#{origin}").count
return if dc == 0
errors.add(:base, I18n.t('there_are_count_domains_in_this_zone', count: dc))
false
end
def self.generate_zonefiles
pluck(:origin).each do |origin|
generate_zonefile(origin)
end
end
def self.generate_zonefile(origin)
filename = "#{origin}.zone"
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
zf = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{origin}')"
)[0]['generate_zonefile']
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
end
def self.origins
pluck(:origin)
end
def to_s
origin
end
def to_partial_path
'zone'
end
end
end

View file

@ -1,5 +0,0 @@
class ZonefileSettingVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_zonefile_settings
self.sequence_name = :log_zonefile_settings_id_seq
end

View file

@ -1,42 +0,0 @@
class ZonefileSetting < ActiveRecord::Base
include Versions # version/zonefile_setting_version.rb
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
validates :origin, uniqueness: true
before_destroy :check_for_dependencies
def check_for_dependencies
dc = Domain.where("name ILIKE ?", "%.#{origin}").count
return if dc == 0
errors.add(:base, I18n.t('there_are_count_domains_in_this_zone', count: dc))
false
end
def self.generate_zonefiles
pluck(:origin).each do |origin|
generate_zonefile(origin)
end
end
def self.generate_zonefile(origin)
filename = "#{origin}.zone"
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
zf = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{origin}')"
)[0]['generate_zonefile']
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
end
def self.origins
pluck(:origin)
end
def to_s
origin
end
end

View file

@ -12,7 +12,7 @@ class DomainNameValidator < ActiveModel::EachValidator
return true unless value
value = value.mb_chars.downcase.strip
origins = ZonefileSetting.origins
origins = DNS::Zone.origins
# if someone tries to register an origin domain, let this validation pass
# the error will be caught in blocked domains validator
return true if origins.include?(value)
@ -38,7 +38,7 @@ class DomainNameValidator < ActiveModel::EachValidator
def validate_blocked(value)
return true unless value
return false if BlockedDomain.where(name: value).count > 0
ZonefileSetting.where(origin: value).count.zero?
DNS::Zone.where(origin: value).count.zero?
end
end
end

View file

@ -31,7 +31,7 @@
%li.divider
%li.dropdown-header= t(:system)
%li= link_to t(:settings), admin_settings_path
%li= link_to t(:zonefile), admin_zonefile_settings_path
%li= link_to t('.zones'), admin_zones_path
%li= link_to t('.blocked_domains'), admin_blocked_domains_path
%li= link_to t('.reserved_domains'), admin_reserved_domains_path
%li= link_to t(:mail_templates), admin_mail_templates_path

View file

@ -1,5 +1,4 @@
= form_for [:admin, @zonefile_setting], html: { class: 'form-horizontal' } do |f|
= form_for [:admin, zone], html: { class: 'form-horizontal' } do |f|
.row
.col-md-8
#domain-statuses
@ -9,52 +8,52 @@
.col-md-4.control-label
= f.label :origin
.col-md-8
- if @zonefile_setting.persisted?
- if zone.persisted?
= f.text_field :origin, class: 'form-control', disabled: true
- else
= f.text_field :origin, class: 'form-control'
= f.text_field :origin, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :ttl
.col-md-8
= f.text_field :ttl, class: 'form-control'
= f.number_field :ttl, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :refresh
.col-md-8
= f.text_field :refresh, class: 'form-control'
= f.number_field :refresh, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :retry
.col-md-8
= f.text_field :retry, class: 'form-control'
= f.number_field :retry, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :expire
.col-md-8
= f.text_field :expire, class: 'form-control'
= f.number_field :expire, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :minimum_ttl
.col-md-8
= f.text_field :minimum_ttl, class: 'form-control'
= f.number_field :minimum_ttl, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :email
.col-md-8
= f.text_field :email, class: 'form-control'
= f.email_field :email, class: 'form-control', required: true
.form-group
.col-md-4.control-label
= f.label :master_nameserver
.col-md-8
= f.text_field :master_nameserver, class: 'form-control'
= f.text_field :master_nameserver, class: 'form-control', required: true
.form-group
.col-md-4.control-label
@ -77,4 +76,4 @@
%hr
.row
.col-md-8.text-right
%button.btn.btn-primary= t(:save)
%button.btn.btn-success= t(".#{zone.new_record? ? 'create' : 'update'}_btn")

View file

@ -0,0 +1,9 @@
<tr>
<td><%= zone.origin %></td>
<td>
<%= link_to t('.edit_btn'), edit_admin_zone_path(zone), class: 'btn btn-xs btn-primary' %>
<%= link_to t('.generate_zone_file_btn'),
admin_zonefiles_path(origin: zone.origin),
method: 'post', class: 'btn btn-xs btn-primary' %>
</td>
</tr>

View file

@ -0,0 +1,20 @@
<ol class="breadcrumb">
<li><%= link_to t('admin.dns.zones.index.title'), admin_zones_path %></li>
</ol>
<div class="page-header">
<div class="row">
<div class="col-sm-10">
<h1><%= t '.title' %></h1>
</div>
<div class="col-sm-2 text-right">
<%= link_to(t('.delete_btn'), admin_zone_path(@zone),
method: :delete,
data: { confirm: t('.delete_btn_confirm') },
class: 'btn btn-danger') %>
</div>
</div>
</div>
<%= render 'form', zone: @zone %>

View file

@ -0,0 +1,28 @@
<div class="page-header">
<div class="row">
<div class="col-sm-10">
<h1><%= t '.title' %></h1>
</div>
<div class="col-sm-2 text-right">
<%= link_to t('.new_btn'), new_admin_zone_path, class: 'btn btn-primary' %>
</div>
</div>
</div>
<% if @zones.present? %>
<table class="table table-hover table-bordered table-wrapped">
<thead>
<tr>
<th><%= DNS::Zone.human_attribute_name :origin %></th>
<th></th>
</tr>
</thead>
<tbody>
<%= render @zones %>
</tbody>
</table>
<% else %>
<div class="alert alert-info"><%= t '.not_found' %></div>
<% end %>

View file

@ -0,0 +1,9 @@
<ol class="breadcrumb">
<li><%= link_to t('admin.dns.zones.index.title'), admin_zones_path %></li>
</ol>
<div class="page-header">
<h1><%= t '.title' %></h1>
</div>
<%= render 'form', zone: @zone %>

View file

@ -1,7 +0,0 @@
- content_for :actions do
= link_to(t(:back), admin_zonefile_settings_path, class: 'btn btn-default')
= link_to(t(:delete), admin_zonefile_setting_path(@zonefile_setting),
method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger')
= render 'shared/title', name: t(:edit_zone)
= render 'form'

View file

@ -1,22 +0,0 @@
- content_for :actions do
= link_to(t(:new), new_admin_zonefile_setting_path, class: 'btn btn-primary')
= render 'shared/title', name: t(:zonefile_settings)
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-10'}
= t(:origin)
%th{class: 'col-xs-2'}
= t(:action)
%tbody
- @zonefile_settings.each do |x|
%tr
%td= link_to(x, edit_admin_zonefile_setting_path(x))
%td
= link_to(t(:generate_zonefile),
admin_zonefiles_path(origin: x.origin),
method: 'post', class: 'btn btn-xs btn-primary')

View file

@ -1,5 +0,0 @@
- content_for :actions do
= link_to(t(:back), admin_zonefile_settings_path, class: 'btn btn-default')
= render 'shared/title', name: t(:new_zone)
= render 'form'

View file

@ -1,75 +0,0 @@
!!! 5
%html{lang: I18n.locale.to_s}
%head
%meta{charset: "utf-8"}/
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/
%meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
%meta{content: "Full stack top-level domain (TLD) management.", name: "description"}/
%meta{content: "Gitlab LTD", name: "author"}/
- if content_for? :head_title
= yield :head_title
- else
%title= t(:registrar_head_title)
= csrf_meta_tags
= stylesheet_link_tag 'registrar-manifest', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'registrar-manifest', 'data-turbolinks-track' => true
= favicon_link_tag 'favicon.ico'
%body
/ Fixed navbar
%nav.navbar.navbar-default.navbar-fixed-top
.container
.navbar-header
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
= link_to main_app.registrar_root_path, class: 'navbar-brand' do
= t(:registrar_head_title)
- if unstable_env.present?
.text-center
%small{style: 'color: #0074B3;'}= unstable_env
- if current_user
.navbar-collapse.collapse
%ul.nav.navbar-nav.public-nav
- if can? :view, Depp::Domain
- active_class = %w(registrar/domains registrar/check registrar/renew registrar/tranfer registrar/keyrelays).include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:domains), registrar_domains_path
- if can? :view, Depp::Contact
- active_class = ['registrar/contacts'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:contacts), registrar_contacts_path
- if can? :show, Invoice
- active_class = ['registrar/invoices'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:billing), registrar_invoices_path
- if !Rails.env.production? && can?(:manage, :xml_console)
- active_class = ['registrar/xml_consoles'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
%ul.nav.navbar-nav.navbar-right
%li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
= "#{current_user} (#{current_user.roles.first}) - #{current_user.registrar}"
%span.caret
%ul.dropdown-menu{role: "menu"}
- ApiUser.all_by_identity_code(current_user.identity_code).each do |x|
%li= link_to "#{x} (#{x.roles.first}) - #{x.registrar}", "/registrar/switch_user/#{x.id}"
- if user_signed_in?
%li= link_to t(:log_out_), '/registrar/logout'
.container
= render 'shared/flash'
- if depp_controller?
= render 'registrar/shared/epp_results'
= yield
%footer.footer
.container
%row
.col-md-6
= image_tag 'eis-logo-et.png'
.col-md-6.text-right
Version
= CURRENT_COMMIT_HASH

View file

@ -0,0 +1,48 @@
!!! 5
%html{lang: I18n.locale.to_s}
%head
%meta{charset: "utf-8"}/
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/
%meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
%meta{content: "Full stack top-level domain (TLD) management.", name: "description"}/
%meta{content: "Gitlab LTD", name: "author"}/
- if content_for? :head_title
= yield :head_title
- else
%title= t(:registrar_head_title)
= csrf_meta_tags
= stylesheet_link_tag 'registrar-manifest', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'registrar-manifest', 'data-turbolinks-track' => true
= favicon_link_tag 'favicon.ico'
%body
/ Fixed navbar
%nav.navbar.navbar-default.navbar-fixed-top
.container
.navbar-header
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
= link_to main_app.registrar_root_path, class: 'navbar-brand' do
= t(:registrar_head_title)
- if unstable_env.present?
.text-center
%small{style: 'color: #0074B3;'}= unstable_env
- if current_user
= render 'navbar'
.container
= render 'shared/flash'
- if depp_controller?
= render 'registrar/shared/epp_results'
= yield
%footer.footer
.container
%row
.col-md-6
= image_tag 'eis-logo-et.png'
.col-md-6.text-right
Version
= CURRENT_COMMIT_HASH

View file

@ -0,0 +1,11 @@
<% if target.errors.any? %>
<div class="alert alert-danger">
<p><%= pluralize(target.errors.count, 'error') %> prohibited this <%= target.model_name.human.downcase %> from being saved:</p>
<ul>
<% target.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

View file

@ -0,0 +1,28 @@
.navbar-collapse.collapse
%ul.nav.navbar-nav.public-nav
- if can? :view, Depp::Domain
- active_class = %w(registrar/domains registrar/check registrar/renew registrar/tranfer registrar/keyrelays).include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:domains), registrar_domains_path
- if can? :view, Depp::Contact
- active_class = ['registrar/contacts'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:contacts), registrar_contacts_path
- if can? :show, Invoice
- active_class = ['registrar/invoices'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:billing), registrar_invoices_path
- if !Rails.env.production? && can?(:manage, :xml_console)
- active_class = ['registrar/xml_consoles'].include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
%ul.nav.navbar-nav.navbar-right
%li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
= "#{current_user} (#{current_user.roles.first}) - #{current_user.registrar}"
%span.caret
%ul.dropdown-menu{role: "menu"}
- ApiUser.all_by_identity_code(current_user.identity_code).each do |x|
%li= link_to "#{x} (#{x.roles.first}) - #{x.registrar}", "/registrar/switch_user/#{x.id}"
- if user_signed_in?
%li= link_to t(:log_out_), '/registrar/logout'

View file

@ -25,7 +25,7 @@
%dt= t(:payment_term)
%dd= t(@invoice.payment_term)
%dt= t(:"invoice no")
%dt= t(:invoice_number)
%dd= @invoice.number
- if @invoice.description.present?

View file

@ -175,7 +175,7 @@
%dt= t(:payment_term)
%dd= t(@invoice.payment_term)
%dt= t(:"invoice no")
%dt= t(:invoice_number)
%dd= @invoice.number
- if @invoice.description.present?

View file

@ -10,7 +10,6 @@
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'DNS'
end

View file

@ -0,0 +1,33 @@
en:
admin:
dns:
zones:
index:
title: Zones
new_btn: New zone
not_found: No zone found
new:
title: New zone
create:
created: Zone has been created
edit:
title: Edit zone
delete_btn: Delete
delete_btn_confirm: Are you sure you want to delete zone?
update:
updated: Zone has been updated
destroy:
destroyed: Zone has been deleted
form:
create_btn: Create zone
update_btn: Update zone
zone:
edit_btn: Edit
generate_zone_file_btn: Generate zone file

View file

@ -7,6 +7,7 @@ en:
archive: Archive
domain_history: Domain history
contact_history: Contact history
zones: Zones
blocked_domains: Blocked domains
reserved_domains: Reserved domains
epp_log: EPP log

View file

@ -232,14 +232,6 @@ en:
protocol: 'Protocol'
alg: 'Algorithm'
public_key: 'Public key'
zonefile_setting:
ttl: 'TTL'
refresh: 'Refresh'
retry: 'Retry'
expire: 'Expire'
minimum_ttl: 'Minimum TTL'
email: 'E-Mail'
registrar:
billing_email: 'Billing e-mail'
phone: 'Contact phone'
@ -436,7 +428,6 @@ en:
transfer_requested: 'Transfer requested.'
message_was_not_found: 'Message was not found'
host_obj_is_not_allowed: 'hostObj object is not allowed'
generate_zonefile: 'Generate zonefile'
zonefile: 'Zonefile'
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
exactly_one_parameter_required: 'Exactly one parameter required: %{params}'
@ -450,7 +441,6 @@ en:
ds_data_with_key_allowed: 'Allow DS data with key'
key_data_allowed: 'Allow key data'
ds_digest_type: 'DS digest type'
zonefile_settings: 'Zonefile settings'
background_jobs: Background jobs
domains_history: Domains history
role: 'Role'
@ -666,6 +656,7 @@ en:
amount: 'Amount'
please_pay_the_following_invoice: 'Please pay the following invoice'
invoice_no: 'Invoice no. %{no}'
invoice_number: Invoice no.
seller: 'Seller'
prepayment: 'Prepayment'
vat: 'VAT (%{vat_prc}%)'
@ -894,8 +885,6 @@ en:
failed_to_generate_invoice_invoice_number_limit_reached: 'Failed to generate invoice - invoice number limit reached'
is_too_small_minimum_deposit_is: 'is too small. Minimum deposit is %{amount} %{currency}'
a4_records: 'AAAA records'
new_zone: 'New zone'
edit_zone: 'Edit zone'
there_are_count_domains_in_this_zone: 'There are %{count} domains in this zone'
poll_pending_update_confirmed_by_registrant: 'Registrant confirmed domain update'
poll_pending_update_rejected_by_registrant: 'Registrant rejected domain update'
@ -934,3 +923,11 @@ en:
cant_match_version: 'Impossible match version with request'
user_not_authenticated: "user not authenticated"
actions: Actions
number:
currency:
format:
format: "%n %u"
delimiter: " "
precision: 2
unit:

View file

@ -170,7 +170,7 @@ Rails.application.routes.draw do
namespace :admin do
resources :keyrelays
resources :zonefiles
resources :zonefile_settings
resources :zones, controller: 'dns/zones', except: %i[show]
resources :legal_documents
resources :keyrelays
resources :pricelists

View file

@ -14,7 +14,7 @@ set :output, 'log/cron.log'
if @cron_group == 'registry'
every 10.minutes do
runner 'ZonefileSetting.generate_zonefiles'
runner 'DNS::Zone.generate_zonefiles'
end
every 6.months, at: '12:01am' do

View file

@ -0,0 +1,5 @@
class RenameZonefileSettingsToZones < ActiveRecord::Migration
def change
rename_table :zonefile_settings, :zones
end
end

View file

@ -0,0 +1,5 @@
class RemoveLogZonefileSettings < ActiveRecord::Migration
def change
drop_table :log_zonefile_settings
end
end

View file

@ -1,9 +1,9 @@
namespace :zonefile do
desc 'Replace procedure'
task replace_procedure: :environment do
ActiveRecord::Base.connection.execute <<-SQL
CREATE OR REPLACE FUNCTION generate_zonefile(i_origin varchar)
RETURNS text AS $$
class UpdateGenerateZonefileSql < ActiveRecord::Migration
def change
execute <<-SQL
CREATE OR REPLACE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
LANGUAGE plpgsql
AS $_$
DECLARE
zone_header text := concat('$ORIGIN ', i_origin, '.');
serial_num varchar;
@ -16,14 +16,14 @@ namespace :zonefile do
include_filter = '%.' || i_origin;
-- for %.%.%
IF i_origin ~ '\\.' THEN
IF i_origin ~ '.' THEN
exclude_filter := '';
-- for %.%
ELSE
exclude_filter := '%.%.' || i_origin;
END IF;
SELECT (extract(epoch from now() at time zone 'utc'))::int INTO serial_num;
SELECT ROUND(extract(epoch from now() at time zone 'utc')) INTO serial_num;
-- zonefile header
SELECT concat(
@ -47,11 +47,11 @@ namespace :zonefile do
-- ns records
SELECT array_to_string(
array(
SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.')
SELECT concat(d.name_puny, '. IN NS ', coalesce(ns.hostname_puny, ns.hostname), '.')
FROM domains d
JOIN nameservers ns ON ns.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
ORDER BY d.name
),
chr(10)
@ -66,14 +66,14 @@ namespace :zonefile do
-- a glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(ns.hostname, '. IN A ', unnest(ns.ipv4))
SELECT concat(coalesce(ns.hostname_puny, ns.hostname), '. IN A ', unnest(ns.ipv4))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND ns.hostname LIKE '%.' || d.name
AND d.name <> i_origin
AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '{}'
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
), chr(10)
) INTO tmp_var;
@ -86,14 +86,14 @@ namespace :zonefile do
-- aaaa glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(ns.hostname, '. IN AAAA ', unnest(ns.ipv6))
SELECT concat(coalesce(ns.hostname_puny, ns.hostname), '. IN AAAA ', unnest(ns.ipv6))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND ns.hostname LIKE '%.' || d.name
AND d.name <> i_origin
AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '{}'
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
), chr(10)
) INTO tmp_var;
@ -109,7 +109,7 @@ namespace :zonefile do
FROM domains d
JOIN dnskeys dk ON dk.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND dk.flags = 257
AND NOT ('{serverHold,clientHold}' && d.statuses)
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
),
chr(10)
) INTO tmp_var;
@ -118,8 +118,7 @@ namespace :zonefile do
RETURN ret;
END;
$$
LANGUAGE plpgsql;
$_$;
SQL
end
end

View file

@ -0,0 +1,124 @@
class RenameZonefileSettingsInGenerateZonefile < ActiveRecord::Migration
def change
execute <<-SQL
CREATE OR REPLACE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
LANGUAGE plpgsql
AS $_$
DECLARE
zone_header text := concat('$ORIGIN ', i_origin, '.');
serial_num varchar;
include_filter varchar := '';
exclude_filter varchar := '';
tmp_var text;
ret text;
BEGIN
-- define filters
include_filter = '%.' || i_origin;
-- for %.%.%
IF i_origin ~ '.' THEN
exclude_filter := '';
-- for %.%
ELSE
exclude_filter := '%.%.' || i_origin;
END IF;
SELECT ROUND(extract(epoch from now() at time zone 'utc')) INTO serial_num;
-- zonefile header
SELECT concat(
format('%-10s', '$ORIGIN .'), chr(10),
format('%-10s', '$TTL'), zf.ttl, chr(10), chr(10),
format('%-10s', i_origin || '.'), 'IN SOA ', zf.master_nameserver, '. ', zf.email, '. (', chr(10),
format('%-17s', ''), format('%-12s', serial_num), '; serial number', chr(10),
format('%-17s', ''), format('%-12s', zf.refresh), '; refresh, seconds', chr(10),
format('%-17s', ''), format('%-12s', zf.retry), '; retry, seconds', chr(10),
format('%-17s', ''), format('%-12s', zf.expire), '; expire, seconds', chr(10),
format('%-17s', ''), format('%-12s', zf.minimum_ttl), '; minimum TTL, seconds', chr(10),
format('%-17s', ''), ')'
) FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret = concat(tmp_var, chr(10), chr(10));
-- origin ns records
SELECT ns_records FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret := concat(ret, '; Zone NS Records', chr(10), tmp_var, chr(10));
-- ns records
SELECT array_to_string(
array(
SELECT concat(d.name_puny, '. IN NS ', coalesce(ns.hostname_puny, ns.hostname), '.')
FROM domains d
JOIN nameservers ns ON ns.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
ORDER BY d.name
),
chr(10)
) INTO tmp_var;
ret := concat(ret, tmp_var, chr(10), chr(10));
-- origin a glue records
SELECT a_records FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret := concat(ret, '; Zone A Records', chr(10), tmp_var, chr(10));
-- a glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(coalesce(ns.hostname_puny, ns.hostname), '. IN A ', unnest(ns.ipv4))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND ns.hostname LIKE '%.' || d.name
AND d.name <> i_origin
AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '{}'
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
), chr(10)
) INTO tmp_var;
ret := concat(ret, tmp_var, chr(10), chr(10));
-- origin aaaa glue records
SELECT a4_records FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret := concat(ret, '; Zone AAAA Records', chr(10), tmp_var, chr(10));
-- aaaa glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(coalesce(ns.hostname_puny, ns.hostname), '. IN AAAA ', unnest(ns.ipv6))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
AND ns.hostname LIKE '%.' || d.name
AND d.name <> i_origin
AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '{}'
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
), chr(10)
) INTO tmp_var;
ret := concat(ret, tmp_var, chr(10), chr(10));
-- ds records
SELECT array_to_string(
array(
SELECT concat(
d.name_puny, '. 3600 IN DS ', dk.ds_key_tag, ' ',
dk.ds_alg, ' ', dk.ds_digest_type, ' ', dk.ds_digest
)
FROM domains d
JOIN dnskeys dk ON dk.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND dk.flags = 257
AND NOT ('{serverHold,clientHold,inactive}' && d.statuses)
),
chr(10)
) INTO tmp_var;
ret := concat(ret, '; Zone DS Records', chr(10), tmp_var, chr(10));
RETURN ret;
END;
$_$;
SQL
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170221115548) do
ActiveRecord::Schema.define(version: 20170422142116) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -914,22 +914,6 @@ ActiveRecord::Schema.define(version: 20170221115548) do
t.string "uuid"
end
create_table "log_zonefile_settings", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.json "object"
t.json "object_changes"
t.datetime "created_at"
t.string "session"
t.json "children"
t.string "uuid"
end
add_index "log_zonefile_settings", ["item_type", "item_id"], name: "index_log_zonefile_settings_on_item_type_and_item_id", using: :btree
add_index "log_zonefile_settings", ["whodunnit"], name: "index_log_zonefile_settings_on_whodunnit", using: :btree
create_table "mail_templates", force: :cascade do |t|
t.string "name", null: false
t.string "subject"
@ -1141,7 +1125,7 @@ ActiveRecord::Schema.define(version: 20170221115548) do
add_index "whois_records", ["domain_id"], name: "index_whois_records_on_domain_id", using: :btree
add_index "whois_records", ["registrar_id"], name: "index_whois_records_on_registrar_id", using: :btree
create_table "zonefile_settings", force: :cascade do |t|
create_table "zones", force: :cascade do |t|
t.string "origin"
t.integer "ttl"
t.integer "refresh"

View file

@ -34,7 +34,7 @@ ActiveRecord::Base.transaction do
roles: ['admin']
)
ZonefileSetting.create!(
DNS::Zone.create!(
origin: 'tld',
ttl: 43200,
refresh: 3600,

View file

@ -167,7 +167,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
exclude_filter varchar := '';
tmp_var text;
ret text;
BEGIN
BEGIN
-- define filters
include_filter = '%.' || i_origin;
@ -192,18 +192,18 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
format('%-17s', ''), format('%-12s', zf.expire), '; expire, seconds', chr(10),
format('%-17s', ''), format('%-12s', zf.minimum_ttl), '; minimum TTL, seconds', chr(10),
format('%-17s', ''), ')'
) FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var;
) FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret = concat(tmp_var, chr(10), chr(10));
-- origin ns records
SELECT ns_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var;
SELECT ns_records FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret := concat(ret, '; Zone NS Records', chr(10), tmp_var, chr(10));
-- ns records
SELECT array_to_string(
array(
SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.')
SELECT concat(d.name_puny, '. IN NS ', coalesce(ns.hostname_puny, ns.hostname), '.')
FROM domains d
JOIN nameservers ns ON ns.domain_id = d.id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
@ -216,13 +216,13 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
ret := concat(ret, tmp_var, chr(10), chr(10));
-- origin a glue records
SELECT a_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var;
SELECT a_records FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret := concat(ret, '; Zone A Records', chr(10), tmp_var, chr(10));
-- a glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(ns.hostname, '. IN A ', unnest(ns.ipv4))
SELECT concat(coalesce(ns.hostname_puny, ns.hostname), '. IN A ', unnest(ns.ipv4))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
@ -236,13 +236,13 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text
ret := concat(ret, tmp_var, chr(10), chr(10));
-- origin aaaa glue records
SELECT a4_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var;
SELECT a4_records FROM zones zf WHERE i_origin = zf.origin INTO tmp_var;
ret := concat(ret, '; Zone AAAA Records', chr(10), tmp_var, chr(10));
-- aaaa glue records for other nameservers
SELECT array_to_string(
array(
SELECT concat(ns.hostname, '. IN AAAA ', unnest(ns.ipv6))
SELECT concat(coalesce(ns.hostname_puny, ns.hostname), '. IN AAAA ', unnest(ns.ipv6))
FROM nameservers ns
JOIN domains d ON d.id = ns.domain_id
WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter
@ -2374,44 +2374,6 @@ CREATE SEQUENCE log_white_ips_id_seq
ALTER SEQUENCE log_white_ips_id_seq OWNED BY log_white_ips.id;
--
-- Name: log_zonefile_settings; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE log_zonefile_settings (
id integer NOT NULL,
item_type character varying NOT NULL,
item_id integer NOT NULL,
event character varying NOT NULL,
whodunnit character varying,
object json,
object_changes json,
created_at timestamp without time zone,
session character varying,
children json,
uuid character varying
);
--
-- Name: log_zonefile_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE log_zonefile_settings_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: log_zonefile_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE log_zonefile_settings_id_seq OWNED BY log_zonefile_settings.id;
--
-- Name: mail_templates; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@ -2968,10 +2930,10 @@ ALTER SEQUENCE whois_records_id_seq OWNED BY whois_records.id;
--
-- Name: zonefile_settings; Type: TABLE; Schema: public; Owner: -; Tablespace:
-- Name: zones; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE zonefile_settings (
CREATE TABLE zones (
id integer NOT NULL,
origin character varying,
ttl integer,
@ -2992,10 +2954,10 @@ CREATE TABLE zonefile_settings (
--
-- Name: zonefile_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: -
-- Name: zones_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE zonefile_settings_id_seq
CREATE SEQUENCE zones_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -3004,10 +2966,10 @@ CREATE SEQUENCE zonefile_settings_id_seq
--
-- Name: zonefile_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
-- Name: zones_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE zonefile_settings_id_seq OWNED BY zonefile_settings.id;
ALTER SEQUENCE zones_id_seq OWNED BY zones.id;
--
@ -3381,13 +3343,6 @@ ALTER TABLE ONLY log_users ALTER COLUMN id SET DEFAULT nextval('log_users_id_seq
ALTER TABLE ONLY log_white_ips ALTER COLUMN id SET DEFAULT nextval('log_white_ips_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY log_zonefile_settings ALTER COLUMN id SET DEFAULT nextval('log_zonefile_settings_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@ -3490,7 +3445,7 @@ ALTER TABLE ONLY whois_records ALTER COLUMN id SET DEFAULT nextval('whois_record
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY zonefile_settings ALTER COLUMN id SET DEFAULT nextval('zonefile_settings_id_seq'::regclass);
ALTER TABLE ONLY zones ALTER COLUMN id SET DEFAULT nextval('zones_id_seq'::regclass);
--
@ -3917,14 +3872,6 @@ ALTER TABLE ONLY log_white_ips
ADD CONSTRAINT log_white_ips_pkey PRIMARY KEY (id);
--
-- Name: log_zonefile_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY log_zonefile_settings
ADD CONSTRAINT log_zonefile_settings_pkey PRIMARY KEY (id);
--
-- Name: mail_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@ -4038,11 +3985,11 @@ ALTER TABLE ONLY whois_records
--
-- Name: zonefile_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- Name: zones_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY zonefile_settings
ADD CONSTRAINT zonefile_settings_pkey PRIMARY KEY (id);
ALTER TABLE ONLY zones
ADD CONSTRAINT zones_pkey PRIMARY KEY (id);
--
@ -4675,20 +4622,6 @@ CREATE INDEX index_log_users_on_item_type_and_item_id ON log_users USING btree (
CREATE INDEX index_log_users_on_whodunnit ON log_users USING btree (whodunnit);
--
-- Name: index_log_zonefile_settings_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_zonefile_settings_on_item_type_and_item_id ON log_zonefile_settings USING btree (item_type, item_id);
--
-- Name: index_log_zonefile_settings_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_zonefile_settings_on_whodunnit ON log_zonefile_settings USING btree (whodunnit);
--
-- Name: index_messages_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -5280,3 +5213,11 @@ INSERT INTO schema_migrations (version) VALUES ('20161227193500');
INSERT INTO schema_migrations (version) VALUES ('20170221115548');
INSERT INTO schema_migrations (version) VALUES ('20170419120048');
INSERT INTO schema_migrations (version) VALUES ('20170420125200');
INSERT INTO schema_migrations (version) VALUES ('20170422130054');
INSERT INTO schema_migrations (version) VALUES ('20170422142116');

View file

@ -122,13 +122,6 @@ Crontab can be setup after deploy. Jobs can be viewed [here](/config/schedule.rb
mina pr cron:setup # to update the crontab.
mina pr cron:clear # to clear crontab.
### Zonefile procedure
Zonefile procedure must be set up in server after deploy. The same command must be run whenever procedure is updated (see changelog).
bundle exec rake zonefile:replace_procedure
### Application settings
Application settings locate at [config/application-example.yml](/config/application-example.yml)

View file

@ -142,11 +142,6 @@
<ellipse fill="none" stroke="black" cx="118" cy="246" rx="118.079" ry="18"/>
<text text-anchor="middle" x="118" y="249.7" font-family="Times,serif" font-size="14.00">Admin::DashboardsController</text>
</g>
<!-- Admin::ZonefileSettingsController -->
<g id="node27" class="node"><title>Admin::ZonefileSettingsController</title>
<ellipse fill="none" stroke="black" cx="135" cy="186" rx="134.576" ry="18"/>
<text text-anchor="middle" x="135" y="189.7" font-family="Times,serif" font-size="14.00">Admin::ZonefileSettingsController</text>
</g>
<!-- Admin::RegistrarsController -->
<g id="node28" class="node"><title>Admin::RegistrarsController</title>
<ellipse fill="none" stroke="black" cx="412" cy="186" rx="112.38" ry="18"/>

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

@ -377,20 +377,6 @@
<polyline fill="none" stroke="black" points="-720,16.5 -538,16.5 "/>
<text text-anchor="start" x="-712" y="31.7" font-family="Times,serif" font-size="14.00">_layout</text>
</g>
<!-- Admin::ZonefileSettingsController -->
<g id="node27" class="node"><title>Admin::ZonefileSettingsController</title>
<path fill="none" stroke="black" d="M532.5,279.5C532.5,279.5 715.5,279.5 715.5,279.5 721.5,279.5 727.5,273.5 727.5,267.5 727.5,267.5 727.5,138.5 727.5,138.5 727.5,132.5 721.5,126.5 715.5,126.5 715.5,126.5 532.5,126.5 532.5,126.5 526.5,126.5 520.5,132.5 520.5,138.5 520.5,138.5 520.5,267.5 520.5,267.5 520.5,273.5 526.5,279.5 532.5,279.5"/>
<text text-anchor="middle" x="624" y="141.7" font-family="Times,serif" font-size="14.00">Admin::ZonefileSettingsController</text>
<polyline fill="none" stroke="black" points="520.5,149.5 727.5,149.5 "/>
<text text-anchor="start" x="528.5" y="164.7" font-family="Times,serif" font-size="14.00">edit</text>
<text text-anchor="start" x="528.5" y="179.7" font-family="Times,serif" font-size="14.00">index</text>
<text text-anchor="start" x="528.5" y="194.7" font-family="Times,serif" font-size="14.00">update</text>
<polyline fill="none" stroke="black" points="520.5,202.5 727.5,202.5 "/>
<polyline fill="none" stroke="black" points="520.5,226.5 727.5,226.5 "/>
<text text-anchor="start" x="528.5" y="241.7" font-family="Times,serif" font-size="14.00">_layout</text>
<text text-anchor="start" x="528.5" y="256.7" font-family="Times,serif" font-size="14.00">set_zonefile_setting</text>
<text text-anchor="start" x="528.5" y="271.7" font-family="Times,serif" font-size="14.00">zonefile_setting_params</text>
</g>
<!-- Admin::RegistrarsController -->
<g id="node28" class="node"><title>Admin::RegistrarsController</title>
<path fill="none" stroke="black" d="M-67.5,479.5C-67.5,479.5 81.5,479.5 81.5,479.5 87.5,479.5 93.5,473.5 93.5,467.5 93.5,467.5 93.5,278.5 93.5,278.5 93.5,272.5 87.5,266.5 81.5,266.5 81.5,266.5 -67.5,266.5 -67.5,266.5 -73.5,266.5 -79.5,272.5 -79.5,278.5 -79.5,278.5 -79.5,467.5 -79.5,467.5 -79.5,473.5 -73.5,479.5 -67.5,479.5"/>

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Before After
Before After

View file

@ -337,17 +337,6 @@
<ellipse fill="none" stroke="#d1286a" cx="3516.25" cy="-77.2469" rx="4.00001" ry="4.00001"/>
<polygon fill="#d1286a" stroke="#d1286a" points="1658.36,-20.9371 1648.46,-16.2185 1653.36,-20.8273 1648.36,-20.7174 1648.36,-20.7174 1648.36,-20.7174 1653.36,-20.8273 1648.26,-25.2164 1658.36,-20.9371 1658.36,-20.9371"/>
</g>
<!-- ZonefileSettingVersion -->
<g id="node31" class="node"><title>ZonefileSettingVersion</title>
<ellipse fill="none" stroke="black" cx="3746.99" cy="-91" rx="92.8835" ry="18"/>
<text text-anchor="middle" x="3746.99" y="-87.3" font-family="Times,serif" font-size="14.00">ZonefileSettingVersion</text>
</g>
<!-- ZonefileSettingVersion&#45;&gt;VersionAssociation -->
<g id="edge29" class="edge"><title>ZonefileSettingVersion&#45;&gt;VersionAssociation</title>
<path fill="none" stroke="#fb178f" d="M3674.74,-76.7667C3664.77,-75.2902 3654.65,-73.9712 3644.99,-73 3407.38,-49.0969 3346.71,-60.9372 3107.99,-54 2557.18,-37.9931 1895.3,-25.0664 1658.57,-20.6418"/>
<ellipse fill="none" stroke="#fb178f" cx="3678.73" cy="-77.3767" rx="4.00001" ry="4.00001"/>
<polygon fill="#fb178f" stroke="#fb178f" points="1658.29,-20.6367 1648.38,-15.9509 1653.29,-20.5434 1648.3,-20.4501 1648.3,-20.4501 1648.3,-20.4501 1653.29,-20.5434 1648.21,-24.9493 1658.29,-20.6367 1658.29,-20.6367"/>
</g>
<!-- DomainVersion -->
<g id="node32" class="node"><title>DomainVersion</title>
<ellipse fill="none" stroke="black" cx="1244.99" cy="-307" rx="67.6881" ry="18"/>
@ -1219,18 +1208,6 @@
<ellipse fill="none" stroke="black" cx="4032.99" cy="-523" rx="89.0842" ry="18"/>
<text text-anchor="middle" x="4032.99" y="-519.3" font-family="Times,serif" font-size="14.00">RegistrantVerification</text>
</g>
<!-- ZonefileSetting -->
<g id="node49" class="node"><title>ZonefileSetting</title>
<ellipse fill="none" stroke="black" cx="3746.99" cy="-199" rx="65.7887" ry="18"/>
<text text-anchor="middle" x="3746.99" y="-195.3" font-family="Times,serif" font-size="14.00">ZonefileSetting</text>
</g>
<!-- ZonefileSetting&#45;&gt;ZonefileSettingVersion -->
<g id="edge74" class="edge"><title>ZonefileSetting&#45;&gt;ZonefileSettingVersion</title>
<path fill="none" stroke="#881b39" d="M3746.99,-172.795C3746.99,-156.735 3746.99,-135.927 3746.99,-119.45"/>
<ellipse fill="none" stroke="#881b39" cx="3746.99" cy="-176.969" rx="4" ry="4"/>
<polygon fill="#881b39" stroke="#881b39" points="3746.99,-119.341 3751.49,-109.341 3746.99,-114.341 3746.99,-109.341 3746.99,-109.341 3746.99,-109.341 3746.99,-114.341 3742.49,-109.341 3746.99,-119.341 3746.99,-119.341"/>
<text text-anchor="middle" x="3769.99" y="-141.3" font-family="Times,serif" font-size="14.00">versions</text>
</g>
<!-- TechDomainContact&#45;&gt;DomainContactVersion -->
<g id="edge75" class="edge"><title>TechDomainContact&#45;&gt;DomainContactVersion</title>
<path fill="none" stroke="#727588" d="M1971.52,-284.313C1929.46,-250.063 1844.49,-181.719 1769.99,-127 1764.3,-122.814 1758.15,-118.466 1752.18,-114.317"/>

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Before After
Before After

View file

@ -665,28 +665,6 @@
<ellipse fill="none" stroke="#9131a9" cx="3586.29" cy="-75.9354" rx="4.00002" ry="4.00002"/>
<polygon fill="#9131a9" stroke="#9131a9" points="1845.79,-21.5158 1835.92,-16.7338 1840.79,-21.3739 1835.79,-21.232 1835.79,-21.232 1835.79,-21.232 1840.79,-21.3739 1835.67,-25.7301 1845.79,-21.5158 1845.79,-21.5158"/>
</g>
<!-- ZonefileSettingVersion -->
<g id="node31" class="node"><title>ZonefileSettingVersion</title>
<path fill="none" stroke="black" d="M3937.5,-73.5C3937.5,-73.5 4056.5,-73.5 4056.5,-73.5 4062.5,-73.5 4068.5,-79.5 4068.5,-85.5 4068.5,-85.5 4068.5,-242.5 4068.5,-242.5 4068.5,-248.5 4062.5,-254.5 4056.5,-254.5 4056.5,-254.5 3937.5,-254.5 3937.5,-254.5 3931.5,-254.5 3925.5,-248.5 3925.5,-242.5 3925.5,-242.5 3925.5,-85.5 3925.5,-85.5 3925.5,-79.5 3931.5,-73.5 3937.5,-73.5"/>
<text text-anchor="middle" x="3997" y="-239.3" font-family="Times,serif" font-size="14.00">ZonefileSettingVersion</text>
<polyline fill="none" stroke="black" points="3925.5,-231.5 4068.5,-231.5 "/>
<text text-anchor="start" x="3933.5" y="-216.3" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="3933.5" y="-201.3" font-family="Times,serif" font-size="14.00">item_type :string</text>
<text text-anchor="start" x="3933.5" y="-186.3" font-family="Times,serif" font-size="14.00">item_id :integer</text>
<text text-anchor="start" x="3933.5" y="-171.3" font-family="Times,serif" font-size="14.00">event :string</text>
<text text-anchor="start" x="3933.5" y="-156.3" font-family="Times,serif" font-size="14.00">whodunnit :string</text>
<text text-anchor="start" x="3933.5" y="-141.3" font-family="Times,serif" font-size="14.00">object :json</text>
<text text-anchor="start" x="3933.5" y="-126.3" font-family="Times,serif" font-size="14.00">object_changes :json</text>
<text text-anchor="start" x="3933.5" y="-111.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="3933.5" y="-96.3" font-family="Times,serif" font-size="14.00">session :string</text>
<text text-anchor="start" x="3933.5" y="-81.3" font-family="Times,serif" font-size="14.00">children :json</text>
</g>
<!-- ZonefileSettingVersion&#45;&gt;VersionAssociation -->
<g id="edge29" class="edge"><title>ZonefileSettingVersion&#45;&gt;VersionAssociation</title>
<path fill="none" stroke="#cc510c" d="M3917.83,-129.497C3865.31,-109.014 3794.29,-84.5899 3729,-73 3542.63,-39.9179 2207.66,-23.7038 1846.75,-19.8943"/>
<ellipse fill="none" stroke="#cc510c" cx="3921.72" cy="-131.026" rx="4.00001" ry="4.00001"/>
<polygon fill="#cc510c" stroke="#cc510c" points="1846.61,-19.8929 1836.66,-15.2881 1841.61,-19.8404 1836.61,-19.7879 1836.61,-19.7879 1836.61,-19.7879 1841.61,-19.8404 1836.57,-24.2876 1846.61,-19.8929 1846.61,-19.8929"/>
</g>
<!-- DomainVersion -->
<g id="node32" class="node"><title>DomainVersion</title>
<path fill="none" stroke="black" d="M1277.5,-1158.5C1277.5,-1158.5 1400.5,-1158.5 1400.5,-1158.5 1406.5,-1158.5 1412.5,-1164.5 1412.5,-1170.5 1412.5,-1170.5 1412.5,-1372.5 1412.5,-1372.5 1412.5,-1378.5 1406.5,-1384.5 1400.5,-1384.5 1400.5,-1384.5 1277.5,-1384.5 1277.5,-1384.5 1271.5,-1384.5 1265.5,-1378.5 1265.5,-1372.5 1265.5,-1372.5 1265.5,-1170.5 1265.5,-1170.5 1265.5,-1164.5 1271.5,-1158.5 1277.5,-1158.5"/>
@ -1981,32 +1959,6 @@
<text text-anchor="start" x="4134" y="-2436.8" font-family="Times,serif" font-size="14.00">domain_id :integer</text>
<text text-anchor="start" x="4134" y="-2421.8" font-family="Times,serif" font-size="14.00">action_type :string</text>
</g>
<!-- ZonefileSetting -->
<g id="node49" class="node"><title>ZonefileSetting</title>
<path fill="none" stroke="black" d="M4115.5,-481C4115.5,-481 4252.5,-481 4252.5,-481 4258.5,-481 4264.5,-487 4264.5,-493 4264.5,-493 4264.5,-695 4264.5,-695 4264.5,-701 4258.5,-707 4252.5,-707 4252.5,-707 4115.5,-707 4115.5,-707 4109.5,-707 4103.5,-701 4103.5,-695 4103.5,-695 4103.5,-493 4103.5,-493 4103.5,-487 4109.5,-481 4115.5,-481"/>
<text text-anchor="middle" x="4184" y="-691.8" font-family="Times,serif" font-size="14.00">ZonefileSetting</text>
<polyline fill="none" stroke="black" points="4103.5,-684 4264.5,-684 "/>
<text text-anchor="start" x="4111.5" y="-668.8" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="4111.5" y="-653.8" font-family="Times,serif" font-size="14.00">origin :string</text>
<text text-anchor="start" x="4111.5" y="-638.8" font-family="Times,serif" font-size="14.00">ttl :integer</text>
<text text-anchor="start" x="4111.5" y="-623.8" font-family="Times,serif" font-size="14.00">refresh :integer</text>
<text text-anchor="start" x="4111.5" y="-608.8" font-family="Times,serif" font-size="14.00">retry :integer</text>
<text text-anchor="start" x="4111.5" y="-593.8" font-family="Times,serif" font-size="14.00">expire :integer</text>
<text text-anchor="start" x="4111.5" y="-578.8" font-family="Times,serif" font-size="14.00">minimum_ttl :integer</text>
<text text-anchor="start" x="4111.5" y="-563.8" font-family="Times,serif" font-size="14.00">email :string</text>
<text text-anchor="start" x="4111.5" y="-548.8" font-family="Times,serif" font-size="14.00">master_nameserver :string</text>
<text text-anchor="start" x="4111.5" y="-533.8" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="4111.5" y="-518.8" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
<text text-anchor="start" x="4111.5" y="-503.8" font-family="Times,serif" font-size="14.00">creator_str :string</text>
<text text-anchor="start" x="4111.5" y="-488.8" font-family="Times,serif" font-size="14.00">updator_str :string</text>
</g>
<!-- ZonefileSetting&#45;&gt;ZonefileSettingVersion -->
<g id="edge74" class="edge"><title>ZonefileSetting&#45;&gt;ZonefileSettingVersion</title>
<path fill="none" stroke="#afb253" d="M4139.2,-472.941C4115.67,-412.317 4085.46,-338.025 4055,-273 4053.6,-270.013 4052.16,-266.991 4050.68,-263.95"/>
<ellipse fill="none" stroke="#afb253" cx="4140.74" cy="-476.912" rx="4.00001" ry="4.00001"/>
<polygon fill="#afb253" stroke="#afb253" points="4050.59,-263.757 4050.21,-252.798 4048.38,-259.272 4046.17,-254.786 4046.17,-254.786 4046.17,-254.786 4048.38,-259.272 4042.13,-256.775 4050.59,-263.757 4050.59,-263.757"/>
<text text-anchor="middle" x="4154" y="-360.3" font-family="Times,serif" font-size="14.00">versions</text>
</g>
<!-- TechDomainContact&#45;&gt;DomainContactVersion -->
<g id="edge75" class="edge"><title>TechDomainContact&#45;&gt;DomainContactVersion</title>
<path fill="none" stroke="#5e4961" d="M2208.23,-1157.73C2184.3,-1002.55 2136.91,-714.902 2080,-473 2058.81,-382.908 2056.36,-358.939 2022,-273 2020.78,-269.96 2019.51,-266.893 2018.19,-263.812"/>

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 246 KiB

Before After
Before After

View file

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

View file

@ -57,7 +57,6 @@ namespace :import do
Rake::Task['import:reserved'].invoke
Rake::Task['import:domains'].invoke
Rake::Task['import:zones'].invoke
Rake::Task['zonefile:replace_procedure'].invoke
end
desc 'Import registrars'
@ -605,7 +604,7 @@ namespace :import do
ns_records, a_records, a4_records = parse_zone_ns_data('ee', 1)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'ee',
ttl: 43200,
refresh: 3600,
@ -622,7 +621,7 @@ namespace :import do
# edu.ee
ns_records, a_records, a4_records = parse_zone_ns_data('edu.ee', 6)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'edu.ee',
ttl: 43200,
refresh: 3600,
@ -639,7 +638,7 @@ namespace :import do
# aip.ee
ns_records, a_records, a4_records = parse_zone_ns_data('aip.ee', 9)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'aip.ee',
ttl: 43200,
refresh: 3600,
@ -656,7 +655,7 @@ namespace :import do
# org.ee
ns_records, a_records, a4_records = parse_zone_ns_data('org.ee', 10)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'org.ee',
ttl: 43200,
refresh: 3600,
@ -673,7 +672,7 @@ namespace :import do
# pri.ee
ns_records, a_records, a4_records = parse_zone_ns_data('pri.ee', 2)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'pri.ee',
ttl: 43200,
refresh: 3600,
@ -690,7 +689,7 @@ namespace :import do
# med.ee
ns_records, a_records, a4_records = parse_zone_ns_data('med.ee', 3)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'med.ee',
ttl: 43200,
refresh: 3600,
@ -707,7 +706,7 @@ namespace :import do
# fie.ee
ns_records, a_records, a4_records = parse_zone_ns_data('fie.ee', 4)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'fie.ee',
ttl: 43200,
refresh: 3600,
@ -724,7 +723,7 @@ namespace :import do
# com.ee
ns_records, a_records, a4_records = parse_zone_ns_data('com.ee', 5)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'com.ee',
ttl: 43200,
refresh: 3600,
@ -741,7 +740,7 @@ namespace :import do
# gov.ee
ns_records, a_records, a4_records = parse_zone_ns_data('gov.ee', 7)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'gov.ee',
ttl: 43200,
refresh: 3600,
@ -758,7 +757,7 @@ namespace :import do
# riik.ee
ns_records, a_records, a4_records = parse_zone_ns_data('riik.ee', 8)
ZonefileSetting.create!({
DNS::Zone.create!({
origin: 'riik.ee',
ttl: 43200,
refresh: 3600,

View file

@ -1,4 +1,4 @@
Fabricator(:zonefile_setting) do
Fabricator(:zone, from: 'DNS::Zone') do
origin 'ee'
ttl 43200
refresh 3600

View file

@ -0,0 +1,12 @@
FactoryGirl.define do
factory :zone, class: DNS::Zone do
origin 'test'
ttl 1
refresh 1
add_attribute :retry, 1
expire 1
minimum_ttl 1
email 'test@test.test'
master_nameserver 'test.test'
end
end

View file

@ -0,0 +1,16 @@
require 'rails_helper'
RSpec.feature 'Deleting zone in admin area', settings: false do
given!(:zone) { create(:zone) }
background do
sign_in_to_admin_area
end
scenario 'deletes zone' do
visit edit_admin_zone_url(zone)
click_link_or_button t('admin.dns.zones.edit.delete_btn')
expect(page).to have_text(t('admin.dns.zones.destroy.destroyed'))
end
end

View file

@ -0,0 +1,29 @@
require 'rails_helper'
RSpec.feature 'Editing zone in admin area', settings: false do
given!(:zone) { create(:zone) }
background do
sign_in_to_admin_area
end
scenario 'updates zone' do
open_list
open_form
submit_form
expect(page).to have_text(t('admin.dns.zones.update.updated'))
end
def open_list
click_link_or_button t('admin.menu.zones')
end
def open_form
click_link_or_button t('admin.dns.zones.zone.edit_btn')
end
def submit_form
click_link_or_button t('admin.dns.zones.form.update_btn')
end
end

View file

@ -0,0 +1,39 @@
require 'rails_helper'
RSpec.feature 'New zone in admin area', settings: false do
background do
sign_in_to_admin_area
end
scenario 'it creates new zone' do
open_list
open_form
fill_form
submit_form
expect(page).to have_text(t('admin.dns.zones.create.created'))
end
def open_list
click_link_or_button t('admin.menu.zones')
end
def open_form
click_link_or_button t('admin.dns.zones.index.new_btn')
end
def fill_form
fill_in 'zone_origin', with: 'test'
fill_in 'zone_ttl', with: '1'
fill_in 'zone_refresh', with: '1'
fill_in 'zone_retry', with: '1'
fill_in 'zone_expire', with: '1'
fill_in 'zone_minimum_ttl', with: '1'
fill_in 'zone_email', with: 'test@test.com'
fill_in 'zone_master_nameserver', with: 'test.test'
end
def submit_form
click_link_or_button t('admin.dns.zones.form.create_btn')
end
end

View file

@ -7,7 +7,7 @@ RSpec.describe Domain, db: false do
before :example do
travel_to Time.zone.parse('05.07.2010 00:00')
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
Fabricate.create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
Fabricate.create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))

View file

@ -4,7 +4,7 @@ RSpec.describe Domain do
it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) }
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
it 'should set force delete time' do

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe Contact do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
context 'about class' do
@ -328,7 +328,7 @@ end
describe Contact, '.destroy_orphans' do
before do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
@contact_1 = Fabricate(:contact, code: 'asd12')
@contact_2 = Fabricate(:contact, code: 'asd13')
end

View file

@ -1,10 +1,6 @@
require 'rails_helper'
RSpec.describe ZonefileSetting, db: false do
it 'has versions' do
expect(described_class.new.versions).to eq([])
end
RSpec.describe DNS::Zone do
describe '::origins' do
before :example do
expect(described_class).to receive(:pluck).with(:origin).and_return('origins')

View file

@ -21,7 +21,7 @@ describe Dnskey do
Setting.client_side_status_editing_enabled = true
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe DomainCron do
it 'should expire domains' do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
@domain = Fabricate(:domain)
Setting.expire_warning_period = 1
@ -25,7 +25,7 @@ RSpec.describe DomainCron do
end
it 'should start redemption grace period' do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
@domain = Fabricate(:domain)
old_valid_to = Time.zone.now - 10.days

View file

@ -21,11 +21,11 @@ RSpec.describe Domain do
Setting.client_side_status_editing_enabled = true
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zonefile_setting, origin: 'pri.ee')
Fabricate(:zonefile_setting, origin: 'med.ee')
Fabricate(:zonefile_setting, origin: 'fie.ee')
Fabricate(:zonefile_setting, origin: 'com.ee')
Fabricate(:zone, origin: 'ee')
Fabricate(:zone, origin: 'pri.ee')
Fabricate(:zone, origin: 'med.ee')
Fabricate(:zone, origin: 'fie.ee')
Fabricate(:zone, origin: 'com.ee')
end
context 'with invalid attribute' do
@ -809,7 +809,7 @@ RSpec.describe Domain, db: false do
before :example do
travel_to Time.zone.parse('05.07.2010 00:00')
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
Fabricate.create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59'))
Fabricate.create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00'))
@ -825,7 +825,7 @@ RSpec.describe Domain, db: false do
before :example do
travel_to Time.zone.parse('05.07.2010 00:00')
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
Fabricate.create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59'))
Fabricate.create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00'))

View file

@ -21,7 +21,7 @@ describe DomainTransfer do
Setting.client_side_status_editing_enabled = true
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do

View file

@ -21,7 +21,7 @@ describe Keyrelay do
Setting.client_side_status_editing_enabled = true
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do

View file

@ -3,11 +3,11 @@ require 'rails_helper'
describe LegalDocument do
context 'tasks' do
it 'make files uniq' do
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zonefile_setting, origin: 'pri.ee')
Fabricate(:zonefile_setting, origin: 'med.ee')
Fabricate(:zonefile_setting, origin: 'fie.ee')
Fabricate(:zonefile_setting, origin: 'com.ee')
Fabricate(:zone, origin: 'ee')
Fabricate(:zone, origin: 'pri.ee')
Fabricate(:zone, origin: 'med.ee')
Fabricate(:zone, origin: 'fie.ee')
Fabricate(:zone, origin: 'com.ee')
LegalDocument.explicitly_write_file = true
PaperTrail.enabled = true

View file

@ -21,7 +21,7 @@ describe Nameserver do
Setting.client_side_status_editing_enabled = true
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do

View file

@ -21,7 +21,7 @@ describe RegistrantVerification do
Setting.client_side_status_editing_enabled = true
Fabricate(:zonefile_setting, origin: 'ee')
Fabricate(:zone, origin: 'ee')
end
context 'with invalid attribute' do
before :example do

View file

@ -0,0 +1,36 @@
require 'rails_helper'
RSpec.describe 'admin zone create', settings: false do
subject(:zone) { DNS::Zone.first }
before :example do
sign_in_to_admin_area
end
it 'creates new zone' do
expect { post admin_zones_path, zone: attributes_for(:zone) }
.to change { DNS::Zone.count }.from(0).to(1)
end
text_attributes = %i[origin email master_nameserver]
integer_attributes = %i[ttl refresh retry expire minimum_ttl]
text_attributes.each do |attr_name|
it "saves #{attr_name}" do
post admin_zones_path, { zone: attributes_for(:zone, attr_name => 'test') }
expect(zone.send(attr_name)).to eq('test')
end
end
integer_attributes.each do |attr_name|
it "saves #{attr_name}" do
post admin_zones_path, { zone: attributes_for(:zone, attr_name => '1') }
expect(zone.send(attr_name)).to eq(1)
end
end
it 'redirects to :index' do
post admin_zones_path, { zone: attributes_for(:zone) }
expect(response).to redirect_to admin_zones_url
end
end

View file

@ -0,0 +1,18 @@
require 'rails_helper'
RSpec.describe 'admin zone destroy', settings: false do
let!(:zone) { create(:zone) }
before :example do
sign_in_to_admin_area
end
it 'deletes zone' do
expect { delete admin_zone_path(zone) }.to change { DNS::Zone.count }.from(1).to(0)
end
it 'redirects to :index' do
delete admin_zone_path(zone)
expect(response).to redirect_to admin_zones_url
end
end

View file

@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe 'admin zone update', settings: false do
before :example do
sign_in_to_admin_area
end
text_attributes = %i[origin email master_nameserver]
integer_attributes = %i[ttl refresh retry expire minimum_ttl]
text_attributes.each do |attr_name|
it "updates #{attr_name}" do
zone = create(:zone, attr_name => 'test')
patch admin_zone_path(zone), zone: attributes_for(:zone, attr_name => 'new-test')
zone.reload
expect(zone.send(attr_name)).to eq('new-test')
end
end
integer_attributes.each do |attr_name|
it "updates #{attr_name}" do
zone = create(:zone, attr_name => '1')
patch admin_zone_path(zone), zone: attributes_for(:zone, attr_name => '2')
zone.reload
expect(zone.send(attr_name)).to eq(2)
end
end
it 'redirects to :index' do
zone = create(:zone)
patch admin_zone_path(zone), { zone: attributes_for(:zone) }
expect(response).to redirect_to admin_zones_url
end
end

View file

@ -1,7 +1,7 @@
RSpec.configure do |config|
config.before :example do |example|
if example.metadata[:db]
Fabricate(:zonefile_setting, origin: 'com')
if example.metadata[:db] && (example.metadata[:settings] != false)
Fabricate(:zone, origin: 'com')
Setting.ds_algorithm = 2
Setting.ds_data_allowed = true

View file

@ -0,0 +1,40 @@
require 'rails_helper'
RSpec.describe 'admin/dns/zones/index' do
let(:zones) { [] }
before :example do
assign(:zones, zones)
stub_template '_zone' => 'zone-row'
end
it 'has title' do
render
expect(rendered).to have_text(t('admin.dns.zones.index.title'))
end
context 'when zones are present' do
let(:zones) { [build_stubbed(:zone)] }
it 'has zone row' do
render
expect(rendered).to have_text('zone-row')
end
it 'has no :not_found message' do
render
expect(rendered).to_not have_text(not_found_message)
end
end
context 'when zones are absent' do
it 'has :not_found message' do
render
expect(rendered).to have_text(not_found_message)
end
end
def not_found_message
t('admin.dns.zones.index.not_found')
end
end