Upgrade epp-xml

This commit is contained in:
Martin Lensment 2014-12-18 15:52:24 +02:00
parent 9d318644ed
commit 9feea600d8
10 changed files with 72 additions and 53 deletions

View file

@ -96,7 +96,7 @@ group :development, :test do
gem 'epp', '~> 1.4.0'
# EPP XMLs
gem 'epp-xml', '~> 0.8.1'
gem 'epp-xml', '~> 0.10.1'
# Replacement for fixtures
gem 'fabrication', '~> 2.11.3'

View file

@ -106,7 +106,7 @@ GEM
epp (1.4.0)
hpricot
libxml-ruby
epp-xml (0.8.1)
epp-xml (0.10.1)
activesupport (~> 4.1)
builder (~> 3.2)
equalizer (0.0.9)
@ -177,7 +177,7 @@ GEM
open4 (~> 1.3.4)
rake
mini_portile (0.6.0)
minitest (5.4.3)
minitest (5.5.0)
multi_json (1.10.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
@ -384,7 +384,7 @@ DEPENDENCIES
delayed_job_active_record (~> 4.0.2)
devise (~> 3.3.0)
epp (~> 1.4.0)
epp-xml (~> 0.8.1)
epp-xml (~> 0.10.1)
fabrication (~> 2.11.3)
faker (~> 1.3.0)
guard (~> 2.6.1)

View file

@ -15,6 +15,7 @@ describe 'EPP Contact', epp: true do
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
let(:zone) { Registrar.where(reg_no: '12345678').first || Fabricate(:registrar) }
let(:epp_xml) { EppXml::Contact.new(cl_trid: 'ABC-12345') }
context 'with valid user' do
before(:each) do
@ -27,7 +28,7 @@ describe 'EPP Contact', epp: true do
context 'create command' do
it 'fails if request xml is missing' do
xml = EppXml::Contact.create
xml = epp_xml.create
response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('2001')
@ -36,7 +37,7 @@ describe 'EPP Contact', epp: true do
end
it 'fails if request xml is missing' do
xml = EppXml::Contact.create(
xml = epp_xml.create(
postalInfo: { addr: { value: nil } }
)
response = epp_request(xml, :xml)
@ -145,7 +146,7 @@ describe 'EPP Contact', epp: true do
context 'update command' do
it 'fails if request is invalid' do
xml = EppXml::Contact.update
xml = epp_xml.update
response = epp_request(xml, :xml) # epp_request('contacts/update_missing_attr.xml')
expect(response[:results][0][:result_code]).to eq('2003')
@ -229,7 +230,7 @@ describe 'EPP Contact', epp: true do
context 'delete command' do
it 'fails if request is invalid' do
xml = EppXml::Contact.delete({ uid: { value: '23123' } })
xml = epp_xml.delete({ uid: { value: '23123' } })
response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('2003')
@ -276,7 +277,7 @@ describe 'EPP Contact', epp: true do
context 'check command' do
it 'fails if request is invalid' do
xml = EppXml::Contact.check({ uid: { value: '123asde' } })
xml = epp_xml.check({ uid: { value: '123asde' } })
response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('2003')
@ -306,7 +307,7 @@ describe 'EPP Contact', epp: true do
@contact = Fabricate(:contact, registrar: zone, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
xml = EppXml::Contact.info({ id: { value: @contact.code } })
xml = epp_xml.info({ id: { value: @contact.code } })
response = epp_request(xml, :xml, :zone)
contact = response[:parsed].css('resData chkData')
@ -319,7 +320,7 @@ describe 'EPP Contact', epp: true do
@contact = Fabricate(:contact, registrar: elkdata, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
xml = EppXml::Contact.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'asdesde' } } })
xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'asdesde' } } })
response = epp_request(xml, :xml, :zone)
expect(response[:result_code]).to eq('2200')
@ -331,7 +332,7 @@ describe 'EPP Contact', epp: true do
name: 'Johnny Awesome', auth_info: 'password',
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
xml = EppXml::Contact.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'password' } } })
xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'password' } } })
response = epp_request(xml, :xml, :zone)
contact = response[:parsed].css('resData chkData')
@ -345,7 +346,7 @@ describe 'EPP Contact', epp: true do
auth_info: 'password',
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
xml = EppXml::Contact.info({ id: { value: @contact.code } })
xml = epp_xml.info({ id: { value: @contact.code } })
response = epp_request(xml, :xml, :zone)
contact = response[:parsed].css('resData chkData')
@ -355,7 +356,7 @@ describe 'EPP Contact', epp: true do
end
it 'fails if request invalid' do
response = epp_request(EppXml::Contact.info({ uid: { value: '123123' } }), :xml)
response = epp_request(epp_xml.info({ uid: { value: '123123' } }), :xml)
expect(response[:results][0][:result_code]).to eq('2003')
expect(response[:results][0][:msg]).to eq('Required parameter missing: id')
@ -373,7 +374,7 @@ describe 'EPP Contact', epp: true do
@contact = Fabricate(:contact, registrar: zone, code: 'info-4444', name: 'Johnny Awesome',
address: Fabricate(:address))
xml = EppXml::Contact.info(id: { value: @contact.code })
xml = epp_xml.info(id: { value: @contact.code })
response = epp_request(xml, :xml, :zone)
contact = response[:parsed].css('resData chkData')
@ -387,7 +388,7 @@ describe 'EPP Contact', epp: true do
Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR', registrar: elkdata,
disclosure: Fabricate(:contact_disclosure, name: true, email: false, phone: false))
xml = EppXml::Contact.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
xml = epp_xml.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
response = epp_request(xml, :xml, :zone)
contact = response[:parsed].css('resData chkData')
@ -404,7 +405,7 @@ describe 'EPP Contact', epp: true do
it 'doesn\'t display unassociated object without password' do
@contact = Fabricate(:contact, code: 'info-4444', registrar: zone)
xml = EppXml::Contact.info(id: { value: @contact.code })
xml = epp_xml.info(id: { value: @contact.code })
response = epp_request(xml, :xml, :elkdata)
expect(response[:result_code]).to eq('2003')
expect(response[:msg]).to eq('Required parameter missing: pw')
@ -413,7 +414,7 @@ describe 'EPP Contact', epp: true do
it 'doesn\'t display unassociated object with wrong password' do
@contact = Fabricate(:contact, code: 'info-4444', registrar: zone)
xml = EppXml::Contact.info(id: { value: @contact.code }, authInfo: { pw: { value: 'qwe321' } })
xml = epp_xml.info(id: { value: @contact.code }, authInfo: { pw: { value: 'qwe321' } })
response = epp_request(xml, :xml, :elkdata)
expect(response[:result_code]).to eq('2200')
expect(response[:msg]).to eq('Authentication error')

