Rubocop autocorrect

This commit is contained in:
Martin Lensment 2014-08-25 14:14:25 +03:00
parent f8c48a7456
commit 6c5c0b38c8
59 changed files with 533 additions and 546 deletions

View file

@ -1,11 +1,20 @@
Style/LineLength:
AllCops:
RunRailsCops: true
Metrics/LineLength:
Max: 120
Documentation:
Enabled: false
Style/CyclomaticComplexity:
Severity: warning
Style/Semicolon:
AllowAsExpressionSeparator: true
Style/AndOr:
Enabled: false
Style/BracesAroundHashParameters:
Enabled: false
Style/IndentHash:
Enabled: false

View file

@ -37,7 +37,7 @@ gem 'nokogiri', '~> 1.6.2.1'
# For punycode
gem 'simpleidn', '~> 0.0.5'
#for EE-id validation
# for EE-id validation
gem 'isikukood'
gem 'bootstrap-sass', '~> 3.2.0.1'

View file

@ -12,7 +12,7 @@ module Epp::Common
end
def proxy
@svTRID = "ccReg-#{'%010d' % rand(10 ** 10)}"
@svTRID = "ccReg-#{'%010d' % rand(10**10)}"
send(params[:command])
end
@ -36,7 +36,7 @@ module Epp::Common
@current_epp_user ||= EppUser.find(epp_session[:epp_user_id]) if epp_session[:epp_user_id]
end
def handle_errors(obj=nil)
def handle_errors(obj = nil)
@errors ||= []
if obj
obj.construct_epp_errors
@ -44,7 +44,7 @@ module Epp::Common
end
# for debugging
@errors << {code: '1', msg: 'handle_errors was executed when there were actually no errors'} if @errors.blank?
@errors << { code: '1', msg: 'handle_errors was executed when there were actually no errors' } if @errors.blank?
render '/epp/error'
end
@ -55,13 +55,13 @@ module Epp::Common
def xml_attrs_present?(ph, attributes)
attributes.each do |x|
epp_errors << {code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)} unless has_attribute(ph, x)
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) } unless has_attribute(ph, x)
end
epp_errors.empty?
end
def has_attribute(ph, path)
path.inject(ph) do |location, key|
path.reduce(ph) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end

View file

@ -1,8 +1,8 @@
module Shared::UserStamper
extend ActiveSupport::Concern
def stamp obj
return false if obj.nil? || !obj.has_attribute?( :created_by_id && :updated_by_id )
def stamp(obj)
return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
if obj.new_record?
obj.created_by_id = current_epp_user.id
@ -10,6 +10,6 @@ module Shared::UserStamper
obj.updated_by_id = current_epp_user.id
end
return true
true
end
end

View file

@ -5,6 +5,7 @@ class Epp::CommandsController < ApplicationController
include Shared::UserStamper
private
def create
send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
end

View file

@ -2,7 +2,7 @@ class Epp::ErrorsController < ApplicationController
include Epp::Common
def error
epp_errors << {code: params[:code], msg: params[:msg]}
epp_errors << { code: params[:code], msg: params[:msg] }
render '/epp/error'
end
end

View file

@ -2,6 +2,7 @@ class Epp::SessionsController < ApplicationController
include Epp::Common
private
def hello
render 'greeting'
end

View file

@ -16,11 +16,12 @@ class SettingGroupsController < ApplicationController
end
private
def set_setting_group
@setting_group = SettingGroup.find(params[:id])
end
def setting_group_params
params.require(:setting_group).permit(settings_attributes: [ :value, :id ])
params.require(:setting_group).permit(settings_attributes: [:value, :id])
end
end

View file

@ -1,6 +1,6 @@
module Epp::ContactsHelper
def create_contact
@contact = Contact.new( contact_and_address_attributes )
@contact = Contact.new(contact_and_address_attributes)
render '/epp/contacts/create' and return if stamp(@contact) && @contact.save
handle_errors(@contact)
@ -29,7 +29,7 @@ module Epp::ContactsHelper
def check_contact
ph = params_hash['epp']['command']['check']['check']
@contacts = Contact.check_availability( ph[:id] )
@contacts = Contact.check_availability(ph[:id])
render '/epp/contacts/check'
end
@ -41,40 +41,41 @@ module Epp::ContactsHelper
end
## HELPER METHODS
private
## CREATE
def validate_contact_create_request
@ph = params_hash['epp']['command']['create']['create']
xml_attrs_present?(@ph, [['id'],
['authInfo', 'pw'],
['postalInfo', 'name'],
['postalInfo', 'addr', 'city'],
['postalInfo', 'addr', 'cc']])
%w(authInfo pw),
%w(postalInfo name),
%w(postalInfo addr city),
%w(postalInfo addr cc)])
end
## UPDATE
def validate_contact_update_request
@ph = params_hash['epp']['command']['update']['update']
xml_attrs_present?(@ph, [['id'] ])
xml_attrs_present?(@ph, [['id']])
end
## DELETE
def validate_contact_delete_request
@ph = params_hash['epp']['command']['delete']['delete']
xml_attrs_present?(@ph, [ ['id'] ] )
xml_attrs_present?(@ph, [['id']])
end
## CHECK
def validate_contact_check_request
@ph = params_hash['epp']['command']['check']['check']
xml_attrs_present?(@ph, [ ['id'] ])
xml_attrs_present?(@ph, [['id']])
end
## INFO
def validate_contact_info_request
@ph = params_hash['epp']['command']['info']['info']
xml_attrs_present?(@ph, [ ['id'] ])
xml_attrs_present?(@ph, [['id']])
end
## SHARED
@ -91,22 +92,22 @@ module Epp::ContactsHelper
pw = @ph.try(:[], :authInfo).try(:[], :pw) || @ph.try(:[], :chg).try(:[], :authInfo).try(:[], :pw) || []
id = @ph[:id]
return true if ( !find_contact.nil? && find_contact.auth_info_matches(pw) )
return true if !find_contact.nil? && find_contact.auth_info_matches(pw)
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error'), value: { obj: 'pw', val: pw } }
return false
false
end
def contact_and_address_attributes( type=:create )
def contact_and_address_attributes(type = :create)
case type
when :update
contact_hash = Contact.extract_attributes(@ph[:chg], type)
contact_hash[:address_attributes] =
Address.extract_attributes(( @ph.try(:[], :chg).try(:[], :postalInfo).try(:[], :addr) || [] ), type)
Address.extract_attributes(( @ph.try(:[], :chg).try(:[], :postalInfo).try(:[], :addr) || []), type)
else
contact_hash = Contact.extract_attributes(@ph, type)
contact_hash[:address_attributes] =
Address.extract_attributes(( @ph.try(:[], :postalInfo).try(:[], :addr) || [] ), type)
Address.extract_attributes(( @ph.try(:[], :postalInfo).try(:[], :addr) || []), type)
end
contact_hash[:ident_type] = ident_type unless ident_type.nil?
contact_hash
@ -118,6 +119,6 @@ module Epp::ContactsHelper
return nil unless result
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }
return nil
nil
end
end

View file

@ -48,6 +48,7 @@ module Epp::DomainsHelper
end
### HELPER METHODS ###
private
## CREATE
@ -95,7 +96,7 @@ module Epp::DomainsHelper
def find_domain
domain = Domain.find_by(name: @ph[:name])
unless domain
epp_errors << {code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: {obj: 'name', val: @ph[:name]}}
epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: { obj: 'name', val: @ph[:name] } }
end
domain
end

View file

@ -3,7 +3,7 @@ class Address < ActiveRecord::Base
belongs_to :country
class << self
def extract_attributes ah, type=:create
def extract_attributes(ah, _type = :create)
address_hash = {}
address_hash = ({
country_id: Country.find_by(iso: ah[:cc]).try(:id),
@ -14,7 +14,7 @@ class Address < ActiveRecord::Base
zip: ah[:pc]
}) if ah.is_a?(Hash)
address_hash.delete_if { |k, v| v.nil? }
address_hash.delete_if { |_k, v| v.nil? }
end
end
end

View file

@ -22,21 +22,21 @@ module EppErrors
values.each do |err|
if err.is_a?(Hash)
next unless code = find_epp_code(err[:msg])
err_msg = {code: code, msg: err[:msg]}
err_msg[:value] = {val: err[:val], obj: err[:obj]} if err[:val]
err_msg = { code: code, msg: err[:msg] }
err_msg[:value] = { val: err[:val], obj: err[:obj] } if err[:val]
epp_errors << err_msg
else
next unless code = find_epp_code(err)
err = {code: code, msg: err}
err = { code: code, msg: err }
# If we have setting relation, then still add the value to the error message
# If this sort of exception happens again, some other logic has to be implemented
if self.class.reflect_on_association(key) && key == :setting
err[:value] = {val: send(key).value, obj: self.class::EPP_ATTR_MAP[key]}
err[:value] = { val: send(key).value, obj: self.class::EPP_ATTR_MAP[key] }
#if the key represents other relations, skip value
# if the key represents other relations, skip value
elsif !self.class.reflect_on_association(key)
err[:value] = {val: send(key), obj: self.class::EPP_ATTR_MAP[key]}
err[:value] = { val: send(key), obj: self.class::EPP_ATTR_MAP[key] }
end
epp_errors << err

View file

@ -1,6 +1,6 @@
class Contact < ActiveRecord::Base
#TODO Foreign contact will get email with activation link/username/temp password
#TODO Phone number validation, in first phase very minimam in order to support current registries
# TODO Foreign contact will get email with activation link/username/temp password
# TODO Phone number validation, in first phase very minimam in order to support current registries
include EppErrors
@ -19,23 +19,23 @@ class Contact < ActiveRecord::Base
validate :ident_must_be_valid
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ #/\+\d{3}\.\d+/
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
validates :email, format: /@/
validates_uniqueness_of :code, message: :epp_id_taken
IDENT_TYPE_ICO = 'ico'
IDENT_TYPES = [
IDENT_TYPE_ICO, #Company registry code (or similar)
"op", #Estonian ID
"passport", #Passport number
"birthday" #Birthday date
IDENT_TYPE_ICO, # Company registry code (or similar)
'op', # Estonian ID
'passport', # Passport number
'birthday' # Birthday date
]
def ident_must_be_valid
#TODO Ident can also be passport number or company registry code.
#so have to make changes to validations (and doc/schema) accordingly
return true unless ident.present? && ident_type.present? && ident_type == "op"
# TODO Ident can also be passport number or company registry code.
# so have to make changes to validations (and doc/schema) accordingly
return true unless ident.present? && ident_type.present? && ident_type == 'op'
code = Isikukood.new(ident)
errors.add(:ident, 'bad format') unless code.valid?
end
@ -56,22 +56,22 @@ class Contact < ActiveRecord::Base
updated_by ? updated_by.username : nil
end
def auth_info_matches pw
def auth_info_matches(pw)
return true if auth_info == pw
return false
false
end
#Find a way to use self.domains with contact
# Find a way to use self.domains with contact
def domains_owned
Domain.find_by(owner_contact_id: id)
end
def relations_with_domain?
return true if domain_contacts.present? || domains_owned.present?
return false
false
end
#should use only in transaction
# should use only in transaction
def destroy_and_clean
clean_up_address
@ -84,15 +84,15 @@ class Contact < ActiveRecord::Base
def epp_code_map
{
'2302' => [ #Object exists
'2302' => [ # Object exists
[:code, :epp_id_taken]
],
'2303' => #Object does not exist
'2303' => # Object does not exist
[:not_found, :epp_obj_does_not_exist],
'2305' => [ #Association exists
'2305' => [ # Association exists
[:domains, :exist]
],
'2005' => [ #Value syntax error
'2005' => [ # Value syntax error
[:phone, :invalid],
[:email, :invalid]
]
@ -100,10 +100,7 @@ class Contact < ActiveRecord::Base
end
class << self
def extract_attributes ph, type=:create
def extract_attributes(ph, type = :create)
contact_hash = {
phone: ph[:voice],
ident: ph[:ident],
@ -117,7 +114,7 @@ class Contact < ActiveRecord::Base
contact_hash[:code] = ph[:id] if type == :create
contact_hash.delete_if { |k, v| v.nil? }
contact_hash.delete_if { |_k, v| v.nil? }
end
def check_availability(codes)
@ -126,9 +123,9 @@ class Contact < ActiveRecord::Base
res = []
codes.each do |x|
if Contact.find_by(code: x)
res << {code: x, avail: 0, reason: 'in use'}
res << { code: x, avail: 0, reason: 'in use' }
else
res << {code: x, avail: 1}
res << { code: x, avail: 1 }
end
end
@ -141,6 +138,4 @@ class Contact < ActiveRecord::Base
def clean_up_address
address.destroy if address
end
end

View file

@ -1,3 +1,2 @@
class Country < ActiveRecord::Base
end

View file

@ -1,6 +1,6 @@
class Domain < ActiveRecord::Base
#TODO whois requests ip whitelist for full info for own domains and partial info for other domains
#TODO most inputs should be trimmed before validatation, probably some global logic?
# TODO whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO most inputs should be trimmed before validatation, probably some global logic?
include EppErrors
@ -15,18 +15,18 @@ class Domain < ActiveRecord::Base
has_many :domain_contacts
has_many :tech_contacts, -> {
where(domain_contacts: {contact_type: DomainContact::TECH})
}, through: :domain_contacts, source: :contact
has_many :tech_contacts, -> do
where(domain_contacts: { contact_type: DomainContact::TECH })
end, through: :domain_contacts, source: :contact
has_many :admin_contacts, -> {
where(domain_contacts: {contact_type: DomainContact::ADMIN})
}, through: :domain_contacts, source: :contact
has_many :admin_contacts, -> do
where(domain_contacts: { contact_type: DomainContact::ADMIN })
end, through: :domain_contacts, source: :contact
has_and_belongs_to_many :nameservers
has_many :domain_statuses, -> {
joins(:setting).where(settings: {setting_group_id: SettingGroup.domain_statuses.id})
joins(:setting).where(settings: { setting_group_id: SettingGroup.domain_statuses.id })
}
delegate :code, to: :owner_contact, prefix: true
@ -123,14 +123,14 @@ class Domain < ActiveRecord::Base
def attach_nameservers(ns_list)
ns_list.each do |ns_attrs|
self.nameservers.build(ns_attrs)
nameservers.build(ns_attrs)
end
end
def attach_statuses(status_list)
status_list.each do |x|
setting = SettingGroup.domain_statuses.settings.find_by(value: x[:value])
self.domain_statuses.build(
domain_statuses.build(
setting: setting,
description: x[:description]
)
@ -139,9 +139,9 @@ class Domain < ActiveRecord::Base
def detach_contacts(contact_list)
to_delete = []
contact_list.each do |k, v|
contact_list.each do |_k, v|
v.each do |x|
contact = domain_contacts.joins(:contact).where(contacts: {code: x[:contact]})
contact = domain_contacts.joins(:contact).where(contacts: { code: x[:contact] })
if contact.blank?
errors.add(:domain_contacts, {
obj: 'contact',
@ -154,13 +154,13 @@ class Domain < ActiveRecord::Base
end
end
self.domain_contacts.delete(to_delete)
domain_contacts.delete(to_delete)
end
def detach_nameservers(ns_list)
to_delete = []
ns_list.each do |ns_attrs|
nameserver = self.nameservers.where(ns_attrs)
nameserver = nameservers.where(ns_attrs)
if nameserver.blank?
errors.add(:nameservers, {
obj: 'hostObj',
@ -172,13 +172,13 @@ class Domain < ActiveRecord::Base
end
end
self.nameservers.delete(to_delete)
nameservers.delete(to_delete)
end
def detach_statuses(status_list)
to_delete = []
status_list.each do |x|
status = domain_statuses.joins(:setting).where(settings: {value: x[:value]})
status = domain_statuses.joins(:setting).where(settings: { value: x[:value] })
if status.blank?
errors.add(:domain_statuses, {
obj: 'status',
@ -190,19 +190,19 @@ class Domain < ActiveRecord::Base
end
end
self.domain_statuses.delete(to_delete)
domain_statuses.delete(to_delete)
end
### RENEW ###
def renew(cur_exp_date, period, unit='y')
def renew(cur_exp_date, period, unit = 'y')
# TODO Check how much time before domain exp date can it be renewed
validate_exp_dates(cur_exp_date)
return false if errors.any?
p = self.class.convert_period_to_time(period, unit)
self.valid_to = self.valid_to + p
self.valid_to = valid_to + p
self.period = period
self.period_unit = unit
save
@ -215,7 +215,7 @@ class Domain < ActiveRecord::Base
min, max = sg.setting(:ns_min_count).value.to_i, sg.setting(:ns_max_count).value.to_i
unless nameservers.length.between?(min, max)
errors.add(:nameservers, :out_of_range, {min: min, max: max})
errors.add(:nameservers, :out_of_range, { min: min, max: max })
end
end
@ -226,11 +226,11 @@ class Domain < ActiveRecord::Base
def validate_period
return unless period.present?
if period_unit == 'd'
valid_values = ['365', '366', '710', '712', '1065', '1068']
valid_values = %w(365 366 710 712 1065 1068)
elsif period_unit == 'm'
valid_values = ['12', '24', '36']
valid_values = %w(12 24 36)
else
valid_values = ['1', '2', '3']
valid_values = %w(1 2 3)
end
errors.add(:period, :out_of_range) unless valid_values.include?(period.to_s)
@ -258,7 +258,7 @@ class Domain < ActiveRecord::Base
[:valid_to, :epp_exp_dates_do_not_match]
],
'2004' => [ # Parameter value range error
[:nameservers, :out_of_range, {min: domain_validation_sg.setting(:ns_min_count).value, max: domain_validation_sg.setting(:ns_max_count).value}],
[:nameservers, :out_of_range, { min: domain_validation_sg.setting(:ns_min_count).value, max: domain_validation_sg.setting(:ns_max_count).value }],
[:period, :out_of_range]
],
'2303' => [ # Object does not exist
@ -277,7 +277,7 @@ class Domain < ActiveRecord::Base
# For domain transfer
def authenticate(pw)
errors.add(:auth_info, {msg: errors.generate_message(:auth_info, :wrong_pw)}) if pw != auth_info
errors.add(:auth_info, { msg: errors.generate_message(:auth_info, :wrong_pw) }) if pw != auth_info
errors.empty?
end
@ -351,20 +351,20 @@ class Domain < ActiveRecord::Base
res = []
domains.each do |x|
if !DomainNameValidator.validate_format(x)
res << {name: x, avail: 0, reason: 'invalid format'}
unless DomainNameValidator.validate_format(x)
res << { name: x, avail: 0, reason: 'invalid format' }
next
end
if !DomainNameValidator.validate_reservation(x)
res << {name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved')}
unless DomainNameValidator.validate_reservation(x)
res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') }
next
end
if Domain.find_by(name: x)
res << {name: x, avail: 0, reason: 'in use'}
res << { name: x, avail: 0, reason: 'in use' }
else
res << {name: x, avail: 1}
res << { name: x, avail: 1 }
end
end

View file

@ -1,5 +1,5 @@
class EppUser < ActiveRecord::Base
#TODO should have max request limit per day
# TODO should have max request limit per day
belongs_to :registrar
has_many :contacts
end

View file

@ -1,3 +1,2 @@
class ReservedDomain < ActiveRecord::Base
end

View file

@ -1,7 +1,7 @@
class User < ActiveRecord::Base
#TODO Foreign user will get email with activation link,email,temp-password.
#After activisation, system should require to change temp password.
#TODO Estonian id validation
# TODO Foreign user will get email with activation link,email,temp-password.
# After activisation, system should require to change temp password.
# TODO Estonian id validation
belongs_to :role
end

View file

@ -1,5 +1,5 @@
class DomainNameValidator < ActiveModel::EachValidator
#TODO
# TODO
# validates lenght of 2-63
# validates/honours Estonian additional letters zäõüö
# honours punicode and all interfces honors utf8

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
require_relative '../config/boot'

View file

@ -7,7 +7,7 @@
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)
require 'rubygems'

View file

@ -4,15 +4,15 @@
# It gets overwritten when you run the `spring binstub` command
unless defined?(Spring)
require "rubygems"
require "bundler"
require 'rubygems'
require 'bundler'
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = ""
ENV['GEM_PATH'] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV['GEM_HOME'] = ''
Gem.paths = ENV
gem "spring", match[1]
require "spring/binstub"
gem 'spring', match[1]
require 'spring/binstub'
end
end

View file

@ -1,12 +1,12 @@
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require 'active_model/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems

View file

@ -1 +1 @@
Dir[File.join(Rails.root, "lib", "ext", "*.rb")].each {|x| require x }
Dir[File.join(Rails.root, 'lib', 'ext', '*.rb')].each { |x| require x }

View file

@ -1,8 +1,8 @@
class Init < ActiveRecord::Migration
def change
create_table :domains do |t|
t.string :name #ascii, utf8 will be converted on the fly
t.integer :registrar_id #registripidaja
t.string :name # ascii, utf8 will be converted on the fly
t.integer :registrar_id # registripidaja
t.datetime :registered_at
t.string :status
t.datetime :valid_from
@ -12,17 +12,17 @@ class Init < ActiveRecord::Migration
t.integer :technical_contact_id
t.integer :ns_set_id
t.string :auth_info
#t.integer :keyset_id #dnssec
# t.integer :keyset_id #dnssec
t.timestamps
end
# this will be a huge table?
create_table :contacts do |t|
t.string :code #CID:STRING:OID
t.string :code # CID:STRING:OID
t.string :name
t.string :type #organisation / juridical / citizen #rails specific variable
t.string :reg_no #identity code or registration number for organisation
t.string :type # organisation / juridical / citizen #rails specific variable
t.string :reg_no # identity code or registration number for organisation
# can a person have one or more of these contacts?
t.string :phone
@ -32,11 +32,11 @@ class Init < ActiveRecord::Migration
t.timestamps
end
create_table :addresses do |t| #needs a better name?
create_table :addresses do |t| # needs a better name?
t.integer :contact_id
t.integer :country_id
t.string :city
t.string :address #Street + house + apartment #needs a better name
t.string :address # Street + house + apartment #needs a better name
t.string :zip
t.timestamps
@ -60,7 +60,7 @@ class Init < ActiveRecord::Migration
t.timestamps
end
#legal documents
# legal documents
# create_table :documents do |t|
# t.integer :domain_id
# t.string :name
@ -70,13 +70,13 @@ class Init < ActiveRecord::Migration
# end
create_table :ns_sets do |t|
t.string :code #NSSID:STRING:OID
t.string :code # NSSID:STRING:OID
t.integer :registrar_id
t.string :auth_info #password for transferring between registrants
t.string :auth_info # password for transferring between registrants
t.string :report_level
#t.integer :technical_contact_id # reference to technical contact -
#does each ns_set have spearate technical contacts or can the contacts be inherited from the registrar?
# t.integer :technical_contact_id # reference to technical contact -
# does each ns_set have spearate technical contacts or can the contacts be inherited from the registrar?
t.timestamps
end
@ -94,13 +94,13 @@ class Init < ActiveRecord::Migration
t.timestamps
end
#devise for login
#cancan for securing
#what to do with API users?
# devise for login
# cancan for securing
# what to do with API users?
create_table :users do |t|
t.string :username
t.string :password
t.integer :role_id #can user have more than one role?
t.integer :role_id # can user have more than one role?
t.timestamps
end
@ -117,7 +117,7 @@ class Init < ActiveRecord::Migration
end
create_table :rights do |t|
t.string :code #LOG_IN, SEE_DOMAINS, etc
t.string :code # LOG_IN, SEE_DOMAINS, etc
t.timestamps
end

View file

@ -6,7 +6,7 @@ class CreateEppSessions < ActiveRecord::Migration
t.timestamps
end
add_index :epp_sessions, :session_id, :unique => true
add_index :epp_sessions, :session_id, unique: true
add_index :epp_sessions, :updated_at
end
end

View file

@ -4,7 +4,7 @@ class PopulateSettings < ActiveRecord::Migration
code: 'domain_validation',
settings: [
Setting.create(code: 'ns_min_count', value: 1),
Setting.create(code: 'ns_max_count', value: 13),
Setting.create(code: 'ns_max_count', value: 13)
]
)
end

View file

@ -11,181 +11,181 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140819103517) do
ActiveRecord::Schema.define(version: 20_140_819_103_517) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension 'plpgsql'
create_table "addresses", force: true do |t|
t.integer "contact_id"
t.integer "country_id"
t.string "city"
t.string "street"
t.string "zip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "street2"
t.string "street3"
create_table 'addresses', force: true do |t|
t.integer 'contact_id'
t.integer 'country_id'
t.string 'city'
t.string 'street'
t.string 'zip'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'street2'
t.string 'street3'
end
create_table "contacts", force: true do |t|
t.string "code"
t.string "name"
t.string "type"
t.string "reg_no"
t.string "phone"
t.string "email"
t.string "fax"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ident"
t.string "ident_type"
t.string "org_name"
t.integer "created_by_id"
t.integer "updated_by_id"
t.string "auth_info"
create_table 'contacts', force: true do |t|
t.string 'code'
t.string 'name'
t.string 'type'
t.string 'reg_no'
t.string 'phone'
t.string 'email'
t.string 'fax'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'ident'
t.string 'ident_type'
t.string 'org_name'
t.integer 'created_by_id'
t.integer 'updated_by_id'
t.string 'auth_info'
end
create_table "countries", force: true do |t|
t.string "iso"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'countries', force: true do |t|
t.string 'iso'
t.string 'name'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "domain_contacts", force: true do |t|
t.integer "contact_id"
t.integer "domain_id"
t.string "contact_type"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'domain_contacts', force: true do |t|
t.integer 'contact_id'
t.integer 'domain_id'
t.string 'contact_type'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "domain_statuses", force: true do |t|
t.integer "domain_id"
t.integer "setting_id"
t.string "description"
create_table 'domain_statuses', force: true do |t|
t.integer 'domain_id'
t.integer 'setting_id'
t.string 'description'
end
create_table "domains", force: true do |t|
t.string "name"
t.integer "registrar_id"
t.datetime "registered_at"
t.string "status"
t.datetime "valid_from"
t.datetime "valid_to"
t.integer "owner_contact_id"
t.integer "admin_contact_id"
t.integer "technical_contact_id"
t.integer "ns_set_id"
t.string "auth_info"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name_dirty"
t.string "name_puny"
t.integer "period"
t.string "period_unit", limit: 1
create_table 'domains', force: true do |t|
t.string 'name'
t.integer 'registrar_id'
t.datetime 'registered_at'
t.string 'status'
t.datetime 'valid_from'
t.datetime 'valid_to'
t.integer 'owner_contact_id'
t.integer 'admin_contact_id'
t.integer 'technical_contact_id'
t.integer 'ns_set_id'
t.string 'auth_info'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'name_dirty'
t.string 'name_puny'
t.integer 'period'
t.string 'period_unit', limit: 1
end
create_table "domains_nameservers", force: true do |t|
t.integer "domain_id"
t.integer "nameserver_id"
create_table 'domains_nameservers', force: true do |t|
t.integer 'domain_id'
t.integer 'nameserver_id'
end
create_table "epp_sessions", force: true do |t|
t.string "session_id"
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'epp_sessions', force: true do |t|
t.string 'session_id'
t.text 'data'
t.datetime 'created_at'
t.datetime 'updated_at'
end
add_index "epp_sessions", ["session_id"], name: "index_epp_sessions_on_session_id", unique: true, using: :btree
add_index "epp_sessions", ["updated_at"], name: "index_epp_sessions_on_updated_at", using: :btree
add_index 'epp_sessions', ['session_id'], name: 'index_epp_sessions_on_session_id', unique: true, using: :btree
add_index 'epp_sessions', ['updated_at'], name: 'index_epp_sessions_on_updated_at', using: :btree
create_table "epp_users", force: true do |t|
t.integer "registrar_id"
t.string "username"
t.string "password"
t.boolean "active", default: false
t.text "csr"
t.text "crt"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'epp_users', force: true do |t|
t.integer 'registrar_id'
t.string 'username'
t.string 'password'
t.boolean 'active', default: false
t.text 'csr'
t.text 'crt'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "nameservers", force: true do |t|
t.string "hostname"
t.string "ipv4"
t.integer "ns_set_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ipv6"
create_table 'nameservers', force: true do |t|
t.string 'hostname'
t.string 'ipv4'
t.integer 'ns_set_id'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'ipv6'
end
create_table "nameservers_ns_sets", force: true do |t|
t.integer "nameserver_id"
t.integer "ns_set_id"
create_table 'nameservers_ns_sets', force: true do |t|
t.integer 'nameserver_id'
t.integer 'ns_set_id'
end
create_table "ns_sets", force: true do |t|
t.string "code"
t.integer "registrar_id"
t.string "auth_info"
t.string "report_level"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'ns_sets', force: true do |t|
t.string 'code'
t.integer 'registrar_id'
t.string 'auth_info'
t.string 'report_level'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "registrars", force: true do |t|
t.string "name"
t.string "reg_no"
t.string "vat_no"
t.string "address"
t.integer "country_id"
t.string "billing_address"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'registrars', force: true do |t|
t.string 'name'
t.string 'reg_no'
t.string 'vat_no'
t.string 'address'
t.integer 'country_id'
t.string 'billing_address'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "reserved_domains", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'reserved_domains', force: true do |t|
t.string 'name'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "rights", force: true do |t|
t.string "code"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'rights', force: true do |t|
t.string 'code'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "rights_roles", force: true do |t|
t.integer "right_id"
t.integer "role_id"
create_table 'rights_roles', force: true do |t|
t.integer 'right_id'
t.integer 'role_id'
end
create_table "roles", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'roles', force: true do |t|
t.string 'name'
t.datetime 'created_at'
t.datetime 'updated_at'
end
create_table "setting_groups", force: true do |t|
t.string "code"
create_table 'setting_groups', force: true do |t|
t.string 'code'
end
create_table "settings", force: true do |t|
t.integer "setting_group_id"
t.string "code"
t.string "value"
create_table 'settings', force: true do |t|
t.integer 'setting_group_id'
t.string 'code'
t.string 'value'
end
create_table "users", force: true do |t|
t.string "username"
t.string "password"
t.integer "role_id"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'users', force: true do |t|
t.string 'username'
t.string 'password'
t.integer 'role_id'
t.datetime 'created_at'
t.datetime 'updated_at'
end
end

View file

@ -3,7 +3,7 @@ require 'builder'
class Builder::XmlMarkup
def epp_head
self.instruct!
self.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
yield
end
end

View file

@ -13,7 +13,7 @@ end
desc 'Run all but EPP specs'
RSpec::Core::RakeTask.new('test:other') do |t|
t.rspec_opts = "--tag ~epp"
t.rspec_opts = '--tag ~epp'
end
Rake::Task[:default].prerequisites.clear

View file

@ -1,17 +1,17 @@
require 'rails_helper'
describe 'EPP Contact', epp: true do
let(:server) { Epp::Server.new({server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701}) }
let(:server) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
context 'with valid user' do
before(:each) {
before(:each) do
Fabricate(:epp_user)
Fabricate(:domain_validation_setting_group)
}
end
context 'create command' do
it "fails if request is invalid" do
response = epp_request(contact_create_xml( { authInfo: [false], addr: { cc: false, city: false } } ), :xml)
it 'fails if request is invalid' do
response = epp_request(contact_create_xml({ authInfo: [false], addr: { cc: false, city: false } }), :xml)
expect(response[:results][0][:result_code]).to eq('2003')
expect(response[:results][1][:result_code]).to eq('2003')
@ -52,7 +52,7 @@ describe 'EPP Contact', epp: true do
crDate = response[:parsed].css('resData creData crDate').first
expect(id.text).to eq('sh8013')
#5 seconds for what-ever weird lag reasons might happen
# 5 seconds for what-ever weird lag reasons might happen
expect(crDate.text.to_time).to be_within(5).of(Time.now)
end
@ -69,18 +69,16 @@ describe 'EPP Contact', epp: true do
end
end
context 'update command' do
it "fails if request is invalid" do
it 'fails if request is invalid' do
response = epp_request('contacts/update_missing_attr.xml')
#response = epp_request(contact_update_xml( {id: false} ), :xml)
# response = epp_request(contact_update_xml( {id: false} ), :xml)
expect(response[:results][0][:result_code]).to eq('2003')
expect(response[:results][0][:msg]).to eq('Required parameter missing: id')
expect(response[:results].count).to eq 1
end
it 'fails with wrong authentication info' do
Fabricate(:contact, code: 'sh8013', auth_info: 'secure_password')
@ -102,7 +100,7 @@ describe 'EPP Contact', epp: true do
it 'is succesful' do
Fabricate(:contact, created_by_id: 1, email: 'not_updated@test.test', code: 'sh8013', auth_info: '2fooBAR')
#response = epp_request(contact_update_xml( { chg: { email: 'fred@bloggers.ee', postalInfo: { name: 'Fred Bloggers' } } } ), :xml)
# response = epp_request(contact_update_xml( { chg: { email: 'fred@bloggers.ee', postalInfo: { name: 'Fred Bloggers' } } } ), :xml)
response = epp_request('contacts/update.xml')
expect(response[:msg]).to eq('Command completed successfully')
@ -114,7 +112,7 @@ describe 'EPP Contact', epp: true do
it 'returns phone and email error' do
Fabricate(:contact, created_by_id: 1, email: 'not_updated@test.test', code: 'sh8013', auth_info: '2fooBAR')
#response = epp_request(contact_update_xml( { chg: { email: "qwe", phone: "123qweasd" } }), :xml)
# response = epp_request(contact_update_xml( { chg: { email: "qwe", phone: "123qweasd" } }), :xml)
response = epp_request('contacts/update_with_errors.xml')
expect(response[:results][0][:result_code]).to eq('2005')
@ -126,7 +124,7 @@ describe 'EPP Contact', epp: true do
end
context 'delete command' do
it "fails if request is invalid" do
it 'fails if request is invalid' do
response = epp_request('contacts/delete_missing_attr.xml')
expect(response[:results][0][:result_code]).to eq('2003')
@ -135,7 +133,7 @@ describe 'EPP Contact', epp: true do
end
it 'deletes contact' do
Fabricate(:contact, code: "dwa1234")
Fabricate(:contact, code: 'dwa1234')
response = epp_request('contacts/delete.xml')
expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully')
@ -163,10 +161,9 @@ describe 'EPP Contact', epp: true do
end
end
context 'check command' do
it "fails if request is invalid" do
response = epp_request(contact_check_xml( ids: [ false ] ), :xml)
it 'fails if request is invalid' do
response = epp_request(contact_check_xml(ids: [false]), :xml)
expect(response[:results][0][:result_code]).to eq('2003')
expect(response[:results][0][:msg]).to eq('Required parameter missing: id')
@ -176,7 +173,7 @@ describe 'EPP Contact', epp: true do
it 'returns info about contact availability' do
Fabricate(:contact, code: 'check-1234')
response = epp_request(contact_check_xml( ids: [{ id: 'check-1234'}, { id: 'check-4321' }] ), :xml)
response = epp_request(contact_check_xml(ids: [{ id: 'check-1234' }, { id: 'check-4321' }]), :xml)
expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully')
@ -191,7 +188,7 @@ describe 'EPP Contact', epp: true do
end
context 'info command' do
it "fails if request invalid" do
it 'fails if request invalid' do
response = epp_request('contacts/delete_missing_attr.xml')
expect(response[:results][0][:result_code]).to eq('2003')
@ -207,7 +204,7 @@ describe 'EPP Contact', epp: true do
end
it 'returns info about contact' do
Fabricate(:contact, name: "Johnny Awesome", created_by_id: '1', code: 'info-4444', auth_info: '2fooBAR')
Fabricate(:contact, name: 'Johnny Awesome', created_by_id: '1', code: 'info-4444', auth_info: '2fooBAR')
Fabricate(:address)
response = epp_request('contacts/info.xml')
@ -220,7 +217,7 @@ describe 'EPP Contact', epp: true do
end
it 'doesn\'t display unassociated object' do
Fabricate(:contact, name:"Johnny Awesome", code: 'info-4444')
Fabricate(:contact, name: 'Johnny Awesome', code: 'info-4444')
response = epp_request('contacts/info.xml')
expect(response[:result_code]).to eq('2201')

View file

@ -1,7 +1,7 @@
require 'rails_helper'
describe 'EPP Domain', epp: true do
let(:server) { server = Epp::Server.new({server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701}) }
let(:server) { server = Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
context 'with valid user' do
before(:each) do
@ -30,11 +30,11 @@ describe 'EPP Domain', epp: true do
end
context 'with citizen as an owner' do
before(:each) {
before(:each) do
Fabricate(:contact, code: 'jd1234')
Fabricate(:contact, code: 'sh8013')
Fabricate(:contact, code: 'sh801333')
}
end
it 'creates a domain' do
response = epp_request(domain_create_xml, :xml)
@ -88,7 +88,7 @@ describe 'EPP Domain', epp: true do
it 'does not create domain with too many nameservers' do
nameservers = []
14.times {|i| nameservers << {hostObj: "ns#{i}.example.net"}}
14.times { |i| nameservers << { hostObj: "ns#{i}.example.net" } }
xml = domain_create_xml(nameservers: nameservers)
response = epp_request(xml, :xml)
@ -97,7 +97,7 @@ describe 'EPP Domain', epp: true do
end
it 'returns error when invalid nameservers are present' do
xml = domain_create_xml(nameservers: [{hostObj: 'invalid1-'}, {hostObj: '-invalid2'}])
xml = domain_create_xml(nameservers: [{ hostObj: 'invalid1-' }, { hostObj: '-invalid2' }])
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('2005')
@ -144,14 +144,14 @@ describe 'EPP Domain', epp: true do
end
context 'with juridical persion as an owner' do
before(:each) {
before(:each) do
Fabricate(:contact, code: 'jd1234', ident_type: 'ico')
Fabricate(:contact, code: 'sh8013')
Fabricate(:contact, code: 'sh801333')
}
end
it 'creates a domain with contacts' do
xml = domain_create_xml(contacts: [{contact_value: 'sh8013', contact_type: 'admin'}])
xml = domain_create_xml(contacts: [{ contact_value: 'sh8013', contact_type: 'admin' }])
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('1000')
@ -166,7 +166,7 @@ describe 'EPP Domain', epp: true do
end
it 'does not create a domain without admin contact' do
xml = domain_create_xml(contacts: [{contact_value: 'sh8013', contact_type: 'tech'}])
xml = domain_create_xml(contacts: [{ contact_value: 'sh8013', contact_type: 'tech' }])
response = epp_request(xml, :xml)
expect(response[:result_code]).to eq('2306')
@ -217,12 +217,12 @@ describe 'EPP Domain', epp: true do
expect(inf_data.css('name').text).to eq('example.ee')
expect(inf_data.css('registrant').text).to eq(d.owner_contact_code)
admin_contacts_from_request = inf_data.css('contact[type="admin"]').collect{|x| x.text }
admin_contacts_from_request = inf_data.css('contact[type="admin"]').map { |x| x.text }
admin_contacts_existing = d.admin_contacts.pluck(:code)
expect(admin_contacts_from_request).to eq(admin_contacts_existing)
hosts_from_request = inf_data.css('hostObj').collect{|x| x.text }
hosts_from_request = inf_data.css('hostObj').map { |x| x.text }
hosts_existing = d.nameservers.pluck(:hostname)
expect(hosts_from_request).to eq(hosts_existing)

View file

@ -64,12 +64,12 @@ describe 'EPP Helper', epp: true do
name: 'one.ee',
period_value: '345',
period_unit: 'd',
nameservers: [{hostObj: 'ns1.test.net'}, {hostObj: 'ns2.test.net'}],
nameservers: [{ hostObj: 'ns1.test.net' }, { hostObj: 'ns2.test.net' }],
registrant: '32fsdaf',
contacts: [
{contact_value: '2323rafaf', contact_type: 'admin'},
{contact_value: '3dgxx', contact_type: 'tech'},
{contact_value: '345xxv', contact_type: 'tech'}
{ contact_value: '2323rafaf', contact_type: 'admin' },
{ contact_value: '3dgxx', contact_type: 'tech' },
{ contact_value: '345xxv', contact_type: 'tech' }
],
pw: 'sdgdgd4esfsa'
)
@ -124,7 +124,6 @@ describe 'EPP Helper', epp: true do
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_info_xml).to_s.squish
expect(generated).to eq(expected)
@ -145,7 +144,6 @@ describe 'EPP Helper', epp: true do
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub', pw: 'b3rafsla')).to_s.squish
expect(generated).to eq(expected)
end
@ -165,7 +163,6 @@ describe 'EPP Helper', epp: true do
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_check_xml).to_s.squish
expect(generated).to eq(expected)
@ -185,7 +182,6 @@ describe 'EPP Helper', epp: true do
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_check_xml(names: ['example.ee', 'example2.ee', 'example3.ee'])).to_s.squish
expect(generated).to eq(expected)
end
@ -207,7 +203,6 @@ describe 'EPP Helper', epp: true do
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_renew_xml).to_s.squish
expect(generated).to eq(expected)
@ -227,7 +222,6 @@ describe 'EPP Helper', epp: true do
</epp>
').to_s.squish
generated = Nokogiri::XML(domain_renew_xml(name: 'one.ee', curExpDate: '2009-11-15', period_value: '365', period_unit: 'd')).to_s.squish
expect(generated).to eq(expected)
end

View file

@ -1,7 +1,7 @@
require 'rails_helper'
describe 'EPP Session', epp: true do
let(:server) { server = Epp::Server.new({server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701}) }
let(:server) { server = Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
context 'when not connected' do
it 'greets client upon connection' do

View file

@ -1,4 +1,4 @@
Fabricator(:epp_session) do
session_id 'test'
data { {epp_user_id: 1} }
data { { epp_user_id: 1 } }
end

View file

@ -1,23 +1,29 @@
Fabricator(:setting_group) do
code 'domain_validation'
settings { [
settings do
[
Fabricate(:setting, code: 'ns_min_count', value: 1),
Fabricate(:setting, code: 'ns_max_count', value: 13)
]}
]
end
end
Fabricator(:domain_validation_setting_group, from: :setting_group) do
code 'domain_validation'
settings { [
settings do
[
Fabricate(:setting, code: 'ns_min_count', value: 1),
Fabricate(:setting, code: 'ns_max_count', value: 13)
]}
]
end
end
Fabricator(:domain_statuses_setting_group, from: :setting_group) do
code 'domain_statuses'
settings { [
settings do
[
Fabricate(:setting, code: 'client_hold', value: 'clientHold'),
Fabricate(:setting, code: 'client_update_prohibited', value: 'clientUpdateProhibited')
]}
]
end
end

View file

@ -1,22 +1,19 @@
require "rails_helper"
require 'rails_helper'
describe Address do
it { should belong_to(:contact) }
it { should belong_to(:country) }
end
describe Address, '.extract_params' do
it 'returns params hash'do
Fabricate(:country, iso:'EE')
ph = { postalInfo: { name: "fred", addr: { cc: 'EE', city: 'Village', street: [ 'street1', 'street2' ] } } }
expect(Address.extract_attributes(ph[:postalInfo][:addr])).to eq( {
Fabricate(:country, iso: 'EE')
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
expect(Address.extract_attributes(ph[:postalInfo][:addr])).to eq({
city: 'Village',
country_id: 1,
street: 'street1',
street2: 'street2'
} )
})
end
end

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe Contact do
it { should have_one(:address) }
@ -7,12 +7,12 @@ describe Contact do
before(:each) { @contact = Fabricate(:contact) }
it 'phone should return false' do
@contact.phone = "32341"
@contact.phone = '32341'
expect(@contact.valid?).to be false
end
it 'ident should return false' do
@contact.ident = "123abc"
@contact.ident = '123abc'
expect(@contact.valid?).to be false
end
@ -21,11 +21,11 @@ describe Contact do
expect(@contact.valid?).to eq false
expect(@contact.errors.messages).to match_array({
:code=>["Required parameter missing - code"],
:name=>["Required parameter missing - name"],
:phone=>["Required parameter missing - phone", "Phone nr is invalid"],
:email=>["Required parameter missing - email", "Email is invalid"],
:ident=>["Required parameter missing - ident"]
code: ['Required parameter missing - code'],
name: ['Required parameter missing - name'],
phone: ['Required parameter missing - phone', 'Phone nr is invalid'],
email: ['Required parameter missing - email', 'Email is invalid'],
ident: ['Required parameter missing - ident']
})
end
end
@ -60,7 +60,7 @@ describe Contact, '#relations_with_domain?' do
end
describe Contact, '#crID' do
before(:each) { Fabricate(:contact, code: "asd12", created_by: Fabricate(:epp_user)) }
before(:each) { Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user)) }
it 'should return username of creator' do
expect(Contact.first.crID).to eq('gitlab')
@ -71,9 +71,8 @@ describe Contact, '#crID' do
end
end
describe Contact, '#upID' do
before(:each) { Fabricate(:contact, code: "asd12", created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user)) }
before(:each) { Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user)) }
it 'should return username of updater' do
expect(Contact.first.upID).to eq('gitlab')
@ -84,45 +83,42 @@ describe Contact, '#upID' do
end
end
describe Contact, '.extract_params' do
it 'returns params hash'do
ph = { id: '123123', email: 'jdoe@example.com', postalInfo: { name: "fred", addr: { cc: 'EE' } } }
expect(Contact.extract_attributes(ph)).to eq( {
ph = { id: '123123', email: 'jdoe@example.com', postalInfo: { name: 'fred', addr: { cc: 'EE' } } }
expect(Contact.extract_attributes(ph)).to eq({
code: '123123',
email: 'jdoe@example.com',
name: 'fred'
} )
})
end
end
describe Contact, '.check_availability' do
before(:each) {
Fabricate(:contact, code: "asd12")
Fabricate(:contact, code: "asd13")
}
before(:each) do
Fabricate(:contact, code: 'asd12')
Fabricate(:contact, code: 'asd13')
end
it 'should return array if argument is string' do
response = Contact.check_availability("asd12")
response = Contact.check_availability('asd12')
expect(response.class).to be Array
expect(response.length).to eq(1)
end
it 'should return in_use and available codes' do
response = Contact.check_availability(["asd12","asd13","asd14"])
response = Contact.check_availability(%w(asd12 asd13 asd14))
expect(response.class).to be Array
expect(response.length).to eq(3)
expect(response[0][:avail]).to eq(0)
expect(response[0][:code]).to eq("asd12")
expect(response[0][:code]).to eq('asd12')
expect(response[1][:avail]).to eq(0)
expect(response[1][:code]).to eq("asd13")
expect(response[1][:code]).to eq('asd13')
expect(response[2][:avail]).to eq(1)
expect(response[2][:code]).to eq("asd14")
expect(response[2][:code]).to eq('asd14')
end
end

View file

@ -1,8 +1,8 @@
require "rails_helper"
require 'rails_helper'
describe Domain do
it { should belong_to(:registrar) }
it { should have_and_belong_to_many(:nameservers)}
it { should have_and_belong_to_many(:nameservers) }
it { should belong_to(:owner_contact) }
it { should have_many(:tech_contacts) }
it { should have_many(:admin_contacts) }
@ -44,9 +44,9 @@ describe Domain do
expect(d.errors.messages).to match_array({
name: ['is missing'],
period: ['is not a number'],
owner_contact: ["Registrant is missing"],
admin_contacts: ["Admin contact is missing"],
nameservers: ["Nameservers count must be between 1-13"]
owner_contact: ['Registrant is missing'],
admin_contacts: ['Admin contact is missing'],
nameservers: ['Nameservers count must be between 1-13']
})
sg = SettingGroup.domain_validation

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe EppSession do
let(:epp_session) { Fabricate(:epp_session) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe EppUser do
it { should belong_to(:registrar) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe Nameserver do
it { should have_and_belong_to_many(:domains) }

View file

@ -1,6 +1,6 @@
require "rails_helper"
require 'rails_helper'
describe NsSet do
it { should belong_to(:registrar)}
it { should belong_to(:registrar) }
it { should have_and_belong_to_many(:nameservers) }
end

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe Registrar do
it { should belong_to(:country) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe Right do
it { should have_and_belong_to_many(:roles) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe Role do
it { should have_and_belong_to_many(:rights) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe SettingGroup do
it { should have_many(:settings) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe Setting do
it { should belong_to(:setting_group) }

View file

@ -1,4 +1,4 @@
require "rails_helper"
require 'rails_helper'
describe User do
it { should belong_to(:role) }

View file

@ -1,7 +1,7 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'shoulda/matchers'
require 'capybara/poltergeist'
@ -13,7 +13,7 @@ require 'capybara/poltergeist'
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.

View file

@ -14,65 +14,63 @@
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
expectations.syntax = :expect
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
mocks.syntax = :expect
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended.
mocks.verify_partial_doubles = true
end
=end
RSpec.configure do |_config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# # These two settings work together to allow you to limit a spec run
# # to individual examples or groups you care about by tagging them with
# # `:focus` metadata. When nothing is tagged with `:focus`, all examples
# # get run.
# config.filter_run :focus
# config.run_all_when_everything_filtered = true
#
# # Many RSpec users commonly either run the entire suite or an individual
# # file, and it's useful to allow more verbose output when running an
# # individual spec file.
# if config.files_to_run.one?
# # Use the documentation formatter for detailed output,
# # unless a formatter has already been configured
# # (e.g. via a command-line flag).
# config.default_formatter = 'doc'
# end
#
# # Print the 10 slowest examples and example groups at the
# # end of the spec run, to help surface which specs are running
# # particularly slow.
# config.profile_examples = 10
#
# # Run specs in random order to surface order dependencies. If you find an
# # order dependency and want to debug it, you can fix the order by providing
# # the seed, which is printed after each run.
# # --seed 1234
# config.order = :random
#
# # Seed global randomization in this process using the `--seed` CLI option.
# # Setting this allows you to use `--seed` to deterministically reproduce
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed
#
# # rspec-expectations config goes here. You can use an alternate
# # assertion/expectation library such as wrong or the stdlib/minitest
# # assertions if you prefer.
# config.expect_with :rspec do |expectations|
# # Enable only the newer, non-monkey-patching expect syntax.
# # For more details, see:
# # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
# expectations.syntax = :expect
# end
#
# # rspec-mocks config goes here. You can use an alternate test double
# # library (such as bogus or mocha) by changing the `mock_with` option here.
# config.mock_with :rspec do |mocks|
# # Enable only the newer, non-monkey-patching expect syntax.
# # For more details, see:
# # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# mocks.syntax = :expect
#
# # Prevents you from mocking or stubbing a method that does not exist on
# # a real object. This is generally recommended.
# mocks.verify_partial_doubles = true
# end
end

View file

@ -1,28 +1,24 @@
module Epp
def read_body filename
def read_body(filename)
File.read("spec/epp/requests/#{filename}")
end
# handles connection and login automatically
def epp_request(data, type=:filename)
begin
def epp_request(data, type = :filename)
return parse_response(server.request(read_body(data))) if type == :filename
return parse_response(server.request(data))
rescue Exception => e
rescue => e
e
end
end
def epp_plain_request(data, type=:filename)
begin
def epp_plain_request(data, type = :filename)
return parse_response(server.send_request(read_body(data))) if type == :filename
return parse_response(server.send_request(data))
rescue Exception => e
rescue => e
e
end
end
def parse_response raw
def parse_response(raw)
res = Nokogiri::XML(raw)
obj = {
@ -33,7 +29,7 @@ module Epp
}
res.css('epp response result').each do |x|
obj[:results] << {result_code: x[:code], msg: x.css('msg').text, value: x.css('value > *').try(:first).try(:text)}
obj[:results] << { result_code: x[:code], msg: x.css('msg').text, value: x.css('value > *').try(:first).try(:text) }
end
obj[:result_code] = obj[:results][0][:result_code]
@ -42,26 +38,26 @@ module Epp
obj
end
#print output
# print output
def po(r)
puts r[:parsed].to_s
end
### REQUEST TEMPLATES ###
def domain_create_xml(xml_params={})
xml_params[:nameservers] = xml_params[:nameservers] || [{hostObj: 'ns1.example.net'}, {hostObj: 'ns2.example.net'}]
def domain_create_xml(xml_params = {})
xml_params[:nameservers] = xml_params[:nameservers] || [{ hostObj: 'ns1.example.net' }, { hostObj: 'ns2.example.net' }]
xml_params[:contacts] = xml_params[:contacts] || [
{contact_value: 'sh8013', contact_type: 'admin'},
{contact_value: 'sh8013', contact_type: 'tech'},
{contact_value: 'sh801333', contact_type: 'tech'}
{ contact_value: 'sh8013', contact_type: 'admin' },
{ contact_value: 'sh8013', contact_type: 'tech' },
{ contact_value: 'sh801333', contact_type: 'tech' }
]
# {hostAttr: {hostName: 'ns1.example.net', hostAddr_value: '192.0.2.2', hostAddr_ip}}
xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no')
xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do
xml.create do
@ -93,10 +89,10 @@ module Epp
end
end
def domain_renew_xml(xml_params={})
def domain_renew_xml(xml_params = {})
xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no')
xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do
xml.renew do
@ -111,11 +107,11 @@ module Epp
end
end
def domain_check_xml(xml_params={})
def domain_check_xml(xml_params = {})
xml_params[:names] = xml_params[:names] || ['example.ee']
xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no')
xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do
xml.check do
@ -130,14 +126,14 @@ module Epp
end
end
def domain_info_xml(xml_params={})
def domain_info_xml(xml_params = {})
xml_params[:name_value] = xml_params[:name_value] || 'example.ee'
xml_params[:name_hosts] = xml_params[:name_hosts] || 'all'
xml_params[:pw] = xml_params[:pw] || '2fooBAR'
xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no')
xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do
xml.info do

View file

@ -1,8 +1,6 @@
module EppContactXmlBuilder
def contact_check_xml(xml_params={})
xml_params[:ids] = xml_params[:ids] || [ { id: 'check-1234' }, { id: 'check-4321' } ]
def contact_check_xml(xml_params = {})
xml_params[:ids] = xml_params[:ids] || [{ id: 'check-1234' }, { id: 'check-4321' }]
xml = Builder::XmlMarkup.new
@ -23,15 +21,14 @@ module EppContactXmlBuilder
end
end
def contact_create_xml(xml_params={})
#xml_params[:ids] = xml_params[:ids] || [ { id: 'check-1234' }, { id: 'check-4321' } ]
def contact_create_xml(xml_params = {})
# xml_params[:ids] = xml_params[:ids] || [ { id: 'check-1234' }, { id: 'check-4321' } ]
xml = Builder::XmlMarkup.new
xml_params[:addr] = xml_params[:addr] || { street: '123 Example Dr.', street2: 'Suite 100', street3: nil,
city: 'Megaton' , sp: 'F3 ' , pc: '201-33' , cc: 'EE' }
city: 'Megaton', sp: 'F3 ', pc: '201-33', cc: 'EE' }
xml_params[:authInfo] = xml_params[:authInfo] || { pw: 'Aas34fq' }
xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do
@ -40,31 +37,31 @@ module EppContactXmlBuilder
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: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: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]
xml.tag!('contact:addr') do
xml.tag!('contact:street', xml_params[:addr][:street] ) unless xml_params[:addr][:street] == false
xml.tag!('contact:street', xml_params[:addr][:street2] ) unless xml_params[:addr][:street2] == false
xml.tag!('contact:street', xml_params[:addr][:street3] ) unless xml_params[:addr][:street3] == false
xml.tag!('contact:city' , xml_params[:addr][:city] ) unless xml_params[:addr][:city] == false
xml.tag!('contact:sp' , xml_params[:addr][:sp] ) unless xml_params[:addr][:sp] == false
xml.tag!('contact:pc' , xml_params[:addr][:pc] ) unless xml_params[:addr][:pc] == false
xml.tag!('contact:cc' , xml_params[:addr][:cc] ) unless xml_params[:addr][:cc] == false
xml.tag!('contact:street', xml_params[:addr][:street]) unless xml_params[:addr][:street] == false
xml.tag!('contact:street', xml_params[:addr][:street2]) unless xml_params[:addr][:street2] == false
xml.tag!('contact:street', xml_params[:addr][:street3]) unless xml_params[:addr][:street3] == false
xml.tag!('contact:city', xml_params[:addr][:city]) unless xml_params[:addr][:city] == false
xml.tag!('contact:sp', xml_params[:addr][:sp]) unless xml_params[:addr][:sp] == false
xml.tag!('contact:pc', xml_params[:addr][:pc]) unless xml_params[:addr][:pc] == false
xml.tag!('contact:cc', xml_params[:addr][:cc]) unless xml_params[:addr][:cc] == false
end
end
end
end
xml.tag!('contact:voice', (xml_params[:voice] || '+372.1234567')) unless xml_params[:voice] == false
xml.tag!('contact:fax', (xml_params[:fax] || '123123' )) unless xml_params[:fax] == false
xml.tag!('contact:fax', (xml_params[:fax] || '123123')) unless xml_params[:fax] == false
xml.tag!('contact:email', (xml_params[:email] || 'example@test.example')) unless xml_params[:email] == false
xml.tag!('contact:ident', (xml_params[:ident] || '37605030299'), type: 'op') unless xml_params[:ident] == false
unless xml_params[:authInfo] == [false]
xml.tag!('contact:authInfo') do
xml.tag!('contact:pw', xml_params[:authInfo][:pw] ) unless xml_params[:authInfo][:pw] == false
xml.tag!('contact:pw', xml_params[:authInfo][:pw]) unless xml_params[:authInfo][:pw] == false
end
end
#Disclosure logic
# Disclosure logic
end
end
xml.clTRID 'ABC-12345'
@ -72,20 +69,20 @@ module EppContactXmlBuilder
end
end
#CONTACT UPDATE NEEDS WORK USE ON YOUR OWN RISK
def contact_update_xml(xml_params={})
# CONTACT UPDATE NEEDS WORK USE ON YOUR OWN RISK
def contact_update_xml(xml_params = {})
xml = Builder::XmlMarkup.new
#postalInfo = xml_params.try(:chg).try(:postalInfo)
#addr = postalInfo.try(:addr)
# postalInfo = xml_params.try(:chg).try(:postalInfo)
# addr = postalInfo.try(:addr)
postalInfo = xml_params[:chg][:postalInfo] rescue nil
addr = postalInfo[:addr] rescue nil
if !addr
unless addr
addr = { street: 'Downtown', city: 'Stockholm', cc: 'SE' }
end
if !postalInfo
unless postalInfo
postalInfo = { name: 'Jane Doe', org: 'Fake Inc.', voice: '+321.12345', fax: '12312312', addr: addr }
end
@ -96,37 +93,36 @@ module EppContactXmlBuilder
xml_params[:chg][:authInfo] = xml_params[:chg][:authInfo] || { pw: 'ccds4324pok' }
xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do
xml.update do
xml.tag!('contact:update', '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[:chg] == [ false ]
xml.tag!('contact:id', (xml_params[:id] || 'sh8013')) unless xml_params[:id] == false
unless xml_params[:chg] == [false]
xml.tag!('contact:chg') do
xml.tag!('contact:voice', xml_params[:chg][:phone] || '+123.321123' ) unless xml_params[:chg][:phone] == false
xml.tag!('contact:email', xml_params[:chg][:email] || 'jane@doe.com' ) unless xml_params[:chg][:email] == false
xml.tag!('contact:voice', xml_params[:chg][:phone] || '+123.321123') unless xml_params[:chg][:phone] == false
xml.tag!('contact:email', xml_params[:chg][:email] || 'jane@doe.com') unless xml_params[:chg][:email] == false
unless xml_params[:chg][:postalInfo] == false
xml.tag!('contact:postalInfo') do
xml.tag!('contact:name', xml_params[:chg][:postalInfo][:name] ) unless xml_params[:chg][:postalInfo][:name] == false
xml.tag!('contact:org', xml_params[:chg][:postalInfo][:org] ) unless xml_params[:chg][:postalInfo][:org] == false
xml.tag!('contact:name', xml_params[:chg][:postalInfo][:name]) unless xml_params[:chg][:postalInfo][:name] == false
xml.tag!('contact:org', xml_params[:chg][:postalInfo][:org]) unless xml_params[:chg][:postalInfo][:org] == false
unless xml_params[:chg][:postalInfo][:addr] == false
xml.tag!('contact:addr') do
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street] ) unless xml_params[:chg][:postalInfo][:addr][:street] == false
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street2] ) unless xml_params[:chg][:postalInfo][:addr][:street2] == false
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street3] ) unless xml_params[:chg][:postalInfo][:addr][:street3] == false
xml.tag!('contact:city' , xml_params[:chg][:postalInfo][:addr][:city] ) unless xml_params[:chg][:postalInfo][:addr][:city] == false
xml.tag!('contact:sp' , xml_params[:chg][:postalInfo][:addr][:sp] ) unless xml_params[:chg][:postalInfo][:addr][:sp] == false
xml.tag!('contact:pc' , xml_params[:chg][:postalInfo][:addr][:pc] ) unless xml_params[:chg][:postalInfo][:addr][:pc] == false
xml.tag!('contact:cc' , xml_params[:chg][:postalInfo][:addr][:cc] ) unless xml_params[:chg][:postalInfo][:addr][:cc] == false
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street]) unless xml_params[:chg][:postalInfo][:addr][:street] == false
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street2]) unless xml_params[:chg][:postalInfo][:addr][:street2] == false
xml.tag!('contact:street', xml_params[:chg][:postalInfo][:addr][:street3]) unless xml_params[:chg][:postalInfo][:addr][:street3] == false
xml.tag!('contact:city', xml_params[:chg][:postalInfo][:addr][:city]) unless xml_params[:chg][:postalInfo][:addr][:city] == false
xml.tag!('contact:sp', xml_params[:chg][:postalInfo][:addr][:sp]) unless xml_params[:chg][:postalInfo][:addr][:sp] == false
xml.tag!('contact:pc', xml_params[:chg][:postalInfo][:addr][:pc]) unless xml_params[:chg][:postalInfo][:addr][:pc] == false
xml.tag!('contact:cc', xml_params[:chg][:postalInfo][:addr][:cc]) unless xml_params[:chg][:postalInfo][:addr][:cc] == false
end
end
end
end
unless xml_params[:chg][:authInfo] == [false]
xml.tag!('contact:authInfo') do
xml.tag!('contact:pw', xml_params[:chg][:authInfo][:pw] ) unless xml_params[:chg][:authInfo][:pw] == false
xml.tag!('contact:pw', xml_params[:chg][:authInfo][:pw]) unless xml_params[:chg][:authInfo][:pw] == false
end
end
end