From 177425d76978c2fee5a02bfc463cad903f7fc5f4 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 3 Sep 2014 14:40:14 +0300 Subject: [PATCH] New builder for domain update test --- spec/epp/domain_spec.rb | 24 ++++++++++++-- spec/epp/epp_helper_spec.rb | 66 ++++++++++++++++++------------------- spec/support/epp.rb | 26 +-------------- 3 files changed, 55 insertions(+), 61 deletions(-) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index c4ef6b270..24e00b911 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -422,8 +422,17 @@ describe 'EPP Domain', epp: true do it 'does not add duplicate objects to domain' do Fabricate(:contact, code: 'mak21') - epp_request('domains/update_add_objects.xml') - response = epp_request('domains/update_add_objects.xml') + + xml = domain_update_xml({ + add: [ + ns: [ + { hostObj: { value: 'ns1.example.com' } } + ] + ] + }) + + epp_request(xml, :xml) + response = epp_request(xml, :xml) expect(response[:results][0][:result_code]).to eq('2302') expect(response[:results][0][:msg]).to eq('Nameserver already exists on this domain') @@ -433,8 +442,17 @@ describe 'EPP Domain', epp: true do it 'updates a domain' do Fabricate(:contact, code: 'mak21') epp_request('domains/update_add_objects.xml') - response = epp_request(domain_update_xml, :xml) + xml_params = { + chg: [ + registrant: { value: 'mak21' }, + authInfo: [ + pw: { value: '2BARfoo' } + ] + ] + } + + response = epp_request(domain_update_xml(xml_params), :xml) expect(response[:results][0][:result_code]).to eq('1000') d = Domain.last diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index 05eb71d46..dc9c52d23 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -265,10 +265,38 @@ describe 'EPP Helper', epp: true do ').to_s.squish - generated = Nokogiri::XML(domain_update_xml).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' }, + authInfo: [ + pw: { value: '2BARfoo' } + ] + ] + ) + + generated = Nokogiri::XML(xml).to_s.squish expect(generated).to eq(expected) - # Edited detailed update + # Update with NS IP-s expected = Nokogiri::XML(' @@ -335,7 +363,7 @@ describe 'EPP Helper', epp: true do generated = Nokogiri::XML(xml).to_s.squish expect(generated).to eq(expected) - ## Update without add and rem + ## Update with chg expected = Nokogiri::XML(' @@ -357,42 +385,14 @@ describe 'EPP Helper', epp: true do ').to_s.squish - xml = domain_update_xml(add: nil, rem: nil) - generated = Nokogiri::XML(xml).to_s.squish - expect(generated).to eq(expected) - - expected = Nokogiri::XML(' - - - - - one.ee - - sh8013 - - b3rafsla - - - - - ABC-12345 - - - ').to_s.squish - xml = domain_update_xml( - name: { value: 'one.ee' }, - add: nil, - rem: nil, chg: [ - registrant: { value: 'sh8013' }, + registrant: { value: 'mak21' }, authInfo: [ - pw: { value: 'b3rafsla' } + pw: { value: '2BARfoo' } ] ] ) - generated = Nokogiri::XML(xml).to_s.squish expect(generated).to eq(expected) end diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 232eab153..c2a96e5ea 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -162,31 +162,7 @@ module Epp def domain_update_xml(xml_params = {}) defaults = { - 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' }, - authInfo: [ - pw: { value: '2BARfoo' } - ] - ] + name: { value: 'example.ee' } } xml_params = defaults.deep_merge(xml_params)