Fix contact create in registrar #2752

This commit is contained in:
Martin Lensment 2015-07-24 13:13:27 +03:00
parent 4c52e3b0b4
commit e463fe4d70
3 changed files with 29 additions and 28 deletions

View file

@ -4,7 +4,7 @@ module Depp
include DisableHtml5Validation include DisableHtml5Validation
attr_accessor :id, :name, :email, :phone, :org_name, attr_accessor :id, :name, :email, :phone, :org_name,
:ident, :ident_type, :ident_country_code, :ident, :ident_type, :ident_country_code,
:street, :city, :zip, :state, :country_code, :street, :city, :zip, :state, :country_code,
:password, :legal_document, :statuses, :code :password, :legal_document, :statuses, :code
@ -68,7 +68,7 @@ module Depp
zip: res.css('postalInfo addr pc').text, zip: res.css('postalInfo addr pc').text,
state: res.css('postalInfo addr sp').text, state: res.css('postalInfo addr sp').text,
country_code: res.css('postalInfo addr cc').text, country_code: res.css('postalInfo addr cc').text,
# authInfo # authInfo
password: res.css('authInfo pw').text, password: res.css('authInfo pw').text,
@ -145,25 +145,26 @@ module Depp
end end
def save def save
create_xml = Depp::Contact.epp_xml.create( hash = {
{ id: { value: code },
id: { value: code }, postalInfo: {
email: { value: email }, name: { value: name },
voice: { value: phone }, org: { value: org_name },
postalInfo: { addr: {
name: { value: name }, street: { value: street },
org: { value: org_name }, city: { value: city },
addr: { sp: { value: state },
street: { value: street }, pc: { value: zip },
city: { value: city }, cc: { value: country_code }
pc: { value: zip },
sp: { value: state },
cc: { value: country_code }
}
} }
}, },
extension_xml voice: { value: phone },
) email: { value: email }
}
hash[:id] = nil if code.blank?
create_xml = Depp::Contact.epp_xml.create(hash, extension_xml)
data = Depp::Contact.user.request(create_xml) data = Depp::Contact.user.request(create_xml)
self.id = data.css('id').text self.id = data.css('id').text
handle_errors(data) handle_errors(data)
@ -250,7 +251,7 @@ module Depp
return {} if legal_document.blank? return {} if legal_document.blank?
type = legal_document.original_filename.split('.').last.downcase type = legal_document.original_filename.split('.').last.downcase
{ {
_anonymus: [ _anonymus: [
legalDocument: { value: Base64.encode64(legal_document.read), attrs: { type: type } } legalDocument: { value: Base64.encode64(legal_document.read), attrs: { type: type } }
] ]
@ -274,7 +275,7 @@ module Depp
ident_type == 'priv' ident_type == 'priv'
end end
def persisted? def persisted?
id.present? id.present?
end end
@ -282,13 +283,13 @@ module Depp
data.css('result').each do |x| data.css('result').each do |x|
success_codes = %(1000, 1300, 1301) success_codes = %(1000, 1300, 1301)
next if success_codes.include?(x['code']) next if success_codes.include?(x['code'])
message = "#{x.css('msg').text} #{x.css('value').text}" message = "#{x.css('msg').text} #{x.css('value').text}"
attr = message.split('[').last.strip.sub(']', '') if message.include?('[') attr = message.split('[').last.strip.sub(']', '') if message.include?('[')
attr = :base if attr.nil? attr = :base if attr.nil?
attr = 'phone' if attr == 'voice' attr = 'phone' if attr == 'voice'
attr = 'zip' if attr == 'pc' attr = 'zip' if attr == 'pc'
errors.add(attr, message) errors.add(attr, message)
end end
errors.blank? errors.blank?
end end

View file

@ -87,8 +87,8 @@ describe 'EPP Poll', epp: true do
}) })
response = epp_plain_request(xml, validate_input: false) response = epp_plain_request(xml, validate_input: false)
response[:msg].should == 'Parameter value range error: op' response[:msg].should == "Element '{urn:ietf:params:xml:ns:epp-1.0}poll', attribute 'op': [facet 'enumeration'] The value 'bla' is not an element of the set {'ack', 'req'}."
response[:result_code].should == '2004' response[:result_code].should == '2001'
end end
it 'dequeues multiple messages' do it 'dequeues multiple messages' do

View file

@ -142,8 +142,8 @@ describe 'EPP Session', epp: true do
newPW: { value: '' } newPW: { value: '' }
), validate_input: false) ), validate_input: false)
response[:msg].should == 'Password is missing [password]' response[:msg].should == "Element '{urn:ietf:params:xml:ns:epp-1.0}newPW': [facet 'minLength'] The value has a length of '0'; this underruns the allowed minimum length of '6'."
response[:result_code].should == '2306' response[:result_code].should == '2001'
@api_user.reload @api_user.reload
@api_user.password.should == 'ghyt9e4fu' @api_user.password.should == 'ghyt9e4fu'