From 55aa7743b0829418a69b197bbfef12b88a26f68c Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 14 Oct 2014 16:37:51 +0300 Subject: [PATCH] Fix some rubocops errors --- app/models/delegation_signer.rb | 9 ++-- app/models/epp/epp_domain.rb | 8 +-- app/models/nameserver.rb | 2 - app/models/setting.rb | 3 +- spec/epp/contact_spec.rb | 9 ++-- spec/epp/domain_spec.rb | 90 ++++++++++++++++----------------- spec/models/contact_spec.rb | 5 +- spec/models/domain_spec.rb | 5 +- 8 files changed, 66 insertions(+), 65 deletions(-) diff --git a/app/models/delegation_signer.rb b/app/models/delegation_signer.rb index b5a5c195e..694feb870 100644 --- a/app/models/delegation_signer.rb +++ b/app/models/delegation_signer.rb @@ -5,17 +5,16 @@ class DelegationSigner < ActiveRecord::Base 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 - } + { + min: sg.setting(Setting::DNSKEYS_MIN_COUNT).value, + max: sg.setting(Setting::DNSKEYS_MAX_COUNT).value + } ] ] } diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index 382309aff..919434eff 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -32,10 +32,10 @@ class Epp::EppDomain < Domain ], [:period, :out_of_range, { value: { obj: 'period', val: period } }], [:dnskeys, :out_of_range, - { - min: domain_validation_sg.setting(Setting::DNSKEYS_MIN_COUNT).value, - max: domain_validation_sg.setting(Setting::DNSKEYS_MAX_COUNT).value - } + { + min: domain_validation_sg.setting(Setting::DNSKEYS_MIN_COUNT).value, + max: domain_validation_sg.setting(Setting::DNSKEYS_MAX_COUNT).value + } ] ], '2200' => [ diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 56a0320fd..dbed6c8be 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -10,8 +10,6 @@ class Nameserver < ActiveRecord::Base validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true } # rubocop: enable Metrics/LineLength - - # archiving has_paper_trail class_name: 'NameserverVersion' diff --git a/app/models/setting.rb b/app/models/setting.rb index 8ace24044..012fd31c7 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -4,12 +4,11 @@ class Setting < ActiveRecord::Base has_many :domains, through: :domain_statuses validates :code, uniqueness: { scope: :setting_group_id } - #dnskeys + # 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 diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 10e922ab1..5acbccd4a 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -12,6 +12,7 @@ describe 'EPP Contact', epp: true do Fabricate(:epp_user, username: 'zone', registrar: zone) Fabricate(:epp_user, username: 'elkdata', registrar: elkdata) Fabricate(:domain_validation_setting_group) + Fabricate(:dnskeys_setting_group) end context 'create command' do @@ -145,7 +146,7 @@ describe 'EPP Contact', epp: true do it 'returns phone and email error' do Fabricate( - :contact, + :contact, registrar: zone, created_by_id: 1, email: 'not_updated@test.test', @@ -203,9 +204,9 @@ describe 'EPP Contact', epp: true do :domain, registrar: zone, owner_contact: Fabricate( - :contact, - code: 'dwa1234', - created_by_id: zone.id, + :contact, + code: 'dwa1234', + created_by_id: zone.id, registrar: zone) ) expect(Domain.first.owner_contact.address.present?).to be true diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 5a44e9d1f..26cbba8eb 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -400,33 +400,33 @@ describe 'EPP Domain', epp: true do it 'does not create a domain when dnskeys are invalid' do - xml = domain_create_xml({}, { - _other: [ - { keyData: { - flags: { value: '250' }, - protocol: { value: '4' }, - alg: { value: '9' }, - pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' } - } - }, - { - keyData: { - flags: { value: '1' }, - protocol: { value: '3' }, - alg: { value: '10' }, - pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } - } - }, - { - keyData: { - flags: { value: '256' }, - protocol: { value: '5' }, - alg: { value: '254' }, - pubKey: { value: '' } - } - } - ] - }) + xml = domain_create_xml({}, { + _other: [ + { keyData: { + flags: { value: '250' }, + protocol: { value: '4' }, + alg: { value: '9' }, + pubKey: { value: 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' } + } + }, + { + keyData: { + flags: { value: '1' }, + protocol: { value: '3' }, + alg: { value: '10' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + }, + { + keyData: { + flags: { value: '256' }, + protocol: { value: '5' }, + alg: { value: '254' }, + pubKey: { value: '' } + } + } + ] + }) response = epp_request(xml, :xml) @@ -452,24 +452,24 @@ describe 'EPP Domain', epp: true do end it 'does not create a domain with two identical dnskeys' do - xml = domain_create_xml({}, { - _other: [ - { keyData: { - flags: { value: '257' }, - protocol: { value: '3' }, - alg: { value: '3' }, - pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } - } - }, - { - keyData: { - flags: { value: '0' }, - protocol: { value: '3' }, - alg: { value: '5' }, - pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } - } - }] - }) + xml = domain_create_xml({}, { + _other: [ + { keyData: { + flags: { value: '257' }, + protocol: { value: '3' }, + alg: { value: '3' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + }, + { + keyData: { + flags: { value: '0' }, + protocol: { value: '3' }, + alg: { value: '5' }, + pubKey: { value: '700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f' } + } + }] + }) response = epp_request(xml, :xml) diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 771e112ff..44a6d23a0 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -51,6 +51,7 @@ describe Contact, '#relations_with_domain?' do context 'with relation' do before(:each) do Fabricate(:domain_validation_setting_group) + Fabricate(:dnskeys_setting_group) Fabricate(:domain) end @@ -74,8 +75,8 @@ end describe Contact, '#up_id' do before(:each) do - # Fabricate(:contact, code: 'asd12', - # created_by: Fabricate(:epp_user), + # Fabricate(:contact, code: 'asd12', + # created_by: Fabricate(:epp_user), # updated_by: Fabricate(:epp_user), registrar: zone) @epp_user = Fabricate(:epp_user) @contact = Fabricate.build(:contact, code: 'asd12', created_by: @epp_user, updated_by: @epp_user) diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 2d59eefc7..14a490b0a 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -10,7 +10,10 @@ describe Domain do it { should have_many(:dnskeys) } context 'with sufficient settings' do - before(:each) { Fabricate(:domain_validation_setting_group) } + before(:each) do + Fabricate(:domain_validation_setting_group) + Fabricate(:dnskeys_setting_group) + end it 'validates domain name' do d = Fabricate(:domain)