View file

@ -15,6 +15,7 @@ describe 'EPP Domain', epp: true do
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
let(:zone) { Fabricate(:registrar) }
let(:epp_xml) { EppXml.new(cl_trid: 'ABC-12345') }
before(:each) { create_settings }
@ -113,7 +114,7 @@ describe 'EPP Domain', epp: true do
# should show up in other registrar's poll
response = epp_request(EppXml::Session.poll, :xml, :elkdata)
response = epp_request(epp_xml.session.poll, :xml, :elkdata)
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
msg_q = response[:parsed].css('msgQ')
expect(msg_q.css('qDate').text).to_not be_blank
@ -121,7 +122,7 @@ describe 'EPP Domain', epp: true do
expect(msg_q.first['id']).to_not be_blank
expect(msg_q.first['count']).to eq('1')
xml = EppXml::Session.poll(poll: {
xml = epp_xml.session.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
@ -751,7 +752,7 @@ describe 'EPP Domain', epp: true do
it 'renews a domain' do
exp_date = (Date.today + 1.year)
xml = EppXml::Domain.renew(
xml = epp_xml.domain.renew(
name: { value: 'example.ee' },
curExpDate: { value: exp_date.to_s },
period: { value: '1', attrs: { unit: 'y' } }
@ -765,7 +766,7 @@ describe 'EPP Domain', epp: true do
end
it 'returns an error when given and current exp dates do not match' do
xml = EppXml::Domain.renew(
xml = epp_xml.domain.renew(
name: { value: 'example.ee' },
curExpDate: { value: '2016-08-07' },
period: { value: '1', attrs: { unit: 'y' } }
@ -779,7 +780,7 @@ describe 'EPP Domain', epp: true do
it 'returns an error when period is invalid' do
exp_date = (Date.today + 1.year)
xml = EppXml::Domain.renew(
xml = epp_xml.domain.renew(
name: { value: 'example.ee' },
curExpDate: { value: exp_date.to_s },
period: { value: '4', attrs: { unit: 'y' } }
@ -1134,7 +1135,7 @@ describe 'EPP Domain', epp: true do
it 'deletes domain' do
expect(DomainContact.count).to eq(2)
response = epp_request(EppXml::Domain.delete(name: { value: 'example.ee' }), :xml)
response = epp_request(epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
expect(response[:result_code]).to eq('1000')
expect(Domain.first).to eq(nil)
@ -1144,7 +1145,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(EppXml::Domain.delete(name: { value: 'example.ee' }), :xml)
response = epp_request(epp_xml.domain.delete(name: { value: 'example.ee' }), :xml)
expect(response[:result_code]).to eq('2304')
expect(response[:msg]).to eq('Domain status prohibits operation')
end

View file

@ -6,6 +6,7 @@ describe 'EPP Keyrelay', epp: true do
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
let(:zone) { Fabricate(:registrar) }
let(:domain) { Fabricate(:domain, name: 'example.ee', registrar: zone, dnskeys: [Fabricate.build(:dnskey)]) }
let(:epp_xml) { EppXml::Keyrelay.new }
before(:each) { create_settings }
@ -16,7 +17,7 @@ describe 'EPP Keyrelay', epp: true do
end
it 'makes a keyrelay request' do
xml = EppXml::Keyrelay.keyrelay({
xml = epp_xml.keyrelay({
name: { value: 'example.ee' },
keyData: {
flags: { value: '256' },

View file

@ -5,6 +5,7 @@ describe 'EPP Poll', epp: true do
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
let(:zone) { Fabricate(:registrar) }
let(:epp_xml) { EppXml::Session.new }
before(:each) { create_settings }
@ -15,7 +16,7 @@ describe 'EPP Poll', epp: true do
end
it 'returns no messages in poll' do
response = epp_request(EppXml::Session.poll, :xml)
response = epp_request(epp_xml.poll, :xml)
expect(response[:msg]).to eq('Command completed successfully; no messages')
expect(response[:result_code]).to eq('1300')
@ -24,11 +25,11 @@ describe 'EPP Poll', epp: true do
it 'queues and dequeues messages' do
msg = zone.messages.create({ body: 'Balance low.' })
response = epp_request(EppXml::Session.poll, :xml, :elkdata)
response = epp_request(epp_xml.poll, :xml, :elkdata)
expect(response[:msg]).to eq('Command completed successfully; no messages')
expect(response[:result_code]).to eq('1300')
response = epp_request(EppXml::Session.poll, :xml, :zone)
response = epp_request(epp_xml.poll, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
expect(response[:result_code]).to eq('1301')
msg_q = response[:parsed].css('msgQ')
@ -37,7 +38,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.first['count']).to eq('1')
expect(msg_q.first['id']).to eq(msg.id.to_s)
xml = EppXml::Session.poll(poll: {
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
@ -59,7 +60,7 @@ describe 'EPP Poll', epp: true do
end
it 'returns an error on incorrect op' do
xml = EppXml::Session.poll(poll: {
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'bla' }
})
@ -72,7 +73,7 @@ describe 'EPP Poll', epp: true do
zone.messages.create({ body: 'Something.' })
zone.messages.create({ body: 'Smth else.' })
response = epp_request(EppXml::Session.poll, :xml, :zone)
response = epp_request(epp_xml.poll, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
expect(response[:result_code]).to eq('1301')
msg_q = response[:parsed].css('msgQ')
@ -80,7 +81,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.css('msg').text).to eq('Smth else.')
expect(msg_q.first['count']).to eq('3')
xml = EppXml::Session.poll(poll: {
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
@ -90,7 +91,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.first['id']).to_not be_blank
expect(msg_q.first['count']).to eq('2')
response = epp_request(EppXml::Session.poll, :xml, :zone)
response = epp_request(epp_xml.poll, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
expect(response[:result_code]).to eq('1301')
msg_q = response[:parsed].css('msgQ')
@ -98,7 +99,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.css('msg').text).to eq('Something.')
expect(msg_q.first['count']).to eq('2')
xml = EppXml::Session.poll(poll: {
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
@ -108,7 +109,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.first['id']).to_not be_blank
expect(msg_q.first['count']).to eq('1')
response = epp_request(EppXml::Session.poll, :xml, :zone)
response = epp_request(epp_xml.poll, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
expect(response[:result_code]).to eq('1301')
msg_q = response[:parsed].css('msgQ')
@ -116,7 +117,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.css('msg').text).to eq('Balance low.')
expect(msg_q.first['count']).to eq('1')
xml = EppXml::Session.poll(poll: {
xml = epp_xml.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
@ -126,7 +127,7 @@ describe 'EPP Poll', epp: true do
expect(msg_q.first['id']).to_not be_blank
expect(msg_q.first['count']).to eq('0')
response = epp_request(EppXml::Session.poll, :xml, :zone)
response = epp_request(epp_xml.poll, :xml, :zone)
expect(response[:msg]).to eq('Command completed successfully; no messages')
expect(response[:result_code]).to eq('1300')
end

View file

@ -2,7 +2,8 @@ require 'rails_helper'
describe 'EPP Session', epp: true do
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
let(:login_xml_cache) { EppXml::Session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' }) }
let(:epp_xml) { EppXml.new(cl_trid: 'ABC-12345') }
let(:login_xml_cache) { epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' }) }
context 'when not connected' do
it 'greets client upon connection' do
@ -29,7 +30,7 @@ describe 'EPP Session', epp: true do
end
it 'prohibits further actions unless logged in' do
response = epp_plain_request(EppXml::Domain.create, :xml)
response = epp_plain_request(epp_xml.domain.create, :xml)
expect(response[:result_code]).to eq('2002')
expect(response[:msg]).to eq('You need to login first.')
expect(response[:clTRID]).to eq('ABC-12345')

View file

@ -18,7 +18,8 @@ describe '.extract_attributes' do
# TODO: remodel create contact xml to support disclosure
it 'should return disclosure has if disclosure' do
xml = EppXml::Contact.create(
epp_xml = EppXml::Contact.new
xml = epp_xml.create(
{
disclose: { value: {
voice: { value: '' },

View file

@ -78,7 +78,9 @@ module Epp
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Domain.info(xml_params)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.info(xml_params)
end
# rubocop: disable Metrics/MethodLength
@ -122,7 +124,8 @@ module Epp
}
dnssec_params = dnssec_defaults.deep_merge(dnssec_params) if dnssec_params != false
EppXml::Domain.create(xml_params, dnssec_params)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.create(xml_params, dnssec_params)
end
def domain_create_with_invalid_ns_ip_xml
@ -154,7 +157,8 @@ module Epp
}
}
EppXml::Domain.create(xml_params, false)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.create(xml_params, false)
end
def domain_create_with_host_attrs
@ -186,7 +190,8 @@ module Epp
}
}
EppXml::Domain.create(xml_params, false)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.create(xml_params, false)
end
def domain_update_xml(xml_params = {}, dnssec_params = false)
@ -195,7 +200,8 @@ module Epp
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Domain.update(xml_params, dnssec_params)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.update(xml_params, dnssec_params)
end
def domain_check_xml(xml_params = {})
@ -205,7 +211,8 @@ module Epp
]
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Domain.check(xml_params)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.check(xml_params)
end
def domain_transfer_xml(xml_params = {}, op = 'query')
@ -217,7 +224,8 @@ module Epp
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Domain.transfer(xml_params, op)
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
epp_xml.transfer(xml_params, op)
end
def log(req, res)

View file

@ -15,7 +15,8 @@ module EppContactXmlHelper
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Contact.create(xml_params)
epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
epp_xml.create(xml_params)
end
def update_contact_xml(xml_params = {})
@ -37,19 +38,22 @@ module EppContactXmlHelper
}
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Contact.update(xml_params)
epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
epp_xml.update(xml_params)
end
def delete_contact_xml(xml_params = {})
defaults = { id: { value: 'sh8012' } }
xml_params = defaults.deep_merge(xml_params)
EppXml::Contact.delete(xml_params)
epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
epp_xml.delete(xml_params)
end
def info_contact_xml(xml_params = {})
defaults = { id: { value: 'sh8012' }, authInfo: { pw: { value: 'password' } } }
xml_params = defaults.deep_merge(xml_params)
EppXml::Contact.info(xml_params)
epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
epp_xml.info(xml_params)
end
def check_contact_xml(xml_params = {})
@ -57,7 +61,8 @@ module EppContactXmlHelper
id: { value: 'ad123c3' }
}
xml_params = defaults.deep_merge(xml_params)
EppXml::Contact.check(xml_params)
epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
epp_xml.check(xml_params)
end
def check_multiple_contacts_xml