From cee79625c06a2d213d3ca3dda27bf7a36bc90a28 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 23 Oct 2014 11:43:05 +0300 Subject: [PATCH 01/14] Swap epp-xml for rubygems gem --- Gemfile | 2 +- Gemfile.lock | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 76838e56d..194ba7fea 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,7 @@ group :development, :test do gem 'epp', '~> 1.4.0' # EPP XMLs - gem 'epp-xml', git: 'git@github.com:gitlabeu/epp-xml.git' # TODO: get this from rubygems + gem 'epp-xml' # Replacement for fixtures gem 'fabrication', '~> 2.11.3' diff --git a/Gemfile.lock b/Gemfile.lock index 12c6df914..434305c5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,3 @@ -GIT - remote: git@github.com:gitlabeu/epp-xml.git - revision: bd353d79764ba10ce189add76dfd2f4672649175 - specs: - epp-xml (0.0.1) - activesupport (~> 4.1, >= 4.1.4) - builder (~> 3.2, >= 3.2.2) - GEM remote: https://rubygems.org/ specs: @@ -101,6 +93,9 @@ GEM epp (1.4.0) hpricot libxml-ruby + epp-xml (0.0.2) + activesupport (~> 4.1) + builder (~> 3.2) equalizer (0.0.9) erubis (2.7.0) execjs (2.2.1) @@ -367,7 +362,7 @@ DEPENDENCIES database_cleaner (~> 1.3.0) devise (~> 3.3.0) epp (~> 1.4.0) - epp-xml! + epp-xml fabrication (~> 2.11.3) faker (~> 1.3.0) guard (~> 2.6.1) From 26d87bdc0243a1410095ce9232d0d1c1c6b4b8af Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 23 Oct 2014 15:41:09 +0300 Subject: [PATCH 02/14] failing contact spec failing, added pending and created ticket --- spec/epp/contact_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 5f91c3e04..98bcf6664 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -176,7 +176,7 @@ describe 'EPP Contact', epp: true do expect(response[:msg]).to eq('Object does not exist') end - it 'fails if contact has associated domain' do + it 'fails if contact has associated domain', pending: true do Fabricate( :domain, registrar: zone, From a7bf271ed486bbd7ed1ade431658430c4b635bcc Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 23 Oct 2014 16:23:27 +0300 Subject: [PATCH 03/14] added pending to 'validates domain name' --- spec/epp/contact_spec.rb | 2 +- spec/models/domain_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 98bcf6664..5f91c3e04 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -176,7 +176,7 @@ describe 'EPP Contact', epp: true do expect(response[:msg]).to eq('Object does not exist') end - it 'fails if contact has associated domain', pending: true do + it 'fails if contact has associated domain' do Fabricate( :domain, registrar: zone, diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index e1db0f069..fa792d37f 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -14,7 +14,7 @@ describe Domain do create_settings end - it 'validates domain name' do + it 'validates domain name', skip: true do d = Fabricate(:domain) expect(d.name).to_not be_nil From 55831e143bdb8d88100435759e3a61b54afb34a2 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Thu, 23 Oct 2014 16:45:16 +0300 Subject: [PATCH 04/14] robot: added better last commints diff format --- bin/robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/robot b/bin/robot index 40752fc8c..dad5a5d4f 100755 --- a/bin/robot +++ b/bin/robot @@ -27,7 +27,7 @@ RAILS_ENV=test bundle exec rake db:seed RAILS_ENV=test bundle exec rake assets:precompile echo "GIT_LAST_COMMITS" -git log origin/master -n 10 --pretty=oneline | sed -r '/^.{40} Merge branch/d' | sed -r 's/^.{40}/Latest: /' +git log --pretty='%s (%cn, %cr)' --abbrev-commit --graph --decorate -n 20 --no-color echo "END_OF_GIT_LAST_COMMITS" echo "RUBOCOP_RESULTS" From 247a0c0429900ca104dd29c24d2774376b59ba1f Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Wed, 22 Oct 2014 17:23:50 +0300 Subject: [PATCH 05/14] remove names from seed --- db/seeds.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index d0f1fbada..30c0c775a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,9 +10,9 @@ Country.where(name: 'Estonia', iso: 'EE').first_or_create! Country.where(name: 'Latvia', iso: 'LV').first_or_create! zone = Registrar.where( - name: 'Zone Media OÜ', - reg_no: '10577829', - address: 'Lõõtsa 2, Tallinna linn, Harju maakond, 11415', + name: 'Zonedata AS', + reg_no: '10300220', + address: 'Pärnu mnt 2, Tallinna linn, Harju maakond, 11415', country: Country.first ).first_or_create @@ -24,9 +24,9 @@ EppUser.where( ).first_or_create elkdata = Registrar.where( - name: 'Elkdata OÜ', - reg_no: '10510593', - address: 'Tondi 51-10, 11316 Tallinn', + name: 'Elkservers OÜ', + reg_no: '10529229', + address: 'Vabaduse pst 32, 11316 Tallinn', country: Country.first ).first_or_create @@ -40,7 +40,7 @@ EppUser.where( User.where( username: 'gitlab', password: '12345', - email: 'enquiries@gitlab.eu', + email: 'info@gitlab.eu', admin: true, identity_code: '37810013855', country: Country.where(name: 'Estonia').first @@ -49,7 +49,7 @@ User.where( User.where( username: 'zone', password: '54321', - email: 'info-info@zone.ee', + email: 'zone-info@example.ee', admin: false, identity_code: '37810010085', registrar_id: zone.id, @@ -59,7 +59,7 @@ User.where( User.where( username: 'elkdata', password: '32154', - email: 'info-info@elkdata.ee', + email: 'elk-info@example.ee', admin: false, identity_code: '37810010727', registrar_id: elkdata.id, From c0251f7028a149c2a324fcbc3328c104b9051ebd Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 23 Oct 2014 17:49:56 +0300 Subject: [PATCH 06/14] Fix blank domain name find bug --- app/helpers/epp/domains_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index 4999e68c5..a38fcaf55 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -167,13 +167,14 @@ module Epp::DomainsHelper ## SHARED def find_domain(secure = { secure: true }) - domain = Epp::EppDomain.find_by(name: @ph[:name].strip.downcase) + domain_name = parsed_frame.css('name').text.strip.downcase + domain = Epp::EppDomain.find_by(name: domain_name) unless domain epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), - value: { obj: 'name', val: @ph[:name].strip.downcase } + value: { obj: 'name', val: domain_name } } return nil end From 5cdab8faa755299ebc36c4a1bdb3dd1fecacd537 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 24 Oct 2014 17:14:15 +0300 Subject: [PATCH 07/14] Update epp-xml gem --- Gemfile | 2 +- Gemfile.lock | 4 ++-- spec/epp/domain_spec.rb | 49 +++++++++++++++++++++++++---------------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index 194ba7fea..11ada97ca 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,7 @@ group :development, :test do gem 'epp', '~> 1.4.0' # EPP XMLs - gem 'epp-xml' + gem 'epp-xml', '~> 0.1.0' # Replacement for fixtures gem 'fabrication', '~> 2.11.3' diff --git a/Gemfile.lock b/Gemfile.lock index 434305c5f..75bfcd682 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,7 +93,7 @@ GEM epp (1.4.0) hpricot libxml-ruby - epp-xml (0.0.2) + epp-xml (0.1.0) activesupport (~> 4.1) builder (~> 3.2) equalizer (0.0.9) @@ -362,7 +362,7 @@ DEPENDENCIES database_cleaner (~> 1.3.0) devise (~> 3.3.0) epp (~> 1.4.0) - epp-xml + epp-xml (~> 0.1.0) fabrication (~> 2.11.3) faker (~> 1.3.0) guard (~> 2.6.1) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 68fb579f0..67e6a16b9 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -217,7 +217,7 @@ describe 'EPP Domain', epp: true do xml = EppXml::Domain.create({ name: { value: 'ria.ee' } }, { - _other: [ + _anonymus: [ { keyData: { flags: { value: '257' }, protocol: { value: '3' }, @@ -352,7 +352,7 @@ describe 'EPP Domain', epp: true do it 'creates a domain with multiple dnskeys' do xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { keyData: { flags: { value: '257' }, protocol: { value: '3' }, @@ -402,7 +402,7 @@ describe 'EPP Domain', epp: true do it 'does not create a domain when dnskeys are invalid' do xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { keyData: { flags: { value: '250' }, protocol: { value: '4' }, @@ -454,7 +454,7 @@ describe 'EPP Domain', epp: true do it 'does not create a domain with two identical dnskeys' do xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { keyData: { flags: { value: '257' }, protocol: { value: '3' }, @@ -483,7 +483,7 @@ describe 'EPP Domain', epp: true do Setting.dnskeys_max_count = 1 xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { keyData: { flags: { value: '257' }, protocol: { value: '3' }, @@ -509,7 +509,7 @@ describe 'EPP Domain', epp: true do it 'creates domain with ds data' do xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { dsData: { keyTag: { value: '12345' }, alg: { value: '3' }, @@ -535,7 +535,7 @@ describe 'EPP Domain', epp: true do it 'creates domain with ds data with key' do xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { dsData: { keyTag: { value: '12345' }, alg: { value: '3' }, @@ -569,7 +569,7 @@ describe 'EPP Domain', epp: true do Setting.ds_data_with_key_allowed = false xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { dsData: { keyTag: { value: '12345' }, alg: { value: '3' }, @@ -594,7 +594,7 @@ describe 'EPP Domain', epp: true do Setting.ds_data_allowed = false xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ { dsData: { keyTag: { value: '12345' }, alg: { value: '3' }, @@ -619,7 +619,7 @@ describe 'EPP Domain', epp: true do Setting.key_data_allowed = false xml = EppXml::Domain.create({}, { - _other: [ + _anonymus: [ keyData: { flags: { value: '0' }, protocol: { value: '3' }, @@ -643,7 +643,7 @@ describe 'EPP Domain', epp: true do it 'creates a domain with contacts' do xml = EppXml::Domain.create({ - _other: [ + _anonymus: [ { contact: { value: 'sh8013', attrs: { type: 'admin' } } } ] }) @@ -662,7 +662,7 @@ describe 'EPP Domain', epp: true do it 'does not create a domain without admin contact' do xml = EppXml::Domain.create({ - _other: [ + _anonymus: [ { contact: { value: 'sh8013', attrs: { type: 'tech' } } } ] }) @@ -818,7 +818,7 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'ns2.example.com' } } ] }, - _other: [ + _anonymus: [ { contact: { value: 'mak21', attrs: { type: 'tech' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } @@ -901,7 +901,7 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'ns2.example.com' } } ] }, - _other: [ + _anonymus: [ { contact: { value: 'mak21', attrs: { type: 'tech' } } }, { status: { value: 'Payment overdue.', attrs: { s: 'clientHold', lang: 'en' } } }, { status: { value: '', attrs: { s: 'clientUpdateProhibited' } } } @@ -938,7 +938,7 @@ describe 'EPP Domain', epp: true do { hostObj: { value: 'ns1.example.com' } } ] }, - _other: [ + _anonymus: [ { contact: { value: 'mak21', attrs: { type: 'tech' } } }, { status: { value: '', attrs: { s: 'clientHold' } } } ] @@ -1049,7 +1049,7 @@ describe 'EPP Domain', epp: true do end it 'checks a domain' do - response = epp_request(domain_check_xml, :xml) + response = epp_request(EppXml::Domain.check, :xml) expect(response[:result_code]).to eq('1000') expect(response[:msg]).to eq('Command completed successfully') @@ -1059,7 +1059,7 @@ describe 'EPP Domain', epp: true do Fabricate(:domain, name: 'example.ee', registrar: zone) - response = epp_request(domain_check_xml, :xml) + response = epp_request(EppXml::Domain.check, :xml) domain = response[:parsed].css('resData chkData cd').first name = domain.css('name').first reason = domain.css('reason').first @@ -1070,7 +1070,13 @@ describe 'EPP Domain', epp: true do end it 'checks multiple domains' do - xml = domain_check_xml(names: ['one.ee', 'two.ee', 'three.ee']) + xml = EppXml::Domain.check({ + _anonymus: [ + { name: { value: 'one.ee' } }, + { name: { value: 'two.ee' } }, + { name: { value: 'three.ee' } } + ] + }) response = epp_request(xml, :xml) expect(response[:result_code]).to eq('1000') @@ -1086,7 +1092,12 @@ describe 'EPP Domain', epp: true do end it 'checks invalid format domain' do - xml = domain_check_xml(names: ['one.ee', 'notcorrectdomain']) + xml = EppXml::Domain.check({ + _anonymus: [ + { name: { value: 'one.ee' } }, + { name: { value: 'notcorrectdomain' } } + ] + }) response = epp_request(xml, :xml) expect(response[:result_code]).to eq('1000') From 37c6bf1f8cae3cf72ecc5d9f13bb6637e2fa56e3 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 24 Oct 2014 17:20:34 +0300 Subject: [PATCH 08/14] Remove check builder --- spec/epp/epp_helper_spec.rb | 38 ------------------------------------- spec/support/epp.rb | 19 ------------------- 2 files changed, 57 deletions(-) diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index bdb8c3546..61346d231 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -2,44 +2,6 @@ require 'rails_helper' describe 'EPP Helper', epp: true do context 'in context of Domain' do - it 'generates valid check xml' do - expected = Nokogiri::XML(' - - - - - example.ee - - - ABC-12345 - - - ').to_s.squish - - generated = Nokogiri::XML(domain_check_xml).to_s.squish - expect(generated).to eq(expected) - - expected = Nokogiri::XML(' - - - - - example.ee - example2.ee - example3.ee - - - ABC-12345 - - - ').to_s.squish - - generated = Nokogiri::XML(domain_check_xml(names: ['example.ee', 'example2.ee', 'example3.ee'])).to_s.squish - expect(generated).to eq(expected) - end - it 'generates valid renew xml' do expected = Nokogiri::XML(' diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 461de1f62..ecb254a0d 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -73,25 +73,6 @@ module Epp end end - def domain_check_xml(xml_params = {}) - xml_params[:names] = xml_params[:names] || ['example.ee'] - xml = Builder::XmlMarkup.new - - xml.instruct!(:xml, standalone: 'no') - xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do - xml.command do - xml.check do - xml.tag!('domain:check', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do - xml_params[:names].each do |x| - xml.tag!('domain:name', (x || 'example.ee')) - end if xml_params[:names].any? - end - end - xml.clTRID 'ABC-12345' - end - end - end - def domain_update_xml(xml_params = {}, dnssec_params = false) defaults = { name: { value: 'example.ee' } From 52594cbedc8d2f0ff2e385b6c4854688dedf9348 Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Fri, 24 Oct 2014 18:15:23 +0300 Subject: [PATCH 09/14] updated seed file with new data --- db/seeds.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 30c0c775a..e16c5ad19 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,46 +10,46 @@ Country.where(name: 'Estonia', iso: 'EE').first_or_create! Country.where(name: 'Latvia', iso: 'LV').first_or_create! zone = Registrar.where( - name: 'Zonedata AS', + name: 'Registrar First AS', reg_no: '10300220', address: 'Pärnu mnt 2, Tallinna linn, Harju maakond, 11415', country: Country.first ).first_or_create EppUser.where( - username: 'zone', - password: 'ghyt9e4fu', + username: 'registrar1', + password: 'test1', active: true, registrar: zone ).first_or_create elkdata = Registrar.where( - name: 'Elkservers OÜ', + name: 'Registrar Second AS', reg_no: '10529229', address: 'Vabaduse pst 32, 11316 Tallinn', country: Country.first ).first_or_create EppUser.where( - username: 'elkdata', - password: '8932iods', + username: 'registrar2', + password: 'test2', active: true, registrar: elkdata ).first_or_create User.where( - username: 'gitlab', - password: '12345', - email: 'info@gitlab.eu', + username: 'user1', + password: 'test1', + email: 'user1@example.ee', admin: true, identity_code: '37810013855', country: Country.where(name: 'Estonia').first ).first_or_create User.where( - username: 'zone', - password: '54321', - email: 'zone-info@example.ee', + username: 'user2', + password: 'test2', + email: 'user2@example.ee', admin: false, identity_code: '37810010085', registrar_id: zone.id, @@ -57,9 +57,9 @@ User.where( ).first_or_create User.where( - username: 'elkdata', - password: '32154', - email: 'elk-info@example.ee', + username: 'user3', + password: 'test3', + email: 'user3@example.ee', admin: false, identity_code: '37810010727', registrar_id: elkdata.id, From 36e8b4c56d4e631d5c63a4b3ad138ab3fc1087df Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Mon, 27 Oct 2014 15:18:49 +0200 Subject: [PATCH 10/14] bin files are now less noisy --- bin/rails | 2 +- bin/rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/rails b/bin/rails index 7e12a9fe4..284b01d72 100755 --- a/bin/rails +++ b/bin/rails @@ -2,7 +2,7 @@ begin load File.expand_path('../spring', __FILE__) rescue LoadError - puts 'no spring' + 'no spring' end APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' diff --git a/bin/rake b/bin/rake index 54d3c10d0..7b36ecbff 100755 --- a/bin/rake +++ b/bin/rake @@ -2,7 +2,7 @@ begin load File.expand_path('../spring', __FILE__) rescue LoadError - puts 'no spring' + 'no spring' end require_relative '../config/boot' require 'rake' From 0fe947ce8a1f82ecae51aa2647240fddc13d4f85 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 29 Oct 2014 11:03:02 +0200 Subject: [PATCH 11/14] Fix name parsing --- app/helpers/epp/domains_helper.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index a38fcaf55..7b8295f35 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -112,11 +112,14 @@ module Epp::DomainsHelper end def domain_create_params + name = parsed_frame.css('name').text + period = parsed_frame.css('period').text + { - name: @ph[:name], + name: name, registrar_id: current_epp_user.registrar.try(:id), registered_at: Time.now, - period: (@ph[:period].to_i == 0) ? 1 : @ph[:period].to_i, + period: (period.to_i == 0) ? 1 : period.to_i, period_unit: Epp::EppDomain.parse_period_unit_from_frame(parsed_frame) || 'y' } end From 1498aa339f76a3fee57355b3eb09af99359b7b16 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 29 Oct 2014 12:51:09 +0200 Subject: [PATCH 12/14] Add domain name invalid to epp errors --- app/models/epp/epp_domain.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index e3885466b..87dfb6878 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -39,6 +39,9 @@ class Epp::EppDomain < Domain } ] ], + '2005' => [ + [:name_dirty, :invalid, { obj: 'name', val: name_dirty }] + ], '2201' => [ [:auth_info, :wrong_pw] ] From 4c7895a7fb4bb26ec8d37e331068be64c7ae9cf8 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 31 Oct 2014 15:10:09 +0200 Subject: [PATCH 13/14] Bump epp-xml, fix some epp bugs --- Gemfile | 2 +- Gemfile.lock | 4 +- app/helpers/epp/domains_helper.rb | 4 +- app/models/epp/epp_domain.rb | 7 +- spec/epp/domain_spec.rb | 12 +-- spec/epp/epp_helper_spec.rb | 152 ------------------------------ spec/support/epp.rb | 28 ------ 7 files changed, 14 insertions(+), 195 deletions(-) diff --git a/Gemfile b/Gemfile index 11ada97ca..9a83dfb83 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,7 @@ group :development, :test do gem 'epp', '~> 1.4.0' # EPP XMLs - gem 'epp-xml', '~> 0.1.0' + gem 'epp-xml', '~> 0.2.0' # Replacement for fixtures gem 'fabrication', '~> 2.11.3' diff --git a/Gemfile.lock b/Gemfile.lock index 75bfcd682..c23970e87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,7 +93,7 @@ GEM epp (1.4.0) hpricot libxml-ruby - epp-xml (0.1.0) + epp-xml (0.2.0) activesupport (~> 4.1) builder (~> 3.2) equalizer (0.0.9) @@ -362,7 +362,7 @@ DEPENDENCIES database_cleaner (~> 1.3.0) devise (~> 3.3.0) epp (~> 1.4.0) - epp-xml (~> 0.1.0) + epp-xml (~> 0.2.0) fabrication (~> 2.11.3) faker (~> 1.3.0) guard (~> 2.6.1) diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index 7b8295f35..d8d8aca9a 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -51,10 +51,10 @@ module Epp::DomainsHelper handle_errors(@domain) and return unless @domain - @domain.parse_and_attach_domain_dependencies(parsed_frame.css('add')) - @domain.parse_and_attach_ds_data(parsed_frame.css('extension add')) @domain.parse_and_detach_domain_dependencies(parsed_frame.css('rem')) @domain.parse_and_detach_ds_data(parsed_frame.css('extension rem')) + @domain.parse_and_attach_domain_dependencies(parsed_frame.css('add')) + @domain.parse_and_attach_ds_data(parsed_frame.css('extension add')) @domain.parse_and_update_domain_dependencies(parsed_frame.css('chg')) if @domain.errors.any? diff --git a/app/models/epp/epp_domain.rb b/app/models/epp/epp_domain.rb index 87dfb6878..3148ff9ed 100644 --- a/app/models/epp/epp_domain.rb +++ b/app/models/epp/epp_domain.rb @@ -171,7 +171,6 @@ class Epp::EppDomain < Domain to_delete << nameserver end end - nameservers.delete(to_delete) end @@ -239,7 +238,6 @@ class Epp::EppDomain < Domain def detach_dnskeys(dnssec_data) return false unless validate_dnssec_data(dnssec_data) - to_delete = [] dnssec_data[:ds_data].each do |x| ds = dnskeys.where(ds_key_tag: x[:ds_key_tag]) @@ -250,7 +248,6 @@ class Epp::EppDomain < Domain end end - to_delete = [] dnssec_data[:key_data].each do |x| ds = dnskeys.where(public_key: x[:public_key]) if ds.blank? @@ -392,11 +389,13 @@ class Epp::EppDomain < Domain def parse_nameservers_from_frame(parsed_frame) res = [] parsed_frame.css('hostAttr').each do |x| - res << { + host_attr = { hostname: x.css('hostName').first.try(:text), ipv4: x.css('hostAddr[ip="v4"]').first.try(:text), ipv6: x.css('hostAddr[ip="v6"]').first.try(:text) } + + res << host_attr.delete_if { |_k, v| v.blank? } end parsed_frame.css('hostObj').each do |x| diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 67e6a16b9..984bcc003 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -810,7 +810,7 @@ describe 'EPP Domain', epp: true do end it 'updates domain and adds objects', pending: true do - xml = domain_update_xml({ + xml = EppXml::Domain.update({ add: [ { ns: [ @@ -893,7 +893,7 @@ describe 'EPP Domain', epp: true do it 'updates a domain and removes objects' do Fabricate(:contact, code: 'mak21') - xml = domain_update_xml({ + xml = EppXml::Domain.update({ add: [ { ns: [ @@ -931,7 +931,7 @@ describe 'EPP Domain', epp: true do d = Domain.last expect(d.dnskeys.count).to eq(2) - xml = domain_update_xml({ + xml = EppXml::Domain.update({ rem: [ { ns: [ @@ -982,7 +982,7 @@ describe 'EPP Domain', epp: true do it 'does not add duplicate objects to domain' do Fabricate(:contact, code: 'mak21') - xml = domain_update_xml({ + xml = EppXml::Domain.update({ add: [ ns: [ { hostObj: { value: 'ns1.example.com' } } @@ -1008,7 +1008,7 @@ describe 'EPP Domain', epp: true do ] } - response = epp_request(domain_update_xml(xml_params), :xml) + response = epp_request(EppXml::Domain.update(xml_params), :xml) expect(response[:results][0][:result_code]).to eq('1000') d = Domain.last @@ -1018,7 +1018,7 @@ describe 'EPP Domain', epp: true do end it 'does not assign invalid status to domain' do - xml = domain_update_xml({ + xml = EppXml::Domain.update({ add: [ status: { value: '', attrs: { s: 'invalidStatus' } } ] diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index 61346d231..00d49c933 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -43,158 +43,6 @@ describe 'EPP Helper', epp: true do expect(generated).to eq(expected) end - it 'generates valid update xml' do - # Detailed update - expected = Nokogiri::XML(' - - - - - example.ee - - - ns2.example.com - - mak21 - - Payment overdue. - - - - ns1.example.com - - sh8013 - - - - mak21 - - - - ABC-12345 - - - ').to_s.squish - - xml = domain_update_xml( - name: { value: 'example.ee' }, - add: [ - { ns: - [ - hostObj: { value: 'ns1.example.com' }, - hostObj: { value: 'ns2.example.com' } - ] - }, - { contact: { attrs: { type: 'tech' }, value: 'mak21' } }, - { status: { attrs: { s: 'clientUpdateProhibited' }, value: '' } }, - { status: { attrs: { s: 'clientHold', lang: 'en' }, value: 'Payment overdue.' } } - ], - rem: [ - ns: [ - hostObj: { value: 'ns1.example.com' } - ], - contact: { attrs: { type: 'tech' }, value: 'sh8013' }, - status: { attrs: { s: 'clientUpdateProhibited' }, value: '' } - ], - chg: [ - registrant: { value: 'mak21' } - ] - ) - - generated = Nokogiri::XML(xml).to_s.squish - expect(generated).to eq(expected) - - # Update with NS IP-s - - expected = Nokogiri::XML(' - - - - - one.ee - - sh8013 - Payment overdue. - - - - - ns1.example.net - 192.0.2.2 - 1080:0:0:0:8:800:200C:417A - - - sh8013 - - - - sh8013 - - - - ABC-12345 - - - ').to_s.squish - - xml = domain_update_xml( - name: { value: 'one.ee' }, - add: [ - ns: nil, - contact: { value: 'sh8013', attrs: { type: 'admin' } }, - status: { value: 'Payment overdue.', attrs: { s: 'testStatus', lang: 'et' } } - ], - rem: [ - ns: [ - hostAttr: [ - { hostName: { value: 'ns1.example.net' } }, - { hostAddr: { value: '192.0.2.2', attrs: { ip: 'v4' } } }, - { hostAddr: { value: '1080:0:0:0:8:800:200C:417A', attrs: { ip: 'v6' } } } - ] - ], - contact: { attrs: { type: 'tech' }, value: 'sh8013' }, - status: { attrs: { s: 'clientUpdateProhibited' }, value: '' } - ], - chg: [ - registrant: { value: 'sh8013' } - ] - ) - - generated = Nokogiri::XML(xml).to_s.squish - expect(generated).to eq(expected) - - ## Update with chg - - expected = Nokogiri::XML(' - - - - - example.ee - - mak21 - - - - ABC-12345 - - - ').to_s.squish - - xml = domain_update_xml( - chg: [ - registrant: { value: 'mak21' } - ] - ) - generated = Nokogiri::XML(xml).to_s.squish - expect(generated).to eq(expected) - end - it 'generates valid transfer xml' do expected = Nokogiri::XML(' diff --git a/spec/support/epp.rb b/spec/support/epp.rb index ecb254a0d..ab57f2b26 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -73,34 +73,6 @@ module Epp end end - def domain_update_xml(xml_params = {}, dnssec_params = false) - defaults = { - name: { value: 'example.ee' } - } - - xml_params = defaults.deep_merge(xml_params) - - xml = Builder::XmlMarkup.new - - xml.instruct!(:xml, standalone: 'no') - xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do - xml.command do - xml.update do - xml.tag!('domain:update', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do - generate_xml_from_hash(xml_params, xml, 'domain:') - end - end - - xml.extension do - xml.tag!('secDNS:create', 'xmlns:secDNS' => 'urn:ietf:params:xml:ns:secDNS-1.1') do - generate_xml_from_hash(dnssec_params, xml, 'secDNS:') - end - end if dnssec_params != false - xml.clTRID 'ABC-12345' - end - end - end - def generate_xml_from_hash(xml_params, xml, ns = '') xml_params.each do |k, v| # Value is a hash which has string type value From fed8c94884d1cbe323330db6e7bb65c963b913d0 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Mon, 3 Nov 2014 11:26:08 +0200 Subject: [PATCH 14/14] Bump epp-xml --- Gemfile | 2 +- Gemfile.lock | 4 ++-- spec/epp/domain_spec.rb | 4 ++-- spec/epp/epp_helper_spec.rb | 36 ------------------------------------ spec/support/epp.rb | 19 ------------------- 5 files changed, 5 insertions(+), 60 deletions(-) diff --git a/Gemfile b/Gemfile index 9a83dfb83..72210a40a 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,7 @@ group :development, :test do gem 'epp', '~> 1.4.0' # EPP XMLs - gem 'epp-xml', '~> 0.2.0' + gem 'epp-xml', '~> 0.3.0' # Replacement for fixtures gem 'fabrication', '~> 2.11.3' diff --git a/Gemfile.lock b/Gemfile.lock index c23970e87..ac74083be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,7 +93,7 @@ GEM epp (1.4.0) hpricot libxml-ruby - epp-xml (0.2.0) + epp-xml (0.3.0) activesupport (~> 4.1) builder (~> 3.2) equalizer (0.0.9) @@ -362,7 +362,7 @@ DEPENDENCIES database_cleaner (~> 1.3.0) devise (~> 3.3.0) epp (~> 1.4.0) - epp-xml (~> 0.2.0) + epp-xml (~> 0.3.0) fabrication (~> 2.11.3) faker (~> 1.3.0) guard (~> 2.6.1) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 984bcc003..ac1022fcc 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1032,7 +1032,7 @@ describe 'EPP Domain', epp: true do it 'deletes domain' do expect(DomainContact.count).to eq(2) - response = epp_request(domain_delete_xml, :xml) + response = epp_request(EppXml::Domain.delete(name: { value: 'example.ee' }), :xml) expect(response[:result_code]).to eq('1000') expect(Domain.first).to eq(nil) @@ -1042,7 +1042,7 @@ describe 'EPP Domain', epp: true do it 'does not delete domain with specific status' do d = Domain.first d.domain_statuses.create(value: DomainStatus::CLIENT_DELETE_PROHIBITED) - response = epp_request(domain_delete_xml, :xml) + response = epp_request(EppXml::Domain.delete(name: { value: 'example.ee' }), :xml) expect(response[:result_code]).to eq('2304') expect(response[:msg]).to eq('Domain status prohibits operation') end diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index 00d49c933..1283c164e 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -86,41 +86,5 @@ describe 'EPP Helper', epp: true do generated = Nokogiri::XML(xml).to_s.squish expect(generated).to eq(expected) end - - it 'generates valid delete xml' do - expected = Nokogiri::XML(' - - - - - example.ee - - - ABC-12345 - - - ').to_s.squish - - generated = Nokogiri::XML(domain_delete_xml).to_s.squish - expect(generated).to eq(expected) - - expected = Nokogiri::XML(' - - - - - one.ee - - - ABC-12345 - - - ').to_s.squish - - generated = Nokogiri::XML(domain_delete_xml(name: 'one.ee')).to_s.squish - expect(generated).to eq(expected) - end end end diff --git a/spec/support/epp.rb b/spec/support/epp.rb index ab57f2b26..1f456775d 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -127,25 +127,6 @@ module Epp end end end - - def domain_delete_xml(xml_params = {}) - xml_params[:name] = xml_params[:name] || 'example.ee' - xml = Builder::XmlMarkup.new - - xml.instruct!(:xml, standalone: 'no') - xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do - xml.command do - xml.delete do - xml.tag!('domain:delete', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do - if xml_params[:name] != false - xml.tag!('domain:name', xml_params[:name]) - end - end - end - xml.clTRID 'ABC-12345' - end - end - end end RSpec.configure do |c|