mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Merge branch 'master' of github.com:internetee/registry
Conflicts: db/schema.rb
This commit is contained in:
commit
4e8b100f5c
19 changed files with 297 additions and 112 deletions
4
Gemfile
4
Gemfile
|
@ -70,10 +70,6 @@ gem 'therubyracer', platforms: :ruby
|
||||||
# for settings
|
# for settings
|
||||||
gem 'rails-settings-cached', '0.4.1'
|
gem 'rails-settings-cached', '0.4.1'
|
||||||
|
|
||||||
# for scp to whois server
|
|
||||||
gem 'net-ssh'
|
|
||||||
gem 'net-scp'
|
|
||||||
|
|
||||||
# delayed job
|
# delayed job
|
||||||
gem 'delayed_job_active_record', '~> 4.0.2'
|
gem 'delayed_job_active_record', '~> 4.0.2'
|
||||||
# to process delayed jobs
|
# to process delayed jobs
|
||||||
|
|
|
@ -171,9 +171,6 @@ GEM
|
||||||
mini_portile (0.6.0)
|
mini_portile (0.6.0)
|
||||||
minitest (5.4.3)
|
minitest (5.4.3)
|
||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
net-scp (1.2.1)
|
|
||||||
net-ssh (>= 2.6.5)
|
|
||||||
net-ssh (2.9.1)
|
|
||||||
nokogiri (1.6.2.1)
|
nokogiri (1.6.2.1)
|
||||||
mini_portile (= 0.6.0)
|
mini_portile (= 0.6.0)
|
||||||
nprogress-rails (0.1.3.1)
|
nprogress-rails (0.1.3.1)
|
||||||
|
@ -387,8 +384,6 @@ DEPENDENCIES
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
kaminari (~> 0.16.1)
|
kaminari (~> 0.16.1)
|
||||||
net-scp
|
|
||||||
net-ssh
|
|
||||||
nokogiri (~> 1.6.2.1)
|
nokogiri (~> 1.6.2.1)
|
||||||
nprogress-rails (~> 0.1.3.1)
|
nprogress-rails (~> 0.1.3.1)
|
||||||
paper_trail (~> 3.0.5)
|
paper_trail (~> 3.0.5)
|
||||||
|
|
|
@ -38,6 +38,9 @@ module Epp::ContactsHelper
|
||||||
def info_contact
|
def info_contact
|
||||||
handle_errors(@contact) and return unless @contact
|
handle_errors(@contact) and return unless @contact
|
||||||
handle_errors(@contact) and return unless rights?
|
handle_errors(@contact) and return unless rights?
|
||||||
|
@disclosure = ContactDisclosure.default_values.merge(@contact.disclosure.as_hash)
|
||||||
|
@disclosure_policy = @contact.disclosure.attributes_with_flag
|
||||||
|
@owner = owner?(false)
|
||||||
render 'epp/contacts/info'
|
render 'epp/contacts/info'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,14 +57,10 @@ module Epp::ContactsHelper
|
||||||
def validate_contact_create_request
|
def validate_contact_create_request
|
||||||
@ph = params_hash['epp']['command']['create']['create']
|
@ph = params_hash['epp']['command']['create']['create']
|
||||||
return false unless validate_params
|
return false unless validate_params
|
||||||
# xml_attrs_present?(@ph, [%w(postalInfo)])
|
|
||||||
xml_attrs_present?(@ph, [%w(postalInfo name), %w(postalInfo addr city), %w(postalInfo addr cc),
|
xml_attrs_present?(@ph, [%w(postalInfo name), %w(postalInfo addr city), %w(postalInfo addr cc),
|
||||||
%w(ident), %w(voice), %w(email)])
|
%w(ident), %w(voice), %w(email)])
|
||||||
|
|
||||||
epp_errors.empty? # unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
|
epp_errors.empty?
|
||||||
|
|
||||||
# (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
|
end
|
||||||
|
|
||||||
## UPDATE
|
## UPDATE
|
||||||
|
@ -118,10 +117,10 @@ module Epp::ContactsHelper
|
||||||
contact
|
contact
|
||||||
end
|
end
|
||||||
|
|
||||||
def owner?
|
def owner?(with_errors = true)
|
||||||
return false unless find_contact
|
return false unless find_contact
|
||||||
# return true if current_epp_user.registrar == find_contact.created_by.try(:registrar)
|
|
||||||
return true if @contact.registrar == current_epp_user.registrar
|
return true if @contact.registrar == current_epp_user.registrar
|
||||||
|
return false unless with_errors
|
||||||
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
|
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -132,14 +131,14 @@ module Epp::ContactsHelper
|
||||||
return true if current_epp_user.try(:registrar) == @contact.try(:registrar)
|
return true if current_epp_user.try(:registrar) == @contact.try(:registrar)
|
||||||
return true if pw && @contact.auth_info_matches(pw) # @contact.try(:auth_info_matches, pw)
|
return true if pw && @contact.auth_info_matches(pw) # @contact.try(:auth_info_matches, pw)
|
||||||
|
|
||||||
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error'), value: { obj: 'pw', val: pw } }
|
epp_errors << { code: '2200', msg: t('errors.messages.epp_authentication_error') }
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_rights?
|
def update_rights?
|
||||||
pw = @ph.try(:[], :authInfo).try(:[], :pw)
|
pw = @ph.try(:[], :authInfo).try(:[], :pw)
|
||||||
return true if pw && @contact.auth_info_matches(pw)
|
return true if pw && @contact.auth_info_matches(pw)
|
||||||
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error'), value: { obj: 'pw', val: pw } }
|
epp_errors << { code: '2200', msg: t('errors.messages.epp_authentication_error') }
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ module Epp::ContactsHelper
|
||||||
case type
|
case type
|
||||||
when :update
|
when :update
|
||||||
# TODO: support for rem/add
|
# TODO: support for rem/add
|
||||||
contact_hash = merge_attribute_hash(@ph[:chg], type)
|
contact_hash = merge_attribute_hash(@ph[:chg], type).delete_if { |_k, v| v.empty? }
|
||||||
else
|
else
|
||||||
contact_hash = merge_attribute_hash(@ph, type)
|
contact_hash = merge_attribute_hash(@ph, type)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Contact < ActiveRecord::Base
|
||||||
include EppErrors
|
include EppErrors
|
||||||
|
|
||||||
has_one :address, dependent: :destroy
|
has_one :address, dependent: :destroy
|
||||||
has_one :disclosure, class_name: 'ContactDisclosure'
|
has_one :disclosure, class_name: 'ContactDisclosure', dependent: :destroy
|
||||||
|
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
has_many :domains, through: :domain_contacts
|
has_many :domains, through: :domain_contacts
|
||||||
|
@ -37,6 +37,7 @@ class Contact < ActiveRecord::Base
|
||||||
after_destroy :domains_snapshot
|
after_destroy :domains_snapshot
|
||||||
before_create :generate_code
|
before_create :generate_code
|
||||||
before_create :generate_auth_info
|
before_create :generate_auth_info
|
||||||
|
after_create :ensure_disclosure
|
||||||
|
|
||||||
# scopes
|
# scopes
|
||||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||||
|
@ -63,6 +64,10 @@ class Contact < ActiveRecord::Base
|
||||||
errors.add(:ident, 'bad format') unless code.valid?
|
errors.add(:ident, 'bad format') unless code.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ensure_disclosure
|
||||||
|
create_disclosure! unless disclosure
|
||||||
|
end
|
||||||
|
|
||||||
def domains_snapshot
|
def domains_snapshot
|
||||||
(domains + domains_owned).uniq.each do |domain|
|
(domains + domains_owned).uniq.each do |domain|
|
||||||
next unless domain.is_a?(Domain)
|
next unless domain.is_a?(Domain)
|
||||||
|
|
|
@ -1,9 +1,39 @@
|
||||||
class ContactDisclosure < ActiveRecord::Base
|
class ContactDisclosure < ActiveRecord::Base
|
||||||
belongs_to :contact
|
belongs_to :contact
|
||||||
|
|
||||||
|
def attributes_with_flag
|
||||||
|
attrs, policy = { name: name, email: email, phone: phone, address: address, org_name: org_name, fax: fax }, {}
|
||||||
|
policy[0] = attrs.map { |k, v| k if v == false }.compact
|
||||||
|
policy[1] = attrs.map { |k, v| k if v }.compact
|
||||||
|
policy
|
||||||
|
end
|
||||||
|
|
||||||
|
def as_hash
|
||||||
|
{
|
||||||
|
name: name,
|
||||||
|
org_name: org_name,
|
||||||
|
phone: phone,
|
||||||
|
fax: fax,
|
||||||
|
email: email,
|
||||||
|
address: address
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# value is true or false depending on disclosure flag
|
# value is true or false depending on disclosure flag
|
||||||
# rules are the contents of disclose element
|
# rules are the contents of disclose element
|
||||||
class << self
|
class << self
|
||||||
|
def default_values
|
||||||
|
@dc = {
|
||||||
|
name: Setting.disclosure_name,
|
||||||
|
org_name: Setting.disclosure_org_name,
|
||||||
|
phone: Setting.disclosure_phone,
|
||||||
|
fax: Setting.disclosure_fax,
|
||||||
|
email: Setting.disclosure_email,
|
||||||
|
address: Setting.disclosure_address
|
||||||
|
}
|
||||||
|
@dc
|
||||||
|
end
|
||||||
|
|
||||||
def extract_attributes(parsed_frame)
|
def extract_attributes(parsed_frame)
|
||||||
disclosure_hash = {}
|
disclosure_hash = {}
|
||||||
rules = parsed_frame.css('disclose').first
|
rules = parsed_frame.css('disclose').first
|
||||||
|
@ -11,7 +41,7 @@ class ContactDisclosure < ActiveRecord::Base
|
||||||
value = rules.attributes['flag'].value
|
value = rules.attributes['flag'].value
|
||||||
disclosure_hash = parse_disclose_xml(rules)
|
disclosure_hash = parse_disclose_xml(rules)
|
||||||
|
|
||||||
disclosure_hash.each do |k, _v|
|
disclosure_hash.each do |k, _v| # provides a correct flag to disclosure elements
|
||||||
disclosure_hash[k] = value
|
disclosure_hash[k] = value
|
||||||
end
|
end
|
||||||
disclosure_hash
|
disclosure_hash
|
||||||
|
@ -19,27 +49,19 @@ class ContactDisclosure < ActiveRecord::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Returns list of disclosure elements present.
|
||||||
def parse_disclose_xml(rules)
|
def parse_disclose_xml(rules)
|
||||||
{ int_name: parse_element_attributes_for('name', rules.children, 'int'),
|
{ name: parse_element_attributes_for('name', rules.children),
|
||||||
int_org_name: parse_element_attributes_for('org_name', rules.children, 'int'),
|
org_name: parse_element_attributes_for('org_name', rules.children),
|
||||||
int_addr: parse_element_attributes_for('addr', rules.children, 'int'),
|
address: parse_element_attributes_for('addr', rules.children),
|
||||||
loc_name: parse_element_attributes_for('name', rules.children, 'loc'),
|
|
||||||
loc_org_name: parse_element_attributes_for('org_name', rules.children, 'loc'),
|
|
||||||
loc_addr: parse_element_attributes_for('addr', rules.children, 'loc'),
|
|
||||||
phone: rules.css('voice').present?,
|
phone: rules.css('voice').present?,
|
||||||
email: rules.css('email').present?,
|
email: rules.css('email').present?,
|
||||||
fax: rules.css('fax').present?
|
fax: rules.css('fax').present?
|
||||||
}.delete_if { |_k, v| v.nil? || v == false }
|
}.delete_if { |_k, v| v.nil? || v == false }
|
||||||
end
|
end
|
||||||
|
|
||||||
# el is the element we are looking for
|
def parse_element_attributes_for(el, rules)
|
||||||
# rules are the contents of disclose element
|
return true if rules.css(el).present?
|
||||||
# value is loc/int depending on what type of el we are looking for
|
|
||||||
def parse_element_attributes_for(el, rules, value)
|
|
||||||
rules.css(el).each do |rule|
|
|
||||||
next unless rule.try(:attributes) || rule.attributes['type']
|
|
||||||
return rule.attributes['type'].value.present? if rule.attributes['type'].value == value
|
|
||||||
end
|
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
9
app/views/epp/contacts/_disclosure_policy.xml.builder
Normal file
9
app/views/epp/contacts/_disclosure_policy.xml.builder
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
if @disclosure_policy
|
||||||
|
@disclosure_policy.each do |k,v|
|
||||||
|
xml.tag!('contact:disclose', 'flag' => k) do
|
||||||
|
v.each do |attr|
|
||||||
|
xml.tag!("contact:#{attr}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,15 +1,13 @@
|
||||||
address = @contact.address
|
address = @contact.address
|
||||||
xml.tag!('contact:postalInfo', type: 'int') do
|
xml.tag!('contact:postalInfo', type: 'int') do
|
||||||
xml.tag!('contact:name', @contact.name)# if @contact.disclosure.try(:int_name)
|
xml.tag!('contact:name', @contact.name) if @disclosure.try(:[], :name) || @owner
|
||||||
xml.tag!('contact:org', @contact.org_name)# if @contact.disclosure.try(:int_org_name)
|
xml.tag!('contact:org', @contact.org_name) if @disclosure.try(:[], :org_name) || @owner
|
||||||
#if @contact.disclosure.try(:int_addr)
|
if @disclosure.try(:addr) || @owner
|
||||||
xml.tag!('contact:addr') do
|
xml.tag!('contact:addr') do
|
||||||
xml.tag!('contact:street', address.street) if address
|
xml.tag!('contact:street', address.street) if address
|
||||||
#xml.tag!('contact:street', address.street2) if address.street2
|
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
|
||||||
#xml.tag!('contact:street', address.street3) if address.street3
|
xml.tag!('contact:city', address.city) if address
|
||||||
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
|
end
|
||||||
xml.tag!('contact:city', address.city) if address
|
|
||||||
end
|
end
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,23 @@ xml.epp_head do
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag!('contact:chkData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
|
xml.tag!('contact:chkData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
|
||||||
xml << render('/epp/contacts/postal_info')
|
|
||||||
xml.tag!('contact:id', @contact.code)
|
xml.tag!('contact:id', @contact.code)
|
||||||
xml.tag!('contact:voice', @contact.phone) #if @contact.disclosure.try(:phone)
|
xml << render('/epp/contacts/postal_info')
|
||||||
xml.tag!('contact:fax', @contact.fax) #if @contact.disclosure.try(:fax)
|
xml.tag!('contact:voice', @contact.phone) if @disclosure.try(:phone) || @owner
|
||||||
xml.tag!('contact:email', @contact.email) #if @contact.disclosure..try(:email)
|
xml.tag!('contact:fax', @contact.fax) if @disclosure.try(:fax) || @owner
|
||||||
xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
|
xml.tag!('contact:email', @contact.email) if @disclosure.try(:email) || @owner
|
||||||
xml.tag!('contact:crID', @contact.cr_id ) if @contact.cr_id
|
#xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
|
||||||
|
#xml.tag!('contact:crID', @contact.cr_id ) if @contact.cr_id
|
||||||
xml.tag!('contact:crDate', @contact.created_at)
|
xml.tag!('contact:crDate', @contact.created_at)
|
||||||
xml.tag!('contact:upID', @contact.up_id) if @contact.up_id
|
xml.tag!('contact:upID', @contact.up_id) if @contact.up_id
|
||||||
xml.tag!('contact:upDate', @contact.updated_at) unless @contact.updated_at == @contact.created_at
|
xml.tag!('contact:upDate', @contact.updated_at) unless @contact.updated_at == @contact.created_at
|
||||||
xml.tag!('contact:trDate', '123') if false
|
xml.tag!('contact:trDate', '123') if false
|
||||||
xml.tag!('contact:authInfo') do
|
if @owner
|
||||||
xml.tag!('contact:pw', @contact.auth_info) # Doc says we have to return this but is it necessary?
|
xml.tag!('contact:authInfo') do
|
||||||
|
xml.tag!('contact:pw', @contact.auth_info) # Doc says we have to return this but is it necessary?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
xml.tag!('contact:disclose', '123') if false
|
xml << render('/epp/contacts/disclosure_policy')
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
6
config/initializers/initial_settings.rb
Normal file
6
config/initializers/initial_settings.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Setting.disclosure_name = true if Setting.disclosure_name.nil?
|
||||||
|
Setting.disclosure_org_name = true if Setting.disclosure_org_name.nil?
|
||||||
|
Setting.disclosure_email = true if Setting.disclosure_email.nil?
|
||||||
|
Setting.disclosure_phone = false if Setting.disclosure_phone.nil?
|
||||||
|
Setting.disclosure_fax = false if Setting.disclosure_fax.nil?
|
||||||
|
Setting.disclosure_address = false if Setting.disclosure_address.nil?
|
|
@ -233,6 +233,7 @@ en:
|
||||||
epp_obj_does_not_exist: 'Object does not exist'
|
epp_obj_does_not_exist: 'Object does not exist'
|
||||||
epp_command_failed: 'Command failed'
|
epp_command_failed: 'Command failed'
|
||||||
epp_authorization_error: 'Authorization error'
|
epp_authorization_error: 'Authorization error'
|
||||||
|
epp_authentication_error: 'Authentication error'
|
||||||
epp_id_taken: 'Contact id already exists'
|
epp_id_taken: 'Contact id already exists'
|
||||||
epp_domain_not_found: 'Domain not found'
|
epp_domain_not_found: 'Domain not found'
|
||||||
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'
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
class RemoveAddressTypeFromContactDisclosure < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :contact_disclosures, :int_name, :boolean
|
||||||
|
remove_column :contact_disclosures, :int_org_name, :boolean
|
||||||
|
remove_column :contact_disclosures, :int_addr, :boolean
|
||||||
|
remove_column :contact_disclosures, :loc_name, :boolean
|
||||||
|
remove_column :contact_disclosures, :loc_org_name, :boolean
|
||||||
|
remove_column :contact_disclosures, :loc_addr, :boolean
|
||||||
|
|
||||||
|
add_column :contact_disclosures, :name, :boolean
|
||||||
|
add_column :contact_disclosures, :org_name, :boolean
|
||||||
|
add_column :contact_disclosures, :address, :boolean
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
class RemoveDefaultsFromDisclosure < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column :contact_disclosures, :phone, :boolean, :default => nil
|
||||||
|
change_column :contact_disclosures, :fax, :boolean, :default => nil
|
||||||
|
change_column :contact_disclosures, :email, :boolean, :default => nil
|
||||||
|
end
|
||||||
|
end
|
15
db/schema.rb
15
db/schema.rb
|
@ -49,17 +49,14 @@ ActiveRecord::Schema.define(version: 20141202114457) do
|
||||||
|
|
||||||
create_table "contact_disclosures", force: true do |t|
|
create_table "contact_disclosures", force: true do |t|
|
||||||
t.integer "contact_id"
|
t.integer "contact_id"
|
||||||
t.boolean "int_name", default: false
|
t.boolean "phone"
|
||||||
t.boolean "int_org_name", default: false
|
t.boolean "fax"
|
||||||
t.boolean "int_addr", default: false
|
t.boolean "email"
|
||||||
t.boolean "loc_name", default: false
|
|
||||||
t.boolean "loc_org_name", default: false
|
|
||||||
t.boolean "loc_addr", default: false
|
|
||||||
t.boolean "phone", default: false
|
|
||||||
t.boolean "fax", default: false
|
|
||||||
t.boolean "email", default: false
|
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.boolean "name"
|
||||||
|
t.boolean "org_name"
|
||||||
|
t.boolean "address"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "contact_versions", force: true do |t|
|
create_table "contact_versions", force: true do |t|
|
||||||
|
|
|
@ -22,10 +22,10 @@ describe 'EPP Contact', epp: true do
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||||
create_settings
|
create_settings
|
||||||
|
create_disclosure_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'create command' do
|
context 'create command' do
|
||||||
|
|
||||||
it 'fails if request xml is missing' do
|
it 'fails if request xml is missing' do
|
||||||
xml = EppXml::Contact.create
|
xml = EppXml::Contact.create
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
|
@ -97,6 +97,50 @@ describe 'EPP Contact', epp: true do
|
||||||
# 5 seconds for what-ever weird lag reasons might happen
|
# 5 seconds for what-ever weird lag reasons might happen
|
||||||
expect(cr_date.text.to_time).to be_within(5).of(Time.now)
|
expect(cr_date.text.to_time).to be_within(5).of(Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates disclosure data' do
|
||||||
|
xml = {
|
||||||
|
disclose: { value: {
|
||||||
|
voice: { value: '' },
|
||||||
|
addr: { value: '' },
|
||||||
|
name: { value: '' },
|
||||||
|
org_name: { value: '' },
|
||||||
|
email: { value: '' },
|
||||||
|
fax: { value: '' }
|
||||||
|
}, attrs: { flag: '1' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response = epp_request(create_contact_xml(xml), :xml)
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
|
||||||
|
expect(Contact.last.disclosure.name).to eq(true)
|
||||||
|
expect(Contact.last.disclosure.org_name).to eq(true)
|
||||||
|
expect(Contact.last.disclosure.phone).to eq(true)
|
||||||
|
expect(Contact.last.disclosure.fax).to eq(true)
|
||||||
|
expect(Contact.last.disclosure.email).to eq(true)
|
||||||
|
expect(Contact.last.disclosure.address).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates disclosure data merging with defaults' do
|
||||||
|
xml = {
|
||||||
|
disclose: { value: {
|
||||||
|
voice: { value: '' },
|
||||||
|
addr: { value: '' }
|
||||||
|
}, attrs: { flag: '1' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response = epp_request(create_contact_xml(xml), :xml)
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
|
||||||
|
expect(Contact.last.disclosure.name).to eq(nil)
|
||||||
|
expect(Contact.last.disclosure.org_name).to eq(nil)
|
||||||
|
expect(Contact.last.disclosure.phone).to eq(true)
|
||||||
|
expect(Contact.last.disclosure.fax).to eq(nil)
|
||||||
|
expect(Contact.last.disclosure.email).to eq(nil)
|
||||||
|
expect(Contact.last.disclosure.address).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'update command' do
|
context 'update command' do
|
||||||
|
@ -118,8 +162,8 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
response = epp_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml, :elkdata)
|
response = epp_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml, :elkdata)
|
||||||
|
|
||||||
expect(response[:msg]).to eq('Authorization error')
|
expect(response[:msg]).to eq('Authentication error')
|
||||||
expect(response[:result_code]).to eq('2201')
|
expect(response[:result_code]).to eq('2200')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is succesful' do
|
it 'is succesful' do
|
||||||
|
@ -165,16 +209,22 @@ describe 'EPP Contact', epp: true do
|
||||||
expect(response[:results][1][:msg]).to eq('Email is invalid')
|
expect(response[:results][1][:msg]).to eq('Email is invalid')
|
||||||
end
|
end
|
||||||
|
|
||||||
# it 'updates disclosure items', pending: true do
|
it 'updates disclosure items' do
|
||||||
# pending 'Disclosure needs to be remodeled a bit'
|
Fabricate(:contact, code: 'sh8013', auth_info: '2fooBAR', registrar: zone, created_by_id: EppUser.first.id,
|
||||||
# Fabricate(:contact, code: 'sh8013', auth_info: '2fooBAR', registrar: zone, created_by_id: EppUser.first.id,
|
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
||||||
# disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
|
||||||
# epp_request('contacts/update.xml')
|
xml = {
|
||||||
#
|
id: { value: 'sh8013' },
|
||||||
# expect(Contact.last.disclosure.phone).to eq(false)
|
authInfo: { pw: { value: '2fooBAR' } }
|
||||||
# expect(Contact.last.disclosure.email).to eq(false)
|
}
|
||||||
# expect(Contact.count).to eq(1)
|
@response = epp_request(update_contact_xml(xml), :xml)
|
||||||
# end
|
|
||||||
|
expect(@response[:results][0][:result_code]).to eq('1000')
|
||||||
|
|
||||||
|
expect(Contact.last.disclosure.phone).to eq(false)
|
||||||
|
expect(Contact.last.disclosure.email).to eq(false)
|
||||||
|
expect(Contact.count).to eq(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'delete command' do
|
context 'delete command' do
|
||||||
|
@ -252,6 +302,58 @@ describe 'EPP Contact', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'info command' do
|
context 'info command' do
|
||||||
|
it 'discloses items with wrong password when queried by owner' 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 } })
|
||||||
|
response = epp_request(xml, :xml, :zone)
|
||||||
|
contact = response[:parsed].css('resData chkData')
|
||||||
|
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
expect(contact.css('name').first.text).to eq('Johnny Awesome')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns auth error for non-owner with wrong password' 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' } } })
|
||||||
|
response = epp_request(xml, :xml, :zone)
|
||||||
|
|
||||||
|
expect(response[:result_code]).to eq('2200')
|
||||||
|
expect(response[:msg]).to eq('Authentication error')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'doesn\'t disclose items to non-owner with right password' do
|
||||||
|
@contact = Fabricate(:contact, registrar: elkdata, code: 'info-4444',
|
||||||
|
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' } } })
|
||||||
|
response = epp_request(xml, :xml, :zone)
|
||||||
|
contact = response[:parsed].css('resData chkData')
|
||||||
|
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
expect(contact.css('chkData postalInfo name').first).to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'discloses items to owner' do
|
||||||
|
@contact = Fabricate(:contact, registrar: zone, code: 'info-4444', name: 'Johnny Awesome',
|
||||||
|
auth_info: 'password',
|
||||||
|
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||||
|
|
||||||
|
xml = EppXml::Contact.info({ id: { value: @contact.code } })
|
||||||
|
response = epp_request(xml, :xml, :zone)
|
||||||
|
contact = response[:parsed].css('resData chkData')
|
||||||
|
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
expect(contact.css('name').first.text).to eq('Johnny Awesome')
|
||||||
|
end
|
||||||
|
|
||||||
it 'fails if request invalid' do
|
it 'fails if request invalid' do
|
||||||
response = epp_request(EppXml::Contact.info({ uid: { value: '123123' } }), :xml)
|
response = epp_request(EppXml::Contact.info({ uid: { value: '123123' } }), :xml)
|
||||||
|
|
||||||
|
@ -281,18 +383,22 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'doesn\'t disclose private elements', pending: true do
|
it 'doesn\'t disclose private elements' do
|
||||||
pending 'Disclosure needs to have some of the details worked out'
|
Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR', registrar: elkdata,
|
||||||
Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR',
|
disclosure: Fabricate(:contact_disclosure, name: true, email: false, phone: false))
|
||||||
disclosure: Fabricate(:contact_disclosure, email: false, phone: false))
|
|
||||||
response = epp_request(info_contact_xml(id: { value: 'info-4444' }), :xml)
|
xml = EppXml::Contact.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml, :zone)
|
||||||
contact = response[:parsed].css('resData chkData')
|
contact = response[:parsed].css('resData chkData')
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
|
||||||
expect(contact.css('phone').present?).to eq(false)
|
expect(contact.css('chkData phone')).to eq(contact.css('chkData disclose phone'))
|
||||||
expect(contact.css('email').present?).to eq(false)
|
expect(contact.css('chkData phone').count).to eq(1)
|
||||||
expect(contact.css('name').present?).to be(true)
|
expect(contact.css('chkData email')).to eq(contact.css('chkData disclose email'))
|
||||||
|
expect(contact.css('chkData email').count).to eq(1)
|
||||||
|
expect(contact.css('postalInfo name').present?).to be(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'doesn\'t display unassociated object without password' do
|
it 'doesn\'t display unassociated object without password' do
|
||||||
|
@ -309,22 +415,9 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
xml = EppXml::Contact.info(id: { value: @contact.code }, authInfo: { pw: { value: 'qwe321' } })
|
xml = EppXml::Contact.info(id: { value: @contact.code }, authInfo: { pw: { value: 'qwe321' } })
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
expect(response[:result_code]).to eq('2201')
|
expect(response[:result_code]).to eq('2200')
|
||||||
expect(response[:msg]).to eq('Authorization error')
|
expect(response[:msg]).to eq('Authentication error')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'doest display unassociated object with correct password' do
|
|
||||||
@contact = Fabricate(:contact, code: 'info-4444', registrar: zone, name: 'Johnny Awesome')
|
|
||||||
|
|
||||||
xml = EppXml::Contact.info(id: { value: @contact.code }, authInfo: { pw: { value: @contact.auth_info } })
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
|
||||||
contact = response[:parsed].css('resData chkData')
|
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
|
||||||
expect(contact.css('name').first.text).to eq('Johnny Awesome')
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'renew command' do
|
context 'renew command' do
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
Fabricator(:contact_disclosure) do
|
Fabricator(:contact_disclosure) do
|
||||||
email true
|
email true
|
||||||
phone true
|
phone true
|
||||||
loc_addr true
|
fax true
|
||||||
loc_name true
|
address true
|
||||||
loc_org_name true
|
name true
|
||||||
int_name true
|
org_name true
|
||||||
int_org_name true
|
|
||||||
int_addr true
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,10 +18,19 @@ describe '.extract_attributes' do
|
||||||
|
|
||||||
# TODO: remodel create contact xml to support disclosure
|
# TODO: remodel create contact xml to support disclosure
|
||||||
it 'should return disclosure has if disclosure' do
|
it 'should return disclosure has if disclosure' do
|
||||||
f = File.open('spec/epp/requests/contacts/create_with_two_addresses.xml')
|
xml = EppXml::Contact.create(
|
||||||
parsed_frame = Nokogiri::XML(f).remove_namespaces!
|
{
|
||||||
f.close
|
disclose: { value: {
|
||||||
|
voice: { value: '' },
|
||||||
|
addr: { value: '' },
|
||||||
|
name: { value: '' },
|
||||||
|
org_name: { value: '' },
|
||||||
|
email: { value: '' },
|
||||||
|
fax: { value: '' }
|
||||||
|
}, attrs: { flag: '0' }
|
||||||
|
} })
|
||||||
|
parsed_frame = Nokogiri::XML(xml).remove_namespaces!
|
||||||
result = ContactDisclosure.extract_attributes(parsed_frame)
|
result = ContactDisclosure.extract_attributes(parsed_frame)
|
||||||
expect(result).to eq({ phone: '0', email: '0' })
|
expect(result).to eq({ phone: '0', email: '0', fax: '0', address: '0', name: '0', org_name: '0' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Contact do
|
describe Contact do
|
||||||
|
before { create_disclosure_settings }
|
||||||
it { should have_one(:address) }
|
it { should have_one(:address) }
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
@ -32,11 +33,30 @@ describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
before(:each) { @contact = Fabricate(:contact) }
|
before(:each) { @contact = Fabricate(:contact, disclosure: nil) }
|
||||||
|
|
||||||
it 'should return true' do
|
it 'should return true' do
|
||||||
expect(@contact.valid?).to be true
|
expect(@contact.valid?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should have empty disclosure' do
|
||||||
|
expect(@contact.disclosure.name).to be nil
|
||||||
|
expect(@contact.disclosure.org_name).to be nil
|
||||||
|
expect(@contact.disclosure.email).to be nil
|
||||||
|
expect(@contact.disclosure.phone).to be nil
|
||||||
|
expect(@contact.disclosure.fax).to be nil
|
||||||
|
expect(@contact.disclosure.address).to be nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have custom disclosure' do
|
||||||
|
@contact = Fabricate(:contact, disclosure: Fabricate(:contact_disclosure))
|
||||||
|
expect(@contact.disclosure.name).to be true
|
||||||
|
expect(@contact.disclosure.org_name).to be true
|
||||||
|
expect(@contact.disclosure.email).to be true
|
||||||
|
expect(@contact.disclosure.phone).to be true
|
||||||
|
expect(@contact.disclosure.fax).to be true
|
||||||
|
expect(@contact.disclosure.address).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with callbacks' do
|
context 'with callbacks' do
|
||||||
|
|
|
@ -27,7 +27,13 @@ module EppContactXmlHelper
|
||||||
name: { value: 'John Doe Edited' }
|
name: { value: 'John Doe Edited' }
|
||||||
},
|
},
|
||||||
voice: { value: '+372.7654321' },
|
voice: { value: '+372.7654321' },
|
||||||
email: { value: 'edited@example.example' }
|
email: { value: 'edited@example.example' },
|
||||||
|
disclose: {
|
||||||
|
value: {
|
||||||
|
voice: { value: '' },
|
||||||
|
email: { value: '' }
|
||||||
|
}, attrs: { flag: '0' }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xml_params = defaults.deep_merge(xml_params)
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
|
|
@ -12,6 +12,15 @@ module General
|
||||||
|
|
||||||
Setting.transfer_wait_time = 0
|
Setting.transfer_wait_time = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_disclosure_settings
|
||||||
|
Setting.disclosure_name = true
|
||||||
|
Setting.disclosure_org_name = true
|
||||||
|
Setting.disclosure_email = true
|
||||||
|
Setting.disclosure_phone = false
|
||||||
|
Setting.disclosure_fax = false
|
||||||
|
Setting.disclosure_address = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue