mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
02e313db46
41 changed files with 237 additions and 695 deletions
3
Gemfile
3
Gemfile
|
@ -67,6 +67,9 @@ gem 'selectize-rails', '~> 0.11.0'
|
||||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||||
gem 'therubyracer', platforms: :ruby
|
gem 'therubyracer', platforms: :ruby
|
||||||
|
|
||||||
|
# for settings
|
||||||
|
gem 'rails-settings-cached', '0.4.1'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'capybara', '~> 2.4.1'
|
gem 'capybara', '~> 2.4.1'
|
||||||
# For feature testing
|
# For feature testing
|
||||||
|
|
|
@ -200,6 +200,8 @@ GEM
|
||||||
bundler (>= 1.3.0, < 2.0)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
railties (= 4.1.4)
|
railties (= 4.1.4)
|
||||||
sprockets-rails (~> 2.0)
|
sprockets-rails (~> 2.0)
|
||||||
|
rails-settings-cached (0.4.1)
|
||||||
|
rails (>= 4.0.0)
|
||||||
railties (4.1.4)
|
railties (4.1.4)
|
||||||
actionpack (= 4.1.4)
|
actionpack (= 4.1.4)
|
||||||
activesupport (= 4.1.4)
|
activesupport (= 4.1.4)
|
||||||
|
@ -376,6 +378,7 @@ DEPENDENCIES
|
||||||
poltergeist (~> 1.5.1)
|
poltergeist (~> 1.5.1)
|
||||||
pry (~> 0.10.1)
|
pry (~> 0.10.1)
|
||||||
rails (= 4.1.4)
|
rails (= 4.1.4)
|
||||||
|
rails-settings-cached (= 0.4.1)
|
||||||
ransack (~> 1.3.0)
|
ransack (~> 1.3.0)
|
||||||
rspec-rails (~> 3.0.2)
|
rspec-rails (~> 3.0.2)
|
||||||
rubocop (~> 0.26.1)
|
rubocop (~> 0.26.1)
|
||||||
|
|
|
@ -26,7 +26,7 @@ group :red_green_refactor, halt_on_fail: true do
|
||||||
|
|
||||||
# Martin does not want rubocop
|
# Martin does not want rubocop
|
||||||
unless Socket.gethostname == 'martin'
|
unless Socket.gethostname == 'martin'
|
||||||
guard :rubocop, cli: '--display-cop-names -c .rubocop-guard.yml', notification: false do
|
guard :rubocop, cli: '--display-cop-names -c .rubocop-guard.yml -f fuubar', notification: false do
|
||||||
watch(%r{.+\.rb$})
|
watch(%r{.+\.rb$})
|
||||||
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||||
watch(%r{(?:.+/)?\.rubocop-guard\.yml$}) { |m| File.dirname(m[0]) }
|
watch(%r{(?:.+/)?\.rubocop-guard\.yml$}) { |m| File.dirname(m[0]) }
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Admin::DomainsController < AdminController
|
||||||
before_action :set_domain, only: [:show, :edit, :update]
|
before_action :set_domain, only: [:show, :edit, :update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = Domain.search(params[:q])
|
@q = Domain.includes(:registrar, :owner_contact).search(params[:q])
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
class Admin::SettingGroupsController < AdminController
|
|
||||||
before_action :set_setting_group, only: [:show, :update]
|
|
||||||
|
|
||||||
def index
|
|
||||||
@q = SettingGroup.search(params[:q])
|
|
||||||
@setting_groups = @q.result.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def show; end
|
|
||||||
|
|
||||||
def update
|
|
||||||
if @setting_group.update(setting_group_params)
|
|
||||||
flash[:notice] = I18n.t('shared.setting_updated')
|
|
||||||
redirect_to [:admin, @setting_group]
|
|
||||||
else
|
|
||||||
flash[:alert] = I18n.t('shared.failed_to_update_setting')
|
|
||||||
render 'show'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_setting_group
|
|
||||||
@setting_group = SettingGroup.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def setting_group_params
|
|
||||||
params.require(:setting_group).permit(settings_attributes: [:value, :id])
|
|
||||||
end
|
|
||||||
end
|
|
48
app/controllers/admin/settings_controller.rb
Normal file
48
app/controllers/admin/settings_controller.rb
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
class Admin::SettingsController < AdminController
|
||||||
|
before_action :set_setting_group, only: [:show, :update]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@settings = Setting.unscoped
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
casted_settings.each do |k, v|
|
||||||
|
Setting[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
flash[:notice] = I18n.t('shared.records_updated')
|
||||||
|
redirect_to [:admin, :settings]
|
||||||
|
end
|
||||||
|
|
||||||
|
def show; end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @setting_group.update(setting_group_params)
|
||||||
|
flash[:notice] = I18n.t('shared.setting_updated')
|
||||||
|
redirect_to [:admin, @setting_group]
|
||||||
|
else
|
||||||
|
flash[:alert] = I18n.t('shared.failed_to_update_setting')
|
||||||
|
render 'show'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_setting_group
|
||||||
|
@setting_group = SettingGroup.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def setting_group_params
|
||||||
|
params.require(:setting_group).permit(settings_attributes: [:value, :id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def casted_settings
|
||||||
|
settings = {}
|
||||||
|
params[:settings].each do |k, v|
|
||||||
|
settings[k] = v.to_i if Setting[k].class == Fixnum
|
||||||
|
settings[k] = v.to_f if Setting[k].class == Float
|
||||||
|
settings[k] = (v == 'true' ? true : false) if [TrueClass, FalseClass].include?(Setting[k].class)
|
||||||
|
end
|
||||||
|
settings
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,7 +4,7 @@ class Client::DomainsController < ClientController
|
||||||
before_action :verify_deletion, only: [:destroy]
|
before_action :verify_deletion, only: [:destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = current_registrar.domains.search(params[:q])
|
@q = current_registrar.domains.includes(:owner_contact).search(params[:q])
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
class DelegationSigner < ActiveRecord::Base
|
|
||||||
include EppErrors
|
|
||||||
has_one :dnskeys
|
|
||||||
|
|
||||||
validate :validate_dnskeys_uniqueness
|
|
||||||
validate :validate_dnskeys_count
|
|
||||||
|
|
||||||
def epp_code_map
|
|
||||||
sg = SettingGroup.domain_validation
|
|
||||||
|
|
||||||
{
|
|
||||||
'2004' => [ # Parameter value range error
|
|
||||||
[:dnskeys, :out_of_range,
|
|
||||||
{
|
|
||||||
min: sg.setting(Setting::DNSKEYS_MIN_COUNT).value,
|
|
||||||
max: sg.setting(Setting::DNSKEYS_MAX_COUNT).value
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_dnskeys_count
|
|
||||||
sg = SettingGroup.domain_validation
|
|
||||||
min, max = sg.setting(:dnskeys_min_count).value.to_i, sg.setting(:dnskeys_max_count).value.to_i
|
|
||||||
return if dnskeys.reject(&:marked_for_destruction?).length.between?(min, max)
|
|
||||||
errors.add(:dnskeys, :out_of_range, { min: min, max: max })
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_dnskeys_uniqueness
|
|
||||||
validated = []
|
|
||||||
list = dnskeys.reject(&:marked_for_destruction?)
|
|
||||||
list.each do |dnskey|
|
|
||||||
next if dnskey.public_key.blank?
|
|
||||||
existing = list.select { |x| x.public_key == dnskey.public_key }
|
|
||||||
next unless existing.length > 1
|
|
||||||
validated << dnskey.public_key
|
|
||||||
errors.add(:dnskeys, :invalid) if errors[:dnskeys].blank?
|
|
||||||
dnskey.errors.add(:public_key, :taken)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -66,11 +66,9 @@ class Dnskey < ActiveRecord::Base
|
||||||
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
|
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
|
||||||
bin = self.class.hex_to_bin(hex)
|
bin = self.class.hex_to_bin(hex)
|
||||||
|
|
||||||
sg = SettingGroup.dnskeys.setting(Setting::DS_ALGORITHM).value
|
if Setting.ds_algorithm == 1
|
||||||
|
|
||||||
if sg == '1'
|
|
||||||
self.ds_digest = Digest::SHA1.hexdigest(bin).upcase
|
self.ds_digest = Digest::SHA1.hexdigest(bin).upcase
|
||||||
elsif sg == '2'
|
elsif Setting.ds_algorithm == 2
|
||||||
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
|
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -103,9 +103,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
### VALIDATIONS ###
|
### VALIDATIONS ###
|
||||||
def validate_nameservers_count
|
def validate_nameservers_count
|
||||||
sg = SettingGroup.domain_validation
|
min, max = Setting.ns_min_count, Setting.ns_max_count
|
||||||
min, max = sg.setting(:ns_min_count).value.to_i, sg.setting(:ns_max_count).value.to_i
|
|
||||||
|
|
||||||
return if nameservers.reject(&:marked_for_destruction?).length.between?(min, max)
|
return if nameservers.reject(&:marked_for_destruction?).length.between?(min, max)
|
||||||
errors.add(:nameservers, :out_of_range, { min: min, max: max })
|
errors.add(:nameservers, :out_of_range, { min: min, max: max })
|
||||||
end
|
end
|
||||||
|
@ -115,8 +113,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_dnskeys_count
|
def validate_dnskeys_count
|
||||||
sg = SettingGroup.domain_validation
|
min, max = Setting.dnskeys_min_count, Setting.dnskeys_max_count
|
||||||
min, max = sg.setting(:dnskeys_min_count).value.to_i, sg.setting(:dnskeys_max_count).value.to_i
|
|
||||||
return if dnskeys.reject(&:marked_for_destruction?).length.between?(min, max)
|
return if dnskeys.reject(&:marked_for_destruction?).length.between?(min, max)
|
||||||
errors.add(:dnskeys, :out_of_range, { min: min, max: max })
|
errors.add(:dnskeys, :out_of_range, { min: min, max: max })
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ class DomainTransfer < ActiveRecord::Base
|
||||||
before_create :set_wait_until
|
before_create :set_wait_until
|
||||||
|
|
||||||
def set_wait_until
|
def set_wait_until
|
||||||
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
wait_time = Setting.transfer_wait_time
|
||||||
return if wait_time == 0
|
return if wait_time == 0
|
||||||
self.wait_until = transfer_requested_at + wait_time.hours
|
self.wait_until = transfer_requested_at + wait_time.hours
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,6 @@ class Epp::EppDomain < Domain
|
||||||
validate :validate_admin_contacts_count
|
validate :validate_admin_contacts_count
|
||||||
|
|
||||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||||
domain_validation_sg = SettingGroup.domain_validation
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'2002' => [
|
'2002' => [
|
||||||
[:base, :domain_already_belongs_to_the_querying_registrar]
|
[:base, :domain_already_belongs_to_the_querying_registrar]
|
||||||
|
@ -29,15 +27,15 @@ class Epp::EppDomain < Domain
|
||||||
'2004' => [ # Parameter value range error
|
'2004' => [ # Parameter value range error
|
||||||
[:nameservers, :out_of_range,
|
[:nameservers, :out_of_range,
|
||||||
{
|
{
|
||||||
min: domain_validation_sg.setting(:ns_min_count).value,
|
min: Setting.ns_min_count,
|
||||||
max: domain_validation_sg.setting(:ns_max_count).value
|
max: Setting.ns_max_count
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[:period, :out_of_range, { value: { obj: 'period', val: period } }],
|
[:period, :out_of_range, { value: { obj: 'period', val: period } }],
|
||||||
[:dnskeys, :out_of_range,
|
[:dnskeys, :out_of_range,
|
||||||
{
|
{
|
||||||
min: domain_validation_sg.setting(Setting::DNSKEYS_MIN_COUNT).value,
|
min: Setting.dnskeys_min_count,
|
||||||
max: domain_validation_sg.setting(Setting::DNSKEYS_MAX_COUNT).value
|
max: Setting.dnskeys_max_count
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -189,8 +187,7 @@ class Epp::EppDomain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_dnskeys(dnssec_data)
|
def attach_dnskeys(dnssec_data)
|
||||||
sg = SettingGroup.dnskeys
|
return false unless validate_dnssec_data(dnssec_data)
|
||||||
return false unless validate_dnssec_data(dnssec_data, sg)
|
|
||||||
|
|
||||||
dnssec_data[:ds_data].each do |ds_data|
|
dnssec_data[:ds_data].each do |ds_data|
|
||||||
dnskeys.build(ds_data)
|
dnskeys.build(ds_data)
|
||||||
|
@ -200,41 +197,35 @@ class Epp::EppDomain < Domain
|
||||||
dnskeys.build({
|
dnskeys.build({
|
||||||
ds_key_tag: SecureRandom.hex(5),
|
ds_key_tag: SecureRandom.hex(5),
|
||||||
ds_alg: 3,
|
ds_alg: 3,
|
||||||
ds_digest_type: sg.setting(Setting::DS_ALGORITHM).value
|
ds_digest_type: Setting.ds_algorithm
|
||||||
}.merge(x))
|
}.merge(x))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_dnssec_data(dnssec_data, sg)
|
def validate_dnssec_data(dnssec_data)
|
||||||
ds_data_allowed?(dnssec_data, sg)
|
ds_data_allowed?(dnssec_data)
|
||||||
ds_data_with_keys_allowed?(dnssec_data, sg)
|
ds_data_with_keys_allowed?(dnssec_data)
|
||||||
key_data_allowed?(dnssec_data, sg)
|
key_data_allowed?(dnssec_data)
|
||||||
|
|
||||||
errors.empty?
|
errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def ds_data_allowed?(dnssec_data, sg)
|
def ds_data_allowed?(dnssec_data)
|
||||||
ds_data_allowed = sg.setting(Setting::ALLOW_DS_DATA).value == '0' ? false : true
|
return if (dnssec_data[:ds_data].any? && Setting.ds_data_allowed) || dnssec_data[:ds_data].empty?
|
||||||
|
|
||||||
return if (dnssec_data[:ds_data].any? && ds_data_allowed) || dnssec_data[:ds_data].empty?
|
|
||||||
errors.add(:base, :ds_data_not_allowed)
|
errors.add(:base, :ds_data_not_allowed)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ds_data_with_keys_allowed?(dnssec_data, sg)
|
def ds_data_with_keys_allowed?(dnssec_data)
|
||||||
ds_data_with_keys_allowed = sg.setting(Setting::ALLOW_DS_DATA_WITH_KEYS).value == '0' ? false : true
|
|
||||||
|
|
||||||
dnssec_data[:ds_data].each do |ds_data|
|
dnssec_data[:ds_data].each do |ds_data|
|
||||||
if key_data?(ds_data) && !ds_data_with_keys_allowed
|
if key_data?(ds_data) && !Setting.ds_data_with_key_allowed
|
||||||
errors.add(:base, :ds_data_with_key_not_allowed)
|
errors.add(:base, :ds_data_with_key_not_allowed)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def key_data_allowed?(dnssec_data, sg)
|
def key_data_allowed?(dnssec_data)
|
||||||
key_data_allowed = sg.setting(Setting::ALLOW_KEY_DATA).value == '0' ? false : true
|
return if (dnssec_data[:key_data].any? && Setting.key_data_allowed) || dnssec_data[:key_data].empty?
|
||||||
|
|
||||||
return if (dnssec_data[:key_data].any? && key_data_allowed) || dnssec_data[:key_data].empty?
|
|
||||||
errors.add(:base, :key_data_not_allowed)
|
errors.add(:base, :key_data_not_allowed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -244,9 +235,7 @@ class Epp::EppDomain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def detach_dnskeys(dnssec_data)
|
def detach_dnskeys(dnssec_data)
|
||||||
sg = SettingGroup.dnskeys
|
return false unless validate_dnssec_data(dnssec_data)
|
||||||
|
|
||||||
return false unless validate_dnssec_data(dnssec_data, sg)
|
|
||||||
|
|
||||||
to_delete = []
|
to_delete = []
|
||||||
dnssec_data[:ds_data].each do |x|
|
dnssec_data[:ds_data].each do |x|
|
||||||
|
@ -305,9 +294,7 @@ class Epp::EppDomain < Domain
|
||||||
|
|
||||||
return true if pt
|
return true if pt
|
||||||
|
|
||||||
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
if Setting.transfer_wait_time > 0
|
||||||
|
|
||||||
if wait_time > 0
|
|
||||||
domain_transfers.create(
|
domain_transfers.create(
|
||||||
status: DomainTransfer::PENDING,
|
status: DomainTransfer::PENDING,
|
||||||
transfer_requested_at: Time.zone.now,
|
transfer_requested_at: Time.zone.now,
|
||||||
|
|
|
@ -1,14 +1,2 @@
|
||||||
class Setting < ActiveRecord::Base
|
class Setting < RailsSettings::CachedSettings
|
||||||
belongs_to :setting_group
|
|
||||||
has_many :domain_statuses
|
|
||||||
has_many :domains, through: :domain_statuses
|
|
||||||
validates :code, uniqueness: { scope: :setting_group_id }
|
|
||||||
|
|
||||||
# dnskeys
|
|
||||||
DS_ALGORITHM = 'ds_algorithm'
|
|
||||||
ALLOW_DS_DATA = 'allow_ds_data'
|
|
||||||
ALLOW_DS_DATA_WITH_KEYS = 'allow_ds_data_with_keys'
|
|
||||||
ALLOW_KEY_DATA = 'allow_key_data'
|
|
||||||
DNSKEYS_MAX_COUNT = 'dnskeys_max_count'
|
|
||||||
DNSKEYS_MIN_COUNT = 'dnskeys_min_count'
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
class SettingGroup < ActiveRecord::Base
|
|
||||||
has_many :settings
|
|
||||||
|
|
||||||
accepts_nested_attributes_for :settings
|
|
||||||
|
|
||||||
validates :code, uniqueness: true
|
|
||||||
|
|
||||||
def setting(key)
|
|
||||||
settings.find_by(code: key.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
class << self
|
|
||||||
def domain_validation
|
|
||||||
find_by(code: 'domain_validation')
|
|
||||||
end
|
|
||||||
|
|
||||||
def domain_general
|
|
||||||
find_by(code: 'domain_general')
|
|
||||||
end
|
|
||||||
|
|
||||||
def dnskeys
|
|
||||||
find_by(code: 'dnskeys')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
%h2= t('shared.setting_groups')
|
|
||||||
%hr
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-9'}
|
|
||||||
= sort_link(@q, 'code', t('shared.setting_group'))
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= t('shared.action')
|
|
||||||
%tbody
|
|
||||||
- @setting_groups.each do |x|
|
|
||||||
%tr
|
|
||||||
%td= t("setting_groups.codes.#{x.code}")
|
|
||||||
%td= link_to(t('shared.edit_settings'), admin_setting_group_path(x), class: 'btn btn-primary btn-xs')
|
|
|
@ -1,22 +0,0 @@
|
||||||
%h2= t("setting_groups.codes.#{@setting_group.code}")
|
|
||||||
%hr
|
|
||||||
= form_for([:admin, @setting_group]) do |f|
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-9'}
|
|
||||||
= t('shared.setting')
|
|
||||||
%th{class: 'col-xs-2'}
|
|
||||||
= t('shared.value')
|
|
||||||
%tbody
|
|
||||||
- @setting_group.settings.order(:code).each do |setting|
|
|
||||||
= f.fields_for :settings, setting do |sf|
|
|
||||||
%tr
|
|
||||||
%td= sf.label :value, t("settings.codes.#{sf.object.code}")
|
|
||||||
%td= sf.text_field(:value, autocomplete: 'off')
|
|
||||||
.row
|
|
||||||
.col-md-12.text-right
|
|
||||||
%button.btn.btn-primary=t('shared.save')
|
|
26
app/views/admin/settings/index.haml
Normal file
26
app/views/admin/settings/index.haml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
%h2= t('shared.settings')
|
||||||
|
%hr
|
||||||
|
= form_tag [:admin, :settings] do
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{class: 'col-xs-9'}
|
||||||
|
= t('shared.setting')
|
||||||
|
%th{class: 'col-xs-2'}
|
||||||
|
= t('shared.value')
|
||||||
|
%tbody
|
||||||
|
- @settings.each do |x|
|
||||||
|
%tr
|
||||||
|
%td= t("shared.#{x.var}")
|
||||||
|
- if [TrueClass, FalseClass].include?(x.value.class)
|
||||||
|
%td
|
||||||
|
= hidden_field_tag("[settings][#{x.var}]", '')
|
||||||
|
= check_box_tag("[settings][#{x.var}]", true, x.value)
|
||||||
|
- else
|
||||||
|
%td= text_field_tag("[settings][#{x.var}]", x.value)
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
%button.btn.btn-primary=t('shared.save')
|
|
@ -36,7 +36,7 @@
|
||||||
%ul.dropdown-menu{role: "menu"}
|
%ul.dropdown-menu{role: "menu"}
|
||||||
%li.dropdown-header= t('shared.system')
|
%li.dropdown-header= t('shared.system')
|
||||||
%li
|
%li
|
||||||
= link_to t('shared.setting_groups'), admin_setting_groups_path
|
= link_to t('shared.settings'), admin_settings_path
|
||||||
%li.divider
|
%li.divider
|
||||||
%li.dropdown-header= t('shared.users')
|
%li.dropdown-header= t('shared.users')
|
||||||
%li
|
%li
|
||||||
|
|
|
@ -139,11 +139,6 @@ en:
|
||||||
blank: 'Contact was not found'
|
blank: 'Contact was not found'
|
||||||
taken: 'Contact already exists on this domain!'
|
taken: 'Contact already exists on this domain!'
|
||||||
|
|
||||||
setting:
|
|
||||||
attributes:
|
|
||||||
code:
|
|
||||||
taken: 'Code already exists'
|
|
||||||
|
|
||||||
domain_status:
|
domain_status:
|
||||||
attributes:
|
attributes:
|
||||||
setting_id:
|
setting_id:
|
||||||
|
@ -249,27 +244,10 @@ en:
|
||||||
domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar'
|
domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar'
|
||||||
attribute_op_is_invalid: 'Attribute op is invalid'
|
attribute_op_is_invalid: 'Attribute op is invalid'
|
||||||
|
|
||||||
setting_groups:
|
|
||||||
codes:
|
|
||||||
domain_validation: 'Domain validation'
|
|
||||||
domain_general: 'Domain general'
|
|
||||||
dnskeys: 'DNS keys'
|
|
||||||
|
|
||||||
settings:
|
|
||||||
codes:
|
|
||||||
ns_min_count: 'Nameserver minimum count'
|
|
||||||
ns_max_count: 'Nameserver maximum count'
|
|
||||||
dnskeys_min_count: 'DNS keys minimum count'
|
|
||||||
dnskeys_max_count: 'DNS keys maximum count'
|
|
||||||
allow_ds_data: 'Allow DS data'
|
|
||||||
allow_ds_data_with_keys: 'Allow DS data with keys'
|
|
||||||
allow_key_data: 'Allow key data'
|
|
||||||
ds_algorithm: 'DS algorithm'
|
|
||||||
|
|
||||||
shared:
|
shared:
|
||||||
code: 'Code'
|
code: 'Code'
|
||||||
value: 'Value'
|
value: 'Value'
|
||||||
setting_groups: 'Setting groups'
|
|
||||||
action: 'Action'
|
action: 'Action'
|
||||||
edit: 'Edit'
|
edit: 'Edit'
|
||||||
save: 'Save'
|
save: 'Save'
|
||||||
|
@ -282,9 +260,6 @@ en:
|
||||||
valid_to: 'Valid to'
|
valid_to: 'Valid to'
|
||||||
name: 'Name'
|
name: 'Name'
|
||||||
transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar'
|
transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar'
|
||||||
edit_settings: 'Edit settings'
|
|
||||||
setting_group: 'Setting group'
|
|
||||||
setting: 'Setting'
|
|
||||||
registrar: 'Registrar'
|
registrar: 'Registrar'
|
||||||
owner: 'Owner'
|
owner: 'Owner'
|
||||||
domain_details: 'Domain details'
|
domain_details: 'Domain details'
|
||||||
|
@ -357,8 +332,6 @@ en:
|
||||||
contact_updated: 'Contact updated'
|
contact_updated: 'Contact updated'
|
||||||
search: 'Search'
|
search: 'Search'
|
||||||
reg_no: 'Reg. no'
|
reg_no: 'Reg. no'
|
||||||
setting_updated: 'Setting updated!'
|
|
||||||
failed_to_update_setting: 'Failed to update setting'
|
|
||||||
status: 'Status'
|
status: 'Status'
|
||||||
eedirekt: 'EEDirekt'
|
eedirekt: 'EEDirekt'
|
||||||
contact: 'Contact'
|
contact: 'Contact'
|
||||||
|
@ -428,6 +401,7 @@ en:
|
||||||
record_created: 'Record created'
|
record_created: 'Record created'
|
||||||
failed_to_create_record: 'Failed to create record'
|
failed_to_create_record: 'Failed to create record'
|
||||||
record_updated: 'Record updated'
|
record_updated: 'Record updated'
|
||||||
|
records_updated: 'Records updated'
|
||||||
failed_to_update_record: 'Failed to update record'
|
failed_to_update_record: 'Failed to update record'
|
||||||
record_deleted: 'Record deleted'
|
record_deleted: 'Record deleted'
|
||||||
failed_to_delete_record: 'Failed to delete record'
|
failed_to_delete_record: 'Failed to delete record'
|
||||||
|
@ -435,5 +409,15 @@ en:
|
||||||
authentication_error: 'Authentication error'
|
authentication_error: 'Authentication error'
|
||||||
ds_data_and_key_data_must_not_exists_together: 'dsData and keyData objects must not exists together'
|
ds_data_and_key_data_must_not_exists_together: 'dsData and keyData objects must not exists together'
|
||||||
|
|
||||||
|
ns_min_count: 'Nameserver minimum count'
|
||||||
|
ns_max_count: 'Nameserver maximum count'
|
||||||
|
dnskeys_min_count: 'DNS keys minimum count'
|
||||||
|
dnskeys_max_count: 'DNS keys maximum count'
|
||||||
|
ds_data_allowed: 'DS data allowed'
|
||||||
|
ds_data_with_key_allowed: 'Allow DS data with key'
|
||||||
|
key_data_allowed: 'Allow key data'
|
||||||
|
ds_algorithm: 'DS algorithm'
|
||||||
|
setting: 'Setting'
|
||||||
|
|
||||||
registrar: Registrar
|
registrar: Registrar
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ Rails.application.routes.draw do
|
||||||
## ADMIN ROUTES
|
## ADMIN ROUTES
|
||||||
namespace(:admin) do
|
namespace(:admin) do
|
||||||
resources :domains
|
resources :domains
|
||||||
resources :setting_groups
|
resources :settings
|
||||||
resources :registrars do
|
resources :registrars do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
class CreateSettings < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
create_table :settings do |t|
|
|
||||||
t.integer :setting_group_id
|
|
||||||
t.string :code
|
|
||||||
t.string :value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
18
db/migrate/20141015135255_create_settings.rb
Normal file
18
db/migrate/20141015135255_create_settings.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class CreateSettings < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
drop_table :settings
|
||||||
|
create_table :settings do |t|
|
||||||
|
t.string :var, :null => false
|
||||||
|
t.text :value, :null => true
|
||||||
|
t.integer :thing_id, :null => true
|
||||||
|
t.string :thing_type, :limit => 30, :null => true
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :settings, [ :thing_type, :thing_id, :var ], :unique => true
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :settings
|
||||||
|
end
|
||||||
|
end
|
17
db/migrate/20141015135742_correct_settings.rb
Normal file
17
db/migrate/20141015135742_correct_settings.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class CorrectSettings < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
drop_table :setting_groups
|
||||||
|
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
end
|
||||||
|
end
|
17
db/schema.rb
17
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20141014073435) do
|
ActiveRecord::Schema.define(version: 20141015135742) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -253,15 +253,16 @@ ActiveRecord::Schema.define(version: 20141014073435) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "setting_groups", force: true do |t|
|
create_table "settings", force: true do |t|
|
||||||
t.string "code"
|
t.string "var", null: false
|
||||||
|
t.text "value"
|
||||||
|
t.integer "thing_id"
|
||||||
|
t.string "thing_type", limit: 30
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "settings", force: true do |t|
|
add_index "settings", ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true, using: :btree
|
||||||
t.integer "setting_group_id"
|
|
||||||
t.string "code"
|
|
||||||
t.string "value"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "users", force: true do |t|
|
create_table "users", force: true do |t|
|
||||||
t.string "username"
|
t.string "username"
|
||||||
|
|
31
db/seeds.rb
31
db/seeds.rb
|
@ -66,27 +66,14 @@ User.where(
|
||||||
country: Country.where(name: 'Estonia').first
|
country: Country.where(name: 'Estonia').first
|
||||||
).first_or_create
|
).first_or_create
|
||||||
|
|
||||||
sg = SettingGroup.where(code: 'domain_validation').first_or_create
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
s_1 = Setting.where(code: 'ns_min_count').first_or_create
|
Setting.dnskeys_min_count = 0
|
||||||
s_1.value = 1
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
s_2 = Setting.where(code: 'ns_max_count').first_or_create
|
Setting.transfer_wait_time = 0
|
||||||
s_2.value = 13
|
|
||||||
|
|
||||||
s_3 = Setting.where(code: 'dnskeys_min_count').first_or_create
|
|
||||||
s_3.value = 0
|
|
||||||
|
|
||||||
s_4 = Setting.where(code: 'dnskeys_max_count').first_or_create
|
|
||||||
s_4.value = 9
|
|
||||||
|
|
||||||
sg.settings = [s_1, s_2, s_3, s_4]
|
|
||||||
sg.save
|
|
||||||
|
|
||||||
sg = SettingGroup.where(code: 'domain_general').first_or_create
|
|
||||||
|
|
||||||
s_1 = Setting.where(code: 'transfer_wait_time').first_or_create
|
|
||||||
s_1.value = 0
|
|
||||||
|
|
||||||
sg.settings = [s_1]
|
|
||||||
sg.save
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ describe 'EPP Contact', epp: true do
|
||||||
Fabricate(:epp_user)
|
Fabricate(:epp_user)
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||||
Fabricate(:domain_validation_setting_group)
|
create_settings
|
||||||
Fabricate(:dnskeys_setting_group)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'create command' do
|
context 'create command' do
|
||||||
|
|
|
@ -6,14 +6,12 @@ describe 'EPP Domain', epp: true do
|
||||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||||
let(:zone) { Fabricate(:registrar) }
|
let(:zone) { Fabricate(:registrar) }
|
||||||
|
|
||||||
|
before(:each) { create_settings }
|
||||||
|
|
||||||
context 'with valid user' do
|
context 'with valid user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||||
|
|
||||||
Fabricate(:domain_validation_setting_group)
|
|
||||||
Fabricate(:domain_statuses_setting_group)
|
|
||||||
Fabricate(:dnskeys_setting_group)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error if contact does not exists' do
|
it 'returns error if contact does not exists' do
|
||||||
|
@ -36,7 +34,6 @@ describe 'EPP Domain', epp: true do
|
||||||
let(:domain) { Domain.first }
|
let(:domain) { Domain.first }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:domain_general_setting_group)
|
|
||||||
Fabricate(:domain, name: 'example.ee', registrar: zone)
|
Fabricate(:domain, name: 'example.ee', registrar: zone)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,8 +62,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
expect(domain.registrar).to eq(elkdata)
|
expect(domain.registrar).to eq(elkdata)
|
||||||
|
|
||||||
s = Setting.find_by(code: 'transfer_wait_time')
|
Setting.transfer_wait_time = 1
|
||||||
s.update(value: 1)
|
|
||||||
|
|
||||||
domain.reload
|
domain.reload
|
||||||
pw = domain.auth_info
|
pw = domain.auth_info
|
||||||
|
@ -209,8 +205,8 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
expect(key.ds_alg).to eq(3)
|
expect(key.ds_alg).to eq(3)
|
||||||
expect(key.ds_key_tag).to_not be_blank
|
expect(key.ds_key_tag).to_not be_blank
|
||||||
sg = SettingGroup.dnskeys
|
|
||||||
expect(key.ds_digest_type).to eq(sg.setting(Setting::DS_ALGORITHM).value.to_i)
|
expect(key.ds_digest_type).to eq(Setting.ds_algorithm)
|
||||||
expect(key.flags).to eq(257)
|
expect(key.flags).to eq(257)
|
||||||
expect(key.protocol).to eq(3)
|
expect(key.protocol).to eq(3)
|
||||||
expect(key.alg).to eq(5)
|
expect(key.alg).to eq(5)
|
||||||
|
@ -297,7 +293,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('2004')
|
expect(response[:result_code]).to eq('2004')
|
||||||
expect(response[:msg]).to eq('Nameservers count must be between 1-13')
|
expect(response[:msg]).to eq('Nameservers count must be between 2-11')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error when invalid nameservers are present' do
|
it 'returns error when invalid nameservers are present' do
|
||||||
|
@ -391,7 +387,7 @@ describe 'EPP Domain', epp: true do
|
||||||
key_1 = d.dnskeys[0]
|
key_1 = d.dnskeys[0]
|
||||||
expect(key_1.ds_key_tag).to_not be_blank
|
expect(key_1.ds_key_tag).to_not be_blank
|
||||||
expect(key_1.ds_alg).to eq(3)
|
expect(key_1.ds_alg).to eq(3)
|
||||||
expect(key_1.ds_digest_type).to eq(SettingGroup.dnskeys.setting(Setting::DS_ALGORITHM).value.to_i)
|
expect(key_1.ds_digest_type).to eq(Setting.ds_algorithm)
|
||||||
|
|
||||||
expect(d.dnskeys.pluck(:flags)).to match_array([257, 0, 256])
|
expect(d.dnskeys.pluck(:flags)).to match_array([257, 0, 256])
|
||||||
expect(d.dnskeys.pluck(:protocol)).to match_array([3, 3, 3])
|
expect(d.dnskeys.pluck(:protocol)).to match_array([3, 3, 3])
|
||||||
|
@ -484,9 +480,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validated dnskeys count' do
|
it 'validated dnskeys count' do
|
||||||
s = Setting.find_by(code: 'dnskeys_max_count')
|
Setting.dnskeys_max_count = 1
|
||||||
s.value = 1
|
|
||||||
s.save
|
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = domain_create_xml({}, {
|
||||||
_other: [
|
_other: [
|
||||||
|
@ -572,10 +566,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prohibits dsData with key' do
|
it 'prohibits dsData with key' do
|
||||||
sg = SettingGroup.dnskeys
|
Setting.ds_data_with_key_allowed = false
|
||||||
s = sg.setting(Setting::ALLOW_DS_DATA_WITH_KEYS)
|
|
||||||
s.value = 0
|
|
||||||
s.save
|
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = domain_create_xml({}, {
|
||||||
_other: [
|
_other: [
|
||||||
|
@ -600,10 +591,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prohibits dsData' do
|
it 'prohibits dsData' do
|
||||||
sg = SettingGroup.dnskeys
|
Setting.ds_data_allowed = false
|
||||||
s = sg.setting(Setting::ALLOW_DS_DATA)
|
|
||||||
s.value = 0
|
|
||||||
s.save
|
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = domain_create_xml({}, {
|
||||||
_other: [
|
_other: [
|
||||||
|
@ -628,10 +616,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prohibits keyData' do
|
it 'prohibits keyData' do
|
||||||
sg = SettingGroup.dnskeys
|
Setting.key_data_allowed = false
|
||||||
s = sg.setting(Setting::ALLOW_KEY_DATA)
|
|
||||||
s.value = 0
|
|
||||||
s.save
|
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = domain_create_xml({}, {
|
||||||
_other: [
|
_other: [
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
Fabricator(:setting) do
|
|
||||||
code 'ns_min_count'
|
|
||||||
end
|
|
|
@ -1,52 +0,0 @@
|
||||||
Fabricator(:setting_group) do
|
|
||||||
code 'domain_validation'
|
|
||||||
settings do
|
|
||||||
[
|
|
||||||
Fabricate(:setting, code: 'ns_min_count', value: 1),
|
|
||||||
Fabricate(:setting, code: 'ns_max_count', value: 13)
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Fabricator(:domain_validation_setting_group, from: :setting_group) do
|
|
||||||
code 'domain_validation'
|
|
||||||
settings do
|
|
||||||
[
|
|
||||||
Fabricate(:setting, code: 'ns_min_count', value: 1),
|
|
||||||
Fabricate(:setting, code: 'ns_max_count', value: 13),
|
|
||||||
Fabricate(:setting, code: 'dnskeys_min_count', value: 0),
|
|
||||||
Fabricate(:setting, code: 'dnskeys_max_count', value: 9)
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Fabricator(:domain_statuses_setting_group, from: :setting_group) do
|
|
||||||
code 'domain_statuses'
|
|
||||||
settings do
|
|
||||||
[
|
|
||||||
Fabricate(:setting, code: 'client_hold', value: 'clientHold'),
|
|
||||||
Fabricate(:setting, code: 'client_update_prohibited', value: 'clientUpdateProhibited')
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Fabricator(:domain_general_setting_group, from: :setting_group) do
|
|
||||||
code 'domain_general'
|
|
||||||
settings do
|
|
||||||
[
|
|
||||||
Fabricate(:setting, code: 'transfer_wait_time', value: '0')
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Fabricator(:dnskeys_setting_group, from: :setting_group) do
|
|
||||||
code 'dnskeys'
|
|
||||||
settings do
|
|
||||||
[
|
|
||||||
Fabricate(:setting, code: Setting::DS_ALGORITHM, value: 2),
|
|
||||||
Fabricate(:setting, code: Setting::ALLOW_DS_DATA, value: 1),
|
|
||||||
Fabricate(:setting, code: Setting::ALLOW_DS_DATA_WITH_KEYS, value: 1),
|
|
||||||
Fabricate(:setting, code: Setting::ALLOW_KEY_DATA, value: 1)
|
|
||||||
]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,38 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
feature 'Contact management', type: :feature do
|
|
||||||
# background do
|
|
||||||
# end
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
Fabricate(:user, country: Fabricate(:country, iso: 'EE'), admin: false, username: 'zone')
|
|
||||||
visit login_path
|
|
||||||
click_on 'ID card (zone)'
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User sees contacts', js: true do
|
|
||||||
Fabricate(:contact, registrar: Registrar.first)
|
|
||||||
Fabricate(:contact, registrar: Registrar.first)
|
|
||||||
visit client_contacts_path
|
|
||||||
expect(page).to have_text(Contact.first.name)
|
|
||||||
expect(page).to have_text(Contact.second.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User creates contact', js: true do
|
|
||||||
visit client_contacts_path
|
|
||||||
click_on 'Create new contact'
|
|
||||||
fill_in('Name', with: 'John Doe The Third')
|
|
||||||
fill_in('Email', with: 'john@doe.eu')
|
|
||||||
fill_in('Phone', with: '+123.3213123')
|
|
||||||
fill_in('Ident', with: '312313')
|
|
||||||
click_on 'Save'
|
|
||||||
|
|
||||||
expect(current_path).to eq client_contact_path(Contact.first)
|
|
||||||
|
|
||||||
expect(page).to have_text('Contact added!')
|
|
||||||
expect(page).to have_text('Contact details')
|
|
||||||
expect(page).to have_text('John Doe The Third')
|
|
||||||
|
|
||||||
expect(Contact.first.registrar).to eq Registrar.first
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,124 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
feature 'Domain management', type: :feature do
|
|
||||||
background do
|
|
||||||
Fabricate(:registrar)
|
|
||||||
Fabricate(:domain_validation_setting_group)
|
|
||||||
Fabricate.times(4, :domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User sees domains', js: true do
|
|
||||||
visit root_path
|
|
||||||
click_on 'Domains'
|
|
||||||
|
|
||||||
Domain.all.each do |x|
|
|
||||||
expect(page).to have_link(x)
|
|
||||||
expect(page).to have_link(x.registrar)
|
|
||||||
expect(page).to have_link(x.owner_contact)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User adds a domain', js: true do
|
|
||||||
visit admin_domains_path
|
|
||||||
click_on 'Add'
|
|
||||||
fill_in('Domain name', with: 'example.ee')
|
|
||||||
fill_in('Period', with: 1)
|
|
||||||
fill_in('Registrar', with: 'zone', fill_options: { blur: false })
|
|
||||||
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
|
|
||||||
# expect(page).to have_text('Zone Media OÜ (10577829)')
|
|
||||||
# click_on('Zone Media OÜ (10577829)')
|
|
||||||
# expect(find_field('Registrar').value).to eq('Zone Media OÜ (10577829)')
|
|
||||||
|
|
||||||
# temporary solution:
|
|
||||||
|
|
||||||
page.execute_script("$('#domain_registrar_id').val('1')")
|
|
||||||
|
|
||||||
c = Contact.first
|
|
||||||
|
|
||||||
fill_in('Registrant', with: c.code, fill_options: { blur: false })
|
|
||||||
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
|
|
||||||
# expect(page).to have_text(c.code)
|
|
||||||
# click_on(c.code)
|
|
||||||
# expect(find_field('Registrar').value).to eq(c.code)
|
|
||||||
|
|
||||||
# temporary solution:
|
|
||||||
page.execute_script("$('#domain_owner_contact_id').val('1')")
|
|
||||||
|
|
||||||
click_on('Save')
|
|
||||||
|
|
||||||
expect(page).to have_text('Domain details')
|
|
||||||
expect(page).to have_text('example.ee')
|
|
||||||
expect(page).to have_link('Zone Media OÜ')
|
|
||||||
expect(page).to have_link(c.name, count: 3)
|
|
||||||
expect(page).to have_text(c.code)
|
|
||||||
expect(page).to have_text(c.ident)
|
|
||||||
expect(page).to have_text(c.email)
|
|
||||||
expect(page).to have_text(c.phone)
|
|
||||||
expect(page).to have_text('Nameservers count must be between 1-13')
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User adds nameserver to domain' do
|
|
||||||
d = Domain.first
|
|
||||||
visit admin_domain_path(d)
|
|
||||||
|
|
||||||
within('#nameservers') { click_on 'Add' }
|
|
||||||
|
|
||||||
fill_in('Hostname', with: 'ns1.example.ee')
|
|
||||||
fill_in('Ipv4', with: '192.168.1.1')
|
|
||||||
fill_in('Ipv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
|
|
||||||
|
|
||||||
click_on 'Save'
|
|
||||||
|
|
||||||
expect(page).to have_text('Nameserver added!')
|
|
||||||
|
|
||||||
within('#nameservers') do
|
|
||||||
expect(page).to have_link('ns1.example.ee')
|
|
||||||
expect(page).to have_text('192.168.1.1')
|
|
||||||
expect(page).to have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User adds status to domain' do
|
|
||||||
d = Domain.first
|
|
||||||
visit admin_domain_path(d)
|
|
||||||
|
|
||||||
within('#domain_statuses') { click_on 'Add' }
|
|
||||||
|
|
||||||
fill_in('Description', with: 'All is well.')
|
|
||||||
|
|
||||||
click_on 'Save'
|
|
||||||
|
|
||||||
expect(page).to have_text('Status added!')
|
|
||||||
|
|
||||||
within('#domain_statuses') do
|
|
||||||
expect(page).to have_text('ok')
|
|
||||||
expect(page).to have_text('All is well.')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'User adds technical contact', js: true do
|
|
||||||
d = Domain.first
|
|
||||||
visit admin_domain_path(d)
|
|
||||||
|
|
||||||
within('#tech_contacts') { click_on 'Add' }
|
|
||||||
|
|
||||||
c = Contact.last
|
|
||||||
fill_in('Contact', with: c.code, fill_options: { blur: false })
|
|
||||||
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
|
|
||||||
# expect(page).to have_text(c.code)
|
|
||||||
# click_on(c.code)
|
|
||||||
# expect(find_field('Tech contact').value).to eq(c.code)
|
|
||||||
|
|
||||||
# temporary solution:
|
|
||||||
page.execute_script("$('#domain_contact_contact_id').val('#{c.id}')")
|
|
||||||
|
|
||||||
click_on 'Save'
|
|
||||||
|
|
||||||
expect(page).to have_text('Contact added!')
|
|
||||||
|
|
||||||
within('#tech_contacts') do
|
|
||||||
expect(page).to have_link(c.name)
|
|
||||||
expect(page).to have_text(c.email)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,126 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
feature 'Domain transfer', type: :feature do
|
|
||||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
|
||||||
let(:zone) { Fabricate(:registrar) }
|
|
||||||
let(:zone_user) { Fabricate(:user, registrar: zone, username: 'zone', admin: false, identity_code: '37810013087') }
|
|
||||||
let(:elkdata_user) do
|
|
||||||
Fabricate(:user, registrar: elkdata, username: 'elkdata', admin: false, identity_code: '37810013261')
|
|
||||||
end
|
|
||||||
|
|
||||||
background do
|
|
||||||
Fabricate(:domain_validation_setting_group)
|
|
||||||
Fabricate(:domain_general_setting_group)
|
|
||||||
Fabricate(:dnskeys_setting_group)
|
|
||||||
Fabricate(:domain, registrar: zone)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Registrar requests transfer on own domain', js: true do
|
|
||||||
sign_in zone_user
|
|
||||||
click_on 'Domains'
|
|
||||||
click_on 'Domain transfers list'
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
fill_in 'Domain name', with: 'false'
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
expect(page).to have_text('Domain was not found!')
|
|
||||||
|
|
||||||
d = Domain.first
|
|
||||||
fill_in 'Domain name', with: d.name
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
expect(page).to have_text('Password invalid!')
|
|
||||||
|
|
||||||
fill_in 'Domain password', with: d.auth_info
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
expect(page).to have_text('Domain already belongs to the querying registrar')
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Other registrar requests transfer with 0 wait time' do
|
|
||||||
sign_in elkdata_user
|
|
||||||
d = Domain.first
|
|
||||||
visit client_domains_path
|
|
||||||
expect(page).to_not have_link(d.name)
|
|
||||||
|
|
||||||
visit new_client_domain_transfer_path
|
|
||||||
fill_in 'Domain name', with: d.name
|
|
||||||
fill_in 'Domain password', with: d.auth_info
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
expect(page).to have_text('Domain transfer approved!')
|
|
||||||
expect(page).to have_text('serverApproved')
|
|
||||||
|
|
||||||
visit client_domains_path
|
|
||||||
expect(page).to have_link(d.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Other registrar requests transfer with 1 wait time' do
|
|
||||||
s = Setting.find_by(code: 'transfer_wait_time')
|
|
||||||
s.value = 1
|
|
||||||
s.save
|
|
||||||
|
|
||||||
sign_in elkdata_user
|
|
||||||
d = Domain.first
|
|
||||||
visit client_domains_path
|
|
||||||
expect(page).to_not have_link(d.name)
|
|
||||||
|
|
||||||
visit new_client_domain_transfer_path
|
|
||||||
fill_in 'Domain name', with: d.name
|
|
||||||
fill_in 'Domain password', with: d.auth_info
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
expect(page).to have_text('Domain transfer requested!')
|
|
||||||
expect(page).to have_text('pending')
|
|
||||||
|
|
||||||
visit new_client_domain_transfer_path
|
|
||||||
fill_in 'Domain name', with: d.name
|
|
||||||
fill_in 'Domain password', with: d.auth_info
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
expect(page).to have_text('Domain transfer requested!')
|
|
||||||
expect(page).to have_text('pending')
|
|
||||||
|
|
||||||
visit client_domains_path
|
|
||||||
expect(page).to_not have_link(d.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Domain owner approves request' do
|
|
||||||
s = Setting.find_by(code: 'transfer_wait_time')
|
|
||||||
s.value = 1
|
|
||||||
s.save
|
|
||||||
|
|
||||||
d = Domain.first
|
|
||||||
d.domain_transfers.create(
|
|
||||||
status: DomainTransfer::PENDING,
|
|
||||||
transfer_requested_at: Time.zone.now,
|
|
||||||
transfer_to: elkdata,
|
|
||||||
transfer_from: zone
|
|
||||||
)
|
|
||||||
|
|
||||||
sign_in elkdata_user
|
|
||||||
visit new_client_domain_transfer_path
|
|
||||||
fill_in 'Domain name', with: d.name
|
|
||||||
fill_in 'Domain password', with: d.auth_info
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
expect(page).to have_text('Domain transfer requested!')
|
|
||||||
expect(page).to_not have_button('Approve')
|
|
||||||
|
|
||||||
sign_in zone_user
|
|
||||||
|
|
||||||
visit new_client_domain_transfer_path
|
|
||||||
fill_in 'Domain name', with: d.name
|
|
||||||
fill_in 'Domain password', with: d.auth_info
|
|
||||||
click_on 'Request domain transfer'
|
|
||||||
|
|
||||||
expect(page).to have_link('Approve')
|
|
||||||
|
|
||||||
click_on 'Approve'
|
|
||||||
expect(page).to have_text('Domain transfer approved!')
|
|
||||||
expect(page).to have_text('clientApproved')
|
|
||||||
|
|
||||||
sign_in elkdata_user
|
|
||||||
visit client_domains_path
|
|
||||||
expect(page).to have_link(d.name)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -5,9 +5,9 @@ feature 'Sessions', type: :feature do
|
||||||
let(:zone) { Fabricate(:registrar) }
|
let(:zone) { Fabricate(:registrar) }
|
||||||
|
|
||||||
background do
|
background do
|
||||||
Fabricate(:user, registrar: zone, username: 'elkdata', identity_code: '37810013261')
|
create_settings
|
||||||
|
Fabricate(:user, registrar: nil, identity_code: '37810013261')
|
||||||
Fabricate(:user, registrar: zone, username: 'zone', admin: false, identity_code: '37810013087')
|
Fabricate(:user, registrar: zone, username: 'zone', admin: false, identity_code: '37810013087')
|
||||||
Fabricate(:domain_validation_setting_group)
|
|
||||||
Fabricate.times(2, :domain, registrar: zone)
|
Fabricate.times(2, :domain, registrar: zone)
|
||||||
Fabricate.times(2, :domain, registrar: elkdata)
|
Fabricate.times(2, :domain, registrar: elkdata)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,30 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Setting management', type: :feature do
|
feature 'Setting management', type: :feature do
|
||||||
background { Fabricate(:domain_validation_setting_group) }
|
let(:zone) { Fabricate(:registrar) }
|
||||||
|
let(:zone_user) { Fabricate(:user, registrar: zone, username: 'zone', admin: true, identity_code: '37810013087') }
|
||||||
|
|
||||||
scenario 'User changes a setting', js: true do
|
background { create_settings }
|
||||||
visit root_path
|
|
||||||
|
|
||||||
# This ensures javascript works correctly
|
scenario 'User changes a setting' do
|
||||||
expect(page).to have_no_link 'Setting groups'
|
sign_in zone_user
|
||||||
click_on 'Settings'
|
visit admin_settings_path
|
||||||
expect(page).to have_link 'Setting groups'
|
|
||||||
|
|
||||||
click_on 'Setting groups'
|
val_min = find_field('_settings_ns_min_count').value
|
||||||
expect(page).to have_text('Domain validation')
|
val_max = find_field('_settings_ns_max_count').value
|
||||||
click_on 'Edit settings'
|
|
||||||
expect(page).to have_text('Nameserver minimum count')
|
|
||||||
expect(page).to have_text('Nameserver maximum count')
|
|
||||||
|
|
||||||
val_min = find_field('Nameserver minimum count').value
|
expect(val_min).to eq('2')
|
||||||
val_max = find_field('Nameserver maximum count').value
|
expect(val_max).to eq('11')
|
||||||
|
|
||||||
expect(val_min).to eq('1')
|
fill_in '_settings_ns_min_count', with: 0
|
||||||
expect(val_max).to eq('13')
|
fill_in '_settings_ns_max_count', with: 10
|
||||||
|
|
||||||
fill_in('Nameserver minimum count', with: '3')
|
click_button 'Save'
|
||||||
fill_in('Nameserver maximum count', with: '10')
|
|
||||||
|
|
||||||
click_on 'Save'
|
val_min = find_field('_settings_ns_min_count').value
|
||||||
|
val_max = find_field('_settings_ns_max_count').value
|
||||||
|
|
||||||
val_min = find_field('Nameserver minimum count').value
|
expect(val_min).to eq('0')
|
||||||
val_max = find_field('Nameserver maximum count').value
|
|
||||||
|
|
||||||
expect(val_min).to eq('3')
|
|
||||||
expect(val_max).to eq('10')
|
expect(val_max).to eq('10')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,8 @@ describe Address, '.extract_params' do
|
||||||
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
|
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
|
||||||
expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
||||||
address_attributes: {
|
address_attributes: {
|
||||||
city: 'Village',
|
|
||||||
country_id: 1,
|
country_id: 1,
|
||||||
|
city: 'Village',
|
||||||
street: 'street1',
|
street: 'street1',
|
||||||
street2: 'street2'
|
street2: 'street2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,7 @@ describe Contact, '#relations_with_domain?' do
|
||||||
|
|
||||||
context 'with relation' do
|
context 'with relation' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:domain_validation_setting_group)
|
create_settings
|
||||||
Fabricate(:dnskeys_setting_group)
|
|
||||||
Fabricate(:domain)
|
Fabricate(:domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Dnskey do
|
describe Dnskey do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:domain_validation_setting_group)
|
create_settings
|
||||||
Fabricate(:dnskeys_setting_group)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should belong_to(:domain) }
|
it { should belong_to(:domain) }
|
||||||
|
|
|
@ -11,8 +11,7 @@ describe Domain do
|
||||||
|
|
||||||
context 'with sufficient settings' do
|
context 'with sufficient settings' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:domain_validation_setting_group)
|
create_settings
|
||||||
Fabricate(:dnskeys_setting_group)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates domain name' do
|
it 'validates domain name' do
|
||||||
|
@ -51,20 +50,13 @@ describe Domain do
|
||||||
period: ['is not a number'],
|
period: ['is not a number'],
|
||||||
owner_contact: ['Registrant is missing'],
|
owner_contact: ['Registrant is missing'],
|
||||||
admin_contacts: ['Admin contacts count must be between 1 - infinity'],
|
admin_contacts: ['Admin contacts count must be between 1 - infinity'],
|
||||||
nameservers: ['Nameservers count must be between 1-13'],
|
nameservers: ['Nameservers count must be between 2-11'],
|
||||||
registrar: ['Registrar is missing'],
|
registrar: ['Registrar is missing'],
|
||||||
period: ['Period is not a number']
|
period: ['Period is not a number']
|
||||||
})
|
})
|
||||||
|
|
||||||
sg = SettingGroup.domain_validation
|
Setting.ns_min_count = 2
|
||||||
min = sg.setting(:ns_min_count)
|
Setting.ns_max_count = 7
|
||||||
max = sg.setting(:ns_max_count)
|
|
||||||
|
|
||||||
min.value = 2
|
|
||||||
min.save
|
|
||||||
|
|
||||||
max.value = 7
|
|
||||||
max.save
|
|
||||||
|
|
||||||
expect(d.valid?).to be false
|
expect(d.valid?).to be false
|
||||||
expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe SettingGroup do
|
|
||||||
it { should have_many(:settings) }
|
|
||||||
end
|
|
|
@ -1,21 +1,12 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Setting do
|
describe Setting do
|
||||||
it { should belong_to(:setting_group) }
|
it 'returns value' do
|
||||||
|
create_settings
|
||||||
it 'validates code uniqueness' do
|
expect(Setting.ns_min_count).to eq(2)
|
||||||
sg = Fabricate(:setting_group)
|
Setting.ns_min_count = '2'
|
||||||
sg.settings.build(code: 'this_is_code')
|
expect(Setting.ns_min_count).to eq('2')
|
||||||
expect(sg.save).to be true
|
Setting.ns_min_count = true
|
||||||
|
expect(Setting.ns_min_count).to eq(true)
|
||||||
sg.settings.build(code: 'this_is_code')
|
|
||||||
expect(sg.save).to be false
|
|
||||||
err = sg.settings.last.errors[:code].first
|
|
||||||
expect(err).to eq('Code already exists')
|
|
||||||
|
|
||||||
sg_2 = Fabricate(:setting_group, code: 'domain_statuses')
|
|
||||||
|
|
||||||
sg_2.settings.build(code: 'this_is_code')
|
|
||||||
expect(sg_2.save).to be true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
20
spec/support/general.rb
Normal file
20
spec/support/general.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module General
|
||||||
|
def create_settings
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
c.include General
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue