Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Martin Lensment 2014-08-28 15:37:46 +03:00
commit 187316078b
8 changed files with 66 additions and 12 deletions

View file

@ -2,8 +2,15 @@ AllCops:
RunRailsCops: true RunRailsCops: true
Exclude: Exclude:
- 'Guardfile'
# stuff generated by AR and rails
- 'db/schema.rb' - 'db/schema.rb'
- 'db/migrate/*' - 'db/migrate/*'
# spring generated stuff
- 'bin/*'
# epp support files until 'complexity issues' will be solved
- 'spec/support/epp.rb'
- 'spec/support/epp_contact_xml_builder.rb'
Metrics/LineLength: Metrics/LineLength:
Max: 120 Max: 120

View file

@ -24,9 +24,8 @@ group :red_green_refactor, halt_on_fail:true do
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end end
# Disabled rubocop in guard until old offenses are removed to reduce visual clutter guard :rubocop do
# guard :rubocop do watch(%r{.+\.rb$})
# watch(%r{.+\.rb$}) watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
# watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } end
# end
end end

View file

@ -41,6 +41,11 @@ module Epp
render 'epp/contacts/info' render 'epp/contacts/info'
end end
def renew_contact
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') }
handle_errors
end
## HELPER METHODS ## HELPER METHODS
private private
@ -48,14 +53,12 @@ module Epp
## CREATE ## CREATE
def validate_contact_create_request def validate_contact_create_request
@ph = params_hash['epp']['command']['create']['create'] @ph = params_hash['epp']['command']['create']['create']
xml_attrs_present?(@ph, [%w(id), xml_attrs_present?(@ph, [%w(id), %w(authInfo pw), %w(postalInfo)])
%w(authInfo pw),
%w(postalInfo)])
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array) return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
xml_attrs_array_present?(@ph['postalInfo'], [%w(name), (epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
%w(addr city), xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)])
%w(addr cc)])
end end
## UPDATE ## UPDATE

View file

@ -14,6 +14,23 @@ class Address < ActiveRecord::Base
# validates_inclusion_of :type, in: TYPES # validates_inclusion_of :type, in: TYPES
class << self class << self
def validate_postal_info_types(parsed_frame)
errors, used = [], []
parsed_frame.css('postalInfo').each do |pi|
attr = pi.attributes['type'].try(:value)
errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')} and next unless attr
if !TYPES.include?(attr)
errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }}
next
end
errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr)
used << attr
end
errors
end
def extract_attributes(ah) def extract_attributes(ah)
address_hash = {} address_hash = {}
[ah].flatten.each do |pi| [ah].flatten.each do |pi|

View file

@ -98,6 +98,10 @@ en:
epp_exp_dates_do_not_match: 'Given and current expire dates do not match' epp_exp_dates_do_not_match: 'Given and current expire dates do not match'
epp_registrant_not_found: 'Registrant not found' epp_registrant_not_found: 'Registrant not found'
required_parameter_missing: 'Required parameter missing: %{key}' required_parameter_missing: 'Required parameter missing: %{key}'
attr_missing: 'Required parameter missing: %{key}'
repeating_postal_info: 'Only one of each postal info types may be provided'
invalid_type: 'PostalInfo type is invalid'
unimplemented_command: 'Unimplemented command'
setting_groups: setting_groups:
codes: codes:

View file

@ -236,5 +236,14 @@ describe 'EPP Contact', epp: true do
expect(response[:msg]).to eq('Authorization error') expect(response[:msg]).to eq('Authorization error')
end end
end end
context 'renew command' do
it 'returns 2101-unimplemented command' do
response = epp_request('contacts/renew.xml')
expect(response[:result_code]).to eq('2101')
expect(response[:msg]).to eq('Unimplemented command')
end
end
end end
end end

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<renew>
<contact:renew
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>info-4444</contact:id>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>
</contact:renew>
</renew>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -36,7 +36,7 @@ module EppContactXmlBuilder
xml.tag!('contact:create', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do xml.tag!('contact:create', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
xml.tag!('contact:id', xml_params[:id], 'sh8013') unless xml_params[:id] == false xml.tag!('contact:id', xml_params[:id], 'sh8013') unless xml_params[:id] == false
unless xml_params[:postalInfo] == [false] unless xml_params[:postalInfo] == [false]
xml.tag!('contact:postalInfo') do xml.tag!('contact:postalInfo', type: 'int') do
xml.tag!('contact:name', ( xml_params[:name] || 'Sillius Soddus')) unless xml_params[:name] == false xml.tag!('contact:name', ( xml_params[:name] || 'Sillius Soddus')) unless xml_params[:name] == false
xml.tag!('contact:org', ( xml_params[:org_name] || 'Example Inc.')) unless xml_params[:org_name] == false xml.tag!('contact:org', ( xml_params[:org_name] || 'Example Inc.')) unless xml_params[:org_name] == false
unless xml_params[:addr] == [false] unless xml_params[:addr] == [false]