mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 01:36:02 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
187316078b
8 changed files with 66 additions and 12 deletions
|
@ -2,8 +2,15 @@ AllCops:
|
|||
RunRailsCops: true
|
||||
|
||||
Exclude:
|
||||
- 'Guardfile'
|
||||
# stuff generated by AR and rails
|
||||
- 'db/schema.rb'
|
||||
- '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:
|
||||
Max: 120
|
||||
|
|
|
@ -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' }
|
||||
end
|
||||
|
||||
# Disabled rubocop in guard until old offenses are removed to reduce visual clutter
|
||||
# guard :rubocop do
|
||||
# watch(%r{.+\.rb$})
|
||||
# watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||
# end
|
||||
guard :rubocop do
|
||||
watch(%r{.+\.rb$})
|
||||
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,11 @@ module Epp
|
|||
render 'epp/contacts/info'
|
||||
end
|
||||
|
||||
def renew_contact
|
||||
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') }
|
||||
handle_errors
|
||||
end
|
||||
|
||||
## HELPER METHODS
|
||||
|
||||
private
|
||||
|
@ -48,14 +53,12 @@ module Epp
|
|||
## CREATE
|
||||
def validate_contact_create_request
|
||||
@ph = params_hash['epp']['command']['create']['create']
|
||||
xml_attrs_present?(@ph, [%w(id),
|
||||
%w(authInfo pw),
|
||||
%w(postalInfo)])
|
||||
xml_attrs_present?(@ph, [%w(id), %w(authInfo pw), %w(postalInfo)])
|
||||
|
||||
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
|
||||
|
||||
xml_attrs_array_present?(@ph['postalInfo'], [%w(name),
|
||||
%w(addr city),
|
||||
%w(addr cc)])
|
||||
(epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
|
||||
xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)])
|
||||
end
|
||||
|
||||
## UPDATE
|
||||
|
|
|
@ -14,6 +14,23 @@ class Address < ActiveRecord::Base
|
|||
# validates_inclusion_of :type, in: TYPES
|
||||
|
||||
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)
|
||||
address_hash = {}
|
||||
[ah].flatten.each do |pi|
|
||||
|
|
|
@ -98,6 +98,10 @@ en:
|
|||
epp_exp_dates_do_not_match: 'Given and current expire dates do not match'
|
||||
epp_registrant_not_found: 'Registrant not found'
|
||||
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:
|
||||
codes:
|
||||
|
|
|
@ -236,5 +236,14 @@ describe 'EPP Contact', epp: true do
|
|||
expect(response[:msg]).to eq('Authorization error')
|
||||
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
|
||||
|
|
15
spec/epp/requests/contacts/renew.xml
Normal file
15
spec/epp/requests/contacts/renew.xml
Normal 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>
|
|
@ -36,7 +36,7 @@ module EppContactXmlBuilder
|
|||
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
|
||||
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:org', ( xml_params[:org_name] || 'Example Inc.')) unless xml_params[:org_name] == false
|
||||
unless xml_params[:addr] == [false]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue