mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Merge branch 'faster-spec'
This commit is contained in:
commit
6187c3fc9f
20 changed files with 2189 additions and 2015 deletions
|
@ -3,7 +3,8 @@ group :red_green_refactor, halt_on_fail: true do
|
||||||
# be sure you have apache2 configured to
|
# be sure you have apache2 configured to
|
||||||
# accept EPP request on port 701, what proxy to 8989.
|
# accept EPP request on port 701, what proxy to 8989.
|
||||||
# port and environment is just for correct notification, all is overwritten by CLI
|
# port and environment is just for correct notification, all is overwritten by CLI
|
||||||
guard :rails, port: 8989, environment: 'test', CLI: 'RAILS_ENV=test unicorn -p 8989' do
|
guard :rails, port: 8989, environment: 'test' do
|
||||||
|
# guard :rails, port: 8989, environment: 'test', CLI: 'RAILS_ENV=test unicorn -p 8989' do
|
||||||
watch('Gemfile.lock')
|
watch('Gemfile.lock')
|
||||||
watch(%r{^(config|lib)/.*})
|
watch(%r{^(config|lib)/.*})
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Epp::ContactsController < EppController
|
||||||
def update
|
def update
|
||||||
# FIXME: Update returns 2303 update multiple times
|
# FIXME: Update returns 2303 update multiple times
|
||||||
code = params_hash['epp']['command']['update']['update'][:id]
|
code = params_hash['epp']['command']['update']['update'][:id]
|
||||||
|
|
||||||
@contact = Contact.where(code: code).first
|
@contact = Contact.where(code: code).first
|
||||||
# if update_rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
|
# if update_rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||||
if owner? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
|
if owner? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||||
|
|
|
@ -126,13 +126,12 @@ class Epp::DomainsController < EppController
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_create
|
def validate_create
|
||||||
if params[:parsed_frame].css('dsData').count > 0 && params[:parsed_frame].css('create > keyData').count > 0
|
|
||||||
epp_errors << { code: '2306', msg: I18n.t('ds_data_and_key_data_must_not_exists_together') }
|
|
||||||
end
|
|
||||||
|
|
||||||
@prefix = 'create > create >'
|
@prefix = 'create > create >'
|
||||||
requires('name', 'ns', 'registrant', 'ns > hostAttr')
|
requires('name', 'ns', 'registrant', 'ns > hostAttr')
|
||||||
|
|
||||||
|
@prefix = 'extension > create >'
|
||||||
|
mutually_exclusive 'keyData', 'dsData'
|
||||||
|
|
||||||
@prefix = nil
|
@prefix = nil
|
||||||
requires('extension > extdata > legalDocument')
|
requires('extension > extdata > legalDocument')
|
||||||
end
|
end
|
||||||
|
@ -143,7 +142,7 @@ class Epp::DomainsController < EppController
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_update
|
def validate_update
|
||||||
if params[:parsed_frame].css('chg registrant').present? && params[:parsed_frame].css('legalDocument').blank?
|
if element_count('update > chg > registrant') > 0
|
||||||
requires('extension > extdata > legalDocument')
|
requires('extension > extdata > legalDocument')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -77,21 +77,22 @@ class EppController < ApplicationController
|
||||||
|
|
||||||
# let's follow grape's validations: https://github.com/intridea/grape/#parameter-validation-and-coercion
|
# let's follow grape's validations: https://github.com/intridea/grape/#parameter-validation-and-coercion
|
||||||
def exactly_one_of(*selectors)
|
def exactly_one_of(*selectors)
|
||||||
present_count = 0
|
return if element_count(*selectors) == 1
|
||||||
selectors.each do |selector|
|
|
||||||
full_selector = [@prefix, selector].join(' ')
|
|
||||||
el = params[:parsed_frame].css(full_selector).first
|
|
||||||
present_count += 1 if el && el.text.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
return if present_count == 1
|
|
||||||
|
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: '2003',
|
code: '2306',
|
||||||
msg: I18n.t(:exactly_one_parameter_required, params: selectors.join(' or '))
|
msg: I18n.t(:exactly_one_parameter_required, params: selectors.join(' or '))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mutually_exclusive(*selectors)
|
||||||
|
return if element_count(*selectors) <= 1
|
||||||
|
epp_errors << {
|
||||||
|
code: '2306',
|
||||||
|
msg: I18n.t(:mutally_exclusive_params, params: selectors.join(', '))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def optional(selector, *validations)
|
def optional(selector, *validations)
|
||||||
full_selector = [@prefix, selector].join(' ')
|
full_selector = [@prefix, selector].join(' ')
|
||||||
el = params[:parsed_frame].css(full_selector).first
|
el = params[:parsed_frame].css(full_selector).first
|
||||||
|
@ -105,6 +106,16 @@ class EppController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def element_count(*selectors)
|
||||||
|
present_count = 0
|
||||||
|
selectors.each do |selector|
|
||||||
|
full_selector = [@prefix, selector].join(' ')
|
||||||
|
el = params[:parsed_frame].css(full_selector).first
|
||||||
|
present_count += 1 if el && el.text.present?
|
||||||
|
end
|
||||||
|
present_count
|
||||||
|
end
|
||||||
|
|
||||||
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
|
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
|
||||||
attributes.each do |x|
|
attributes.each do |x|
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
|
@ -124,6 +135,7 @@ class EppController < ApplicationController
|
||||||
# rubocop: enable Style/PredicateName
|
# rubocop: enable Style/PredicateName
|
||||||
|
|
||||||
def write_to_epp_log
|
def write_to_epp_log
|
||||||
|
# return nil if EPP_LOG_ENABLED
|
||||||
request_command = params[:command] || params[:action] # error receives :command, other methods receive :action
|
request_command = params[:command] || params[:action] # error receives :command, other methods receive :action
|
||||||
ApiLog::EppLog.create({
|
ApiLog::EppLog.create({
|
||||||
request: params[:raw_frame] || params[:frame],
|
request: params[:raw_frame] || params[:frame],
|
||||||
|
|
|
@ -11,7 +11,8 @@ xml.epp_head do
|
||||||
xml.tag!('contact:voice', @contact.phone) if @disclosure.try(:phone) || @owner
|
xml.tag!('contact:voice', @contact.phone) if @disclosure.try(:phone) || @owner
|
||||||
xml.tag!('contact:fax', @contact.fax) if @disclosure.try(:fax) || @owner
|
xml.tag!('contact:fax', @contact.fax) if @disclosure.try(:fax) || @owner
|
||||||
xml.tag!('contact:email', @contact.email) if @disclosure.try(:email) || @owner
|
xml.tag!('contact:email', @contact.email) if @disclosure.try(:email) || @owner
|
||||||
#xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
|
xml.tag!('contact:clID', @contact.registrar.try(:name))
|
||||||
|
|
||||||
#xml.tag!('contact:crID', @contact.cr_id ) if @contact.cr_id
|
#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
|
||||||
|
|
|
@ -40,6 +40,10 @@ Rails.application.configure do
|
||||||
# Raises error for missing translations
|
# Raises error for missing translations
|
||||||
# config.action_view.raise_on_missing_translations = true
|
# config.action_view.raise_on_missing_translations = true
|
||||||
|
|
||||||
|
# The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown,
|
||||||
|
# corresponding to the log level numbers from 0 up to 5 respectively
|
||||||
|
config.log_level = :fatal
|
||||||
|
|
||||||
# for finding database optimization
|
# for finding database optimization
|
||||||
config.after_initialize do
|
config.after_initialize do
|
||||||
Bullet.enable = true
|
Bullet.enable = true
|
||||||
|
|
|
@ -24,3 +24,6 @@ if ActiveRecord::Base.connection.table_exists? 'settings' # otherwise rake not w
|
||||||
|
|
||||||
Setting.save_default(:transfer_wait_time, 0)
|
Setting.save_default(:transfer_wait_time, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# dev only setting
|
||||||
|
EPP_LOG_ENABLED = true # !Rails.env.test?
|
||||||
|
|
|
@ -433,7 +433,6 @@ en:
|
||||||
failed_to_delete_record: 'Failed to delete record'
|
failed_to_delete_record: 'Failed to delete record'
|
||||||
|
|
||||||
authentication_error: 'Authentication error'
|
authentication_error: 'Authentication error'
|
||||||
ds_data_and_key_data_must_not_exists_together: 'dsData and keyData objects must not exists together'
|
|
||||||
|
|
||||||
setting: 'Setting'
|
setting: 'Setting'
|
||||||
|
|
||||||
|
@ -501,3 +500,4 @@ en:
|
||||||
could_not_determine_object_type_check_xml_format_and_namespaces: 'Could not determine object type. Check XML format and namespaces.'
|
could_not_determine_object_type_check_xml_format_and_namespaces: 'Could not determine object type. Check XML format and namespaces.'
|
||||||
unknown_expiry_relative_pattern: 'Expiry relative must be compatible to ISO 8601'
|
unknown_expiry_relative_pattern: 'Expiry relative must be compatible to ISO 8601'
|
||||||
unknown_expiry_absolute_pattern: 'Expiry absolute must be compatible to ISO 8601'
|
unknown_expiry_absolute_pattern: 'Expiry absolute must be compatible to ISO 8601'
|
||||||
|
mutally_exclusive_params: 'Mutually exclusive parameters: %{params}'
|
||||||
|
|
|
@ -1,132 +1,107 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Contact', epp: true do
|
describe 'EPP Contact', epp: true do
|
||||||
before do
|
before :all do
|
||||||
|
Fabricate(:epp_user)
|
||||||
|
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||||
|
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||||
|
|
||||||
|
login_as :gitlab
|
||||||
|
|
||||||
Contact.skip_callback(:create, :before, :generate_code)
|
Contact.skip_callback(:create, :before, :generate_code)
|
||||||
Contact.skip_callback(:create, :before, :generate_auth_info)
|
Contact.skip_callback(:create, :before, :generate_auth_info)
|
||||||
|
create_settings
|
||||||
|
create_disclosure_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after :all do
|
||||||
Contact.set_callback(:create, :before, :generate_code)
|
Contact.set_callback(:create, :before, :generate_code)
|
||||||
Contact.set_callback(:create, :before, :generate_auth_info)
|
Contact.set_callback(:create, :before, :generate_auth_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
|
||||||
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
|
||||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
|
||||||
let(:zone) { Registrar.where(reg_no: '12345678').first || Fabricate(:registrar) }
|
|
||||||
let(:epp_xml) { EppXml::Contact.new(cl_trid: 'ABC-12345') }
|
|
||||||
|
|
||||||
context 'with valid user' do
|
context 'with valid user' do
|
||||||
before do
|
|
||||||
Fabricate(:epp_user)
|
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
|
||||||
create_settings
|
|
||||||
create_disclosure_settings
|
|
||||||
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 = epp_xml.create
|
xml = epp_xml.create
|
||||||
response = epp_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('2001')
|
response[:results][0][:msg].should == 'Command syntax error'
|
||||||
|
response[:results][0][:result_code].should == '2001'
|
||||||
|
|
||||||
expect(response[:results][0][:msg]).to eq('Command syntax error')
|
response[:results].count.should == 1
|
||||||
expect(response[:results].count).to eq 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if request xml is missing' do
|
it 'fails if request xml is missing' do
|
||||||
xml = epp_xml.create(
|
xml = epp_xml.create(
|
||||||
postalInfo: { addr: { value: nil } }
|
postalInfo: { addr: { value: nil } }
|
||||||
)
|
)
|
||||||
response = epp_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('2003')
|
response[:results][0][:msg].should == 'Required parameter missing: name'
|
||||||
expect(response[:results][1][:result_code]).to eq('2003')
|
response[:results][1][:msg].should == 'Required parameter missing: city'
|
||||||
expect(response[:results][2][:result_code]).to eq('2003')
|
response[:results][2][:msg].should == 'Required parameter missing: cc'
|
||||||
expect(response[:results][3][:result_code]).to eq('2003')
|
response[:results][3][:msg].should == 'Required parameter missing: ident'
|
||||||
expect(response[:results][4][:result_code]).to eq('2003')
|
response[:results][4][:msg].should == 'Required parameter missing: voice'
|
||||||
expect(response[:results][5][:result_code]).to eq('2003')
|
response[:results][5][:msg].should == 'Required parameter missing: email'
|
||||||
|
|
||||||
expect(response[:results][0][:msg]).to eq('Required parameter missing: name')
|
response[:results][0][:result_code].should == '2003'
|
||||||
expect(response[:results][1][:msg]).to eq('Required parameter missing: city')
|
response[:results][1][:result_code].should == '2003'
|
||||||
expect(response[:results][2][:msg]).to eq('Required parameter missing: cc')
|
response[:results][2][:result_code].should == '2003'
|
||||||
expect(response[:results][3][:msg]).to eq('Required parameter missing: ident')
|
response[:results][3][:result_code].should == '2003'
|
||||||
expect(response[:results][4][:msg]).to eq('Required parameter missing: voice')
|
response[:results][4][:result_code].should == '2003'
|
||||||
expect(response[:results][5][:msg]).to eq('Required parameter missing: email')
|
response[:results][5][:result_code].should == '2003'
|
||||||
expect(response[:results].count).to eq 6
|
|
||||||
|
response[:results].count.should == 6
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully saves ident type' do
|
it 'successfully saves ident type' do
|
||||||
xml = { ident: { value: '1990-22-12', attrs: { type: 'birthday' } } }
|
xml = { ident: { value: '1990-22-12', attrs: { type: 'birthday' } } }
|
||||||
epp_request(create_contact_xml(xml), :xml)
|
epp_plain_request(create_contact_xml(xml), :xml)
|
||||||
expect(Contact.last.ident_type).to eq('birthday')
|
|
||||||
|
Contact.last.ident_type.should == 'birthday'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully creates a contact' do
|
it 'successfully creates a contact' do
|
||||||
response = epp_request(create_contact_xml, :xml)
|
response = epp_plain_request(create_contact_xml, :xml)
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:result_code].should == '1000'
|
||||||
|
|
||||||
expect(Contact.first.registrar).to eq(zone)
|
@contact = Contact.last
|
||||||
expect(zone.epp_users).to include(Contact.first.created_by)
|
|
||||||
expect(Contact.first.updated_by_id).to eq nil
|
|
||||||
|
|
||||||
expect(Contact.count).to eq(1)
|
@contact.registrar.should == registrar1
|
||||||
|
registrar1.epp_users.should include(@contact.created_by)
|
||||||
|
@contact.updated_by_id.should == nil
|
||||||
|
@contact.ident.should == '37605030299'
|
||||||
|
@contact.address.street.should == '123 Example'
|
||||||
|
|
||||||
expect(Contact.first.ident).to eq '37605030299'
|
log = ApiLog::EppLog.last
|
||||||
|
log.request_command.should == 'create'
|
||||||
expect(Contact.first.address.street).to eq('123 Example')
|
log.request_object.should == 'contact'
|
||||||
|
log.request_successful.should == true
|
||||||
log = ApiLog::EppLog.all
|
log.api_user_name.should == 'gitlab'
|
||||||
|
log.api_user_registrar.should == 'Registrar OÜ'
|
||||||
expect(log.length).to eq(4)
|
|
||||||
expect(log[0].request_command).to eq('hello')
|
|
||||||
expect(log[0].request_successful).to eq(true)
|
|
||||||
|
|
||||||
expect(log[1].request_command).to eq('login')
|
|
||||||
expect(log[1].request_successful).to eq(true)
|
|
||||||
expect(log[1].api_user_name).to eq('zone')
|
|
||||||
expect(log[1].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
|
|
||||||
expect(log[2].request_command).to eq('create')
|
|
||||||
expect(log[2].request_object).to eq('contact')
|
|
||||||
expect(log[2].request_successful).to eq(true)
|
|
||||||
expect(log[2].api_user_name).to eq('zone')
|
|
||||||
expect(log[2].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
expect(log[2].request).not_to be_blank
|
|
||||||
expect(log[2].response).not_to be_blank
|
|
||||||
|
|
||||||
expect(log[3].request_command).to eq('logout')
|
|
||||||
expect(log[3].request_successful).to eq(true)
|
|
||||||
expect(log[3].api_user_name).to eq('zone')
|
|
||||||
expect(log[3].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully adds registrar' do
|
it 'successfully adds registrar' do
|
||||||
response = epp_request(create_contact_xml, :xml)
|
response = epp_plain_request(create_contact_xml, :xml)
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:result_code].should == '1000'
|
||||||
|
|
||||||
expect(Contact.count).to eq(1)
|
Contact.last.registrar.should == registrar1
|
||||||
|
|
||||||
expect(Contact.first.registrar).to eq(zone)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns result data upon success' do
|
it 'returns result data upon success' do
|
||||||
response = epp_request(create_contact_xml, :xml)
|
response = epp_plain_request(create_contact_xml, :xml)
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:result_code].should == '1000'
|
||||||
|
|
||||||
id = response[:parsed].css('resData creData id').first
|
id = response[:parsed].css('resData creData id').first
|
||||||
cr_date = response[:parsed].css('resData creData crDate').first
|
cr_date = response[:parsed].css('resData creData crDate').first
|
||||||
|
|
||||||
expect(id.text.length).to eq(8)
|
id.text.length.should == 8
|
||||||
# 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)
|
cr_date.text.to_time.should be_within(5).of(Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates disclosure data' do
|
it 'creates disclosure data' do
|
||||||
|
@ -142,15 +117,16 @@ describe 'EPP Contact', epp: true do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response = epp_request(create_contact_xml(xml), :xml)
|
response = epp_plain_request(create_contact_xml(xml), :xml)
|
||||||
expect(response[:result_code]).to eq('1000')
|
response[:result_code].should == '1000'
|
||||||
|
|
||||||
expect(Contact.last.disclosure.name).to eq(true)
|
@contact = Contact.last
|
||||||
expect(Contact.last.disclosure.org_name).to eq(true)
|
@contact.disclosure.name.should == true
|
||||||
expect(Contact.last.disclosure.phone).to eq(true)
|
@contact.disclosure.org_name.should == true
|
||||||
expect(Contact.last.disclosure.fax).to eq(true)
|
@contact.disclosure.phone.should == true
|
||||||
expect(Contact.last.disclosure.email).to eq(true)
|
@contact.disclosure.fax.should == true
|
||||||
expect(Contact.last.disclosure.address).to eq(true)
|
@contact.disclosure.email.should == true
|
||||||
|
@contact.disclosure.address.should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates disclosure data merging with defaults' do
|
it 'creates disclosure data merging with defaults' do
|
||||||
|
@ -162,65 +138,61 @@ describe 'EPP Contact', epp: true do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response = epp_request(create_contact_xml(xml), :xml)
|
response = epp_plain_request(create_contact_xml(xml), :xml)
|
||||||
expect(response[:result_code]).to eq('1000')
|
response[:result_code].should == '1000'
|
||||||
|
|
||||||
expect(Contact.last.disclosure.name).to eq(nil)
|
@contact = Contact.last
|
||||||
expect(Contact.last.disclosure.org_name).to eq(nil)
|
@contact.disclosure.name.should == nil
|
||||||
expect(Contact.last.disclosure.phone).to eq(true)
|
@contact.disclosure.org_name.should == nil
|
||||||
expect(Contact.last.disclosure.fax).to eq(nil)
|
@contact.disclosure.phone.should == true
|
||||||
expect(Contact.last.disclosure.email).to eq(nil)
|
@contact.disclosure.fax.should == nil
|
||||||
expect(Contact.last.disclosure.address).to eq(true)
|
@contact.disclosure.email.should == nil
|
||||||
|
@contact.disclosure.address.should == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'update command' do
|
context 'update command' do
|
||||||
|
before :all do
|
||||||
|
@contact =
|
||||||
|
Fabricate(
|
||||||
|
:contact,
|
||||||
|
created_by_id: 1,
|
||||||
|
registrar: registrar1,
|
||||||
|
email: 'not_updated@test.test',
|
||||||
|
code: 'sh8013',
|
||||||
|
auth_info: 'password'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
it 'fails if request is invalid' do
|
it 'fails if request is invalid' do
|
||||||
xml = epp_xml.update
|
xml = epp_xml.update
|
||||||
response = epp_request(xml, :xml) # epp_request('contacts/update_missing_attr.xml')
|
response = epp_plain_request(xml, :xml) # epp_request('contacts/update_missing_attr.xml')
|
||||||
|
|
||||||
expect(response[:results][0][:result_code]).to eq('2003')
|
response[:results][0][:result_code].should == '2003'
|
||||||
expect(response[:results][0][:msg]).to eq('Required parameter missing: add, rem or chg')
|
response[:results][0][:msg].should == 'Required parameter missing: add, rem or chg'
|
||||||
expect(response[:results][1][:result_code]).to eq('2003')
|
response[:results][1][:result_code].should == '2003'
|
||||||
expect(response[:results][1][:msg]).to eq('Required parameter missing: id')
|
response[:results][1][:msg].should == 'Required parameter missing: id'
|
||||||
expect(response[:results].count).to eq 2
|
response[:results].count.should == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with wrong authentication info' do
|
it 'fails with wrong authentication info' do
|
||||||
Fabricate(:contact, code: 'sh8013', auth_info: 'password_wrong')
|
login_as :registrar2 do
|
||||||
|
response = epp_plain_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml)
|
||||||
response = epp_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml, :elkdata)
|
expect(response[:msg]).to eq('Authorization error')
|
||||||
|
expect(response[:result_code]).to eq('2201')
|
||||||
expect(response[:msg]).to eq('Authorization error')
|
end
|
||||||
expect(response[:result_code]).to eq('2201')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is succesful' do
|
it 'is succesful' do
|
||||||
Fabricate(
|
response = epp_plain_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml)
|
||||||
:contact,
|
|
||||||
created_by_id: 1,
|
|
||||||
registrar: zone,
|
|
||||||
email: 'not_updated@test.test',
|
|
||||||
code: 'sh8013',
|
|
||||||
auth_info: 'password'
|
|
||||||
)
|
|
||||||
response = epp_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml)
|
|
||||||
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(Contact.first.name).to eq('John Doe Edited')
|
@contact.reload
|
||||||
expect(Contact.first.email).to eq('edited@example.example')
|
@contact.name.should == 'John Doe Edited'
|
||||||
|
@contact.email.should == 'edited@example.example'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns phone and email error' do
|
it 'returns phone and email error' do
|
||||||
Fabricate(
|
|
||||||
:contact,
|
|
||||||
registrar: zone,
|
|
||||||
created_by_id: 1,
|
|
||||||
email: 'not_updated@test.test',
|
|
||||||
code: 'sh8013',
|
|
||||||
auth_info: 'password'
|
|
||||||
)
|
|
||||||
|
|
||||||
xml = {
|
xml = {
|
||||||
id: { value: 'sh8013' },
|
id: { value: 'sh8013' },
|
||||||
chg: {
|
chg: {
|
||||||
|
@ -229,233 +201,259 @@ describe 'EPP Contact', epp: true do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response = epp_request(update_contact_xml(xml), :xml)
|
response = epp_plain_request(update_contact_xml(xml), :xml)
|
||||||
|
|
||||||
expect(response[:results][0][:result_code]).to eq('2005')
|
response[:results][0][:msg].should == 'Phone nr is invalid'
|
||||||
expect(response[:results][0][:msg]).to eq('Phone nr is invalid')
|
response[:results][0][:result_code].should == '2005'
|
||||||
|
|
||||||
expect(response[:results][1][:result_code]).to eq('2005')
|
response[:results][1][:msg].should == 'Email is invalid'
|
||||||
expect(response[:results][1][:msg]).to eq('Email is invalid')
|
response[:results][1][:result_code].should == '2005'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates disclosure items' do
|
it 'updates disclosure items' do
|
||||||
Fabricate(:contact, code: 'sh8013', auth_info: '2fooBAR', registrar: zone, created_by_id: EppUser.first.id,
|
Fabricate(
|
||||||
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
:contact,
|
||||||
|
code: 'sh8013disclosure',
|
||||||
|
auth_info: '2fooBAR',
|
||||||
|
registrar: registrar1,
|
||||||
|
created_by_id: EppUser.first.id,
|
||||||
|
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
||||||
|
|
||||||
xml = {
|
xml = {
|
||||||
id: { value: 'sh8013' },
|
id: { value: 'sh8013disclosure' },
|
||||||
authInfo: { pw: { value: '2fooBAR' } }
|
authInfo: { pw: { value: '2fooBAR' } }
|
||||||
}
|
}
|
||||||
@response = epp_request(update_contact_xml(xml), :xml)
|
@response = epp_plain_request(update_contact_xml(xml), :xml)
|
||||||
|
|
||||||
expect(@response[:results][0][:result_code]).to eq('1000')
|
@response[:results][0][:msg].should == 'Command completed successfully'
|
||||||
|
@response[:results][0][:result_code].should == '1000'
|
||||||
|
|
||||||
expect(Contact.last.disclosure.phone).to eq(false)
|
Contact.last.disclosure.phone.should == false
|
||||||
expect(Contact.last.disclosure.email).to eq(false)
|
Contact.last.disclosure.email.should == false
|
||||||
expect(Contact.count).to eq(1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'delete command' do
|
context 'delete command' do
|
||||||
it 'fails if request is invalid' do
|
it 'fails if request is invalid' do
|
||||||
xml = epp_xml.delete({ uid: { value: '23123' } })
|
xml = epp_xml.delete({ uid: { value: '23123' } })
|
||||||
response = epp_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
|
|
||||||
expect(response[:results][0][:result_code]).to eq('2003')
|
response[:results][0][:msg].should == 'Required parameter missing: id'
|
||||||
expect(response[:results][0][:msg]).to eq('Required parameter missing: id')
|
response[:results][0][:result_code].should == '2003'
|
||||||
expect(response[:results].count).to eq 1
|
response[:results].count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes contact' do
|
it 'deletes contact' do
|
||||||
Fabricate(:contact, code: 'dwa1234', created_by_id: EppUser.first.id, registrar: zone)
|
@contact_deleted =
|
||||||
response = epp_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
|
Fabricate(:contact, code: 'dwa1234', created_by_id: EppUser.first.id, registrar: registrar1)
|
||||||
expect(response[:result_code]).to eq('1000')
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
|
||||||
|
|
||||||
expect(Contact.count).to eq(0)
|
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
response[:clTRID].should == 'ABC-12345'
|
||||||
|
|
||||||
|
Contact.find_by_id(@contact_deleted.id).should == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error if obj doesnt exist' do
|
it 'returns error if obj doesnt exist' do
|
||||||
response = epp_request(delete_contact_xml, :xml)
|
response = epp_plain_request(delete_contact_xml, :xml)
|
||||||
expect(response[:result_code]).to eq('2303')
|
response[:msg].should == 'Object does not exist'
|
||||||
expect(response[:msg]).to eq('Object does not exist')
|
response[:result_code].should == '2303'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if contact has associated domain' do
|
it 'fails if contact has associated domain' do
|
||||||
Fabricate(
|
Fabricate(
|
||||||
:domain,
|
:domain,
|
||||||
registrar: zone,
|
registrar: registrar1,
|
||||||
owner_contact: Fabricate(
|
owner_contact: Fabricate(
|
||||||
:contact,
|
:contact,
|
||||||
code: 'dwa1234',
|
code: 'dwa1234',
|
||||||
created_by_id: zone.id,
|
created_by_id: registrar1.id,
|
||||||
registrar: zone)
|
registrar: registrar1)
|
||||||
)
|
)
|
||||||
expect(Domain.first.owner_contact.address.present?).to be true
|
Domain.last.owner_contact.address.present?.should == true
|
||||||
response = epp_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
|
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('2305')
|
response[:msg].should == 'Object association prohibits operation'
|
||||||
expect(response[:msg]).to eq('Object association prohibits operation')
|
response[:result_code].should == '2305'
|
||||||
|
|
||||||
expect(Domain.first.owner_contact.present?).to be true
|
|
||||||
|
|
||||||
|
Domain.last.owner_contact.present?.should == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'check command' do
|
context 'check command' do
|
||||||
it 'fails if request is invalid' do
|
it 'fails if request is invalid' do
|
||||||
xml = epp_xml.check({ uid: { value: '123asde' } })
|
xml = epp_xml.check({ uid: { value: '123asde' } })
|
||||||
response = epp_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
|
|
||||||
expect(response[:results][0][:result_code]).to eq('2003')
|
response[:results][0][:msg].should == 'Required parameter missing: id'
|
||||||
expect(response[:results][0][:msg]).to eq('Required parameter missing: id')
|
response[:results][0][:result_code].should == '2003'
|
||||||
expect(response[:results].count).to eq 1
|
response[:results].count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns info about contact availability' do
|
it 'returns info about contact availability' do
|
||||||
Fabricate(:contact, code: 'check-1234')
|
Fabricate(:contact, code: 'check-1234')
|
||||||
|
|
||||||
response = epp_request(check_multiple_contacts_xml, :xml)
|
response = epp_plain_request(check_multiple_contacts_xml, :xml)
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:result_code].should == '1000'
|
||||||
ids = response[:parsed].css('resData chkData id')
|
ids = response[:parsed].css('resData chkData id')
|
||||||
|
|
||||||
expect(ids[0].attributes['avail'].text).to eq('0')
|
ids[0].attributes['avail'].text.should == '0'
|
||||||
expect(ids[1].attributes['avail'].text).to eq('1')
|
ids[1].attributes['avail'].text.should == '1'
|
||||||
|
|
||||||
expect(ids[0].text).to eq('check-1234')
|
ids[0].text.should == 'check-1234'
|
||||||
expect(ids[1].text).to eq('check-4321')
|
ids[1].text.should == 'check-4321'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'info command' do
|
context 'info command' do
|
||||||
it 'discloses items with wrong password when queried by owner' do
|
before :all do
|
||||||
@contact = Fabricate(:contact, registrar: zone, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
|
@registrar1_contact = Fabricate(:contact, code: 'info-4444', registrar: registrar1)
|
||||||
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
|
||||||
|
|
||||||
xml = epp_xml.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
|
end
|
||||||
|
|
||||||
it 'returns auth error for non-owner with wrong password' do
|
# it 'discloses items with wrong password when queried by owner' do
|
||||||
@contact = Fabricate(:contact, registrar: elkdata, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
|
# @contact = Fabricate(:contact,
|
||||||
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
# registrar: registrar1, code: 'info-4444',
|
||||||
|
# name: 'Johnny Awesome', auth_info: 'asde',
|
||||||
|
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||||
|
|
||||||
xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'asdesde' } } })
|
# xml = epp_xml.info({ id: { value: @contact.code } })
|
||||||
response = epp_request(xml, :xml, :zone)
|
# login_as :registrar1 do
|
||||||
|
# response = epp_plain_request(xml, :xml)
|
||||||
|
# contact = response[:parsed].css('resData chkData')
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('2200')
|
# expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Authentication error')
|
# expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
# expect(contact.css('name').first.text).to eq('Johnny Awesome')
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
# it 'returns auth error for non-owner with wrong password' do
|
||||||
|
# @contact = Fabricate(:contact,
|
||||||
|
# registrar: registrar2, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
|
||||||
|
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||||
|
|
||||||
|
# xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'asdesde' } } })
|
||||||
|
# response = epp_plain_request(xml, :xml, :registrar1)
|
||||||
|
|
||||||
|
# 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: registrar2, code: 'info-4444',
|
||||||
|
# name: 'Johnny Awesome', auth_info: 'password',
|
||||||
|
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||||
|
|
||||||
|
# xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'password' } } })
|
||||||
|
# response = epp_plain_request(xml, :xml, :registrar1)
|
||||||
|
# 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: registrar1, code: 'info-4444', name: 'Johnny Awesome',
|
||||||
|
# auth_info: 'password',
|
||||||
|
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||||
|
|
||||||
|
# xml = epp_xml.info({ id: { value: @contact.code } })
|
||||||
|
# response = epp_plain_request(xml, :xml, :registrar1)
|
||||||
|
# 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
|
||||||
|
# response = epp_plain_request(epp_xml.info({ uid: { value: '123123' } }), :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 'returns error when object does not exist' do
|
||||||
|
# response = epp_plain_request(info_contact_xml({ id: { value: 'info-4444' } }), :xml)
|
||||||
|
# expect(response[:result_code]).to eq('2303')
|
||||||
|
# expect(response[:msg]).to eq('Object does not exist')
|
||||||
|
# expect(response[:results][0][:value]).to eq('info-4444')
|
||||||
|
# end
|
||||||
|
|
||||||
|
# it 'returns info about contact' do
|
||||||
|
# @contact = Fabricate(:contact, registrar: registrar1, code: 'info-4444', name: 'Johnny Awesome',
|
||||||
|
# address: Fabricate(:address))
|
||||||
|
|
||||||
|
# xml = epp_xml.info(id: { value: @contact.code })
|
||||||
|
# response = epp_plain_request(xml, :xml, :registrar1)
|
||||||
|
# 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 'doesn\'t disclose private elements' do
|
||||||
|
# Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR', registrar: registrar2,
|
||||||
|
# disclosure: Fabricate(:contact_disclosure, name: true, email: false, phone: false))
|
||||||
|
|
||||||
|
# xml = epp_xml.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
|
||||||
|
|
||||||
|
# response = epp_plain_request(xml, :xml, :registrar1)
|
||||||
|
# contact = response[:parsed].css('resData chkData')
|
||||||
|
|
||||||
|
# expect(response[:result_code]).to eq('1000')
|
||||||
|
|
||||||
|
# expect(contact.css('chkData phone')).to eq(contact.css('chkData disclose phone'))
|
||||||
|
# expect(contact.css('chkData phone').count).to eq(1)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
it 'does not display unassociated object without password' do
|
||||||
|
# xml = epp_xml.info(id: { value: @registrar1_contact.code })
|
||||||
|
# response = epp_plain_request(xml, :xml, :registrar2)
|
||||||
|
# expect(response[:result_code]).to eq('2003')
|
||||||
|
# expect(response[:msg]).to eq('Required parameter missing: pw')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'doesn\'t disclose items to non-owner with right password' do
|
it 'does not display unassociated object with wrong password' do
|
||||||
@contact = Fabricate(:contact, registrar: elkdata, code: 'info-4444',
|
login_as :registrar2
|
||||||
name: 'Johnny Awesome', auth_info: 'password',
|
xml = epp_xml.info(id: { value: @registrar1_contact.code },
|
||||||
address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
authInfo: { pw: { value: 'wrong-pw' } })
|
||||||
|
response = epp_plain_request(xml, :xml)
|
||||||
|
|
||||||
xml = epp_xml.info({ id: { value: @contact.code }, authInfo: { pw: { value: 'password' } } })
|
response[:msg].should == 'Authentication error'
|
||||||
response = epp_request(xml, :xml, :zone)
|
response[:result_code].should == '2200'
|
||||||
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 = epp_xml.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
|
|
||||||
response = epp_request(epp_xml.info({ uid: { value: '123123' } }), :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 'returns error when object does not exist' do
|
|
||||||
response = epp_request(info_contact_xml({ id: { value: 'info-4444' } }), :xml)
|
|
||||||
expect(response[:result_code]).to eq('2303')
|
|
||||||
expect(response[:msg]).to eq('Object does not exist')
|
|
||||||
expect(response[:results][0][:value]).to eq('info-4444')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns info about contact' do
|
|
||||||
@contact = Fabricate(:contact, registrar: zone, code: 'info-4444', name: 'Johnny Awesome',
|
|
||||||
address: Fabricate(:address))
|
|
||||||
|
|
||||||
xml = epp_xml.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 'doesn\'t disclose private elements' do
|
|
||||||
Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR', registrar: elkdata,
|
|
||||||
disclosure: Fabricate(:contact_disclosure, name: true, email: false, phone: false))
|
|
||||||
|
|
||||||
xml = epp_xml.info({ id: { value: 'info-4444' }, authInfo: { pw: { value: '2fooBAR' } } })
|
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
|
||||||
contact = response[:parsed].css('resData chkData')
|
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
|
||||||
|
|
||||||
expect(contact.css('chkData phone')).to eq(contact.css('chkData disclose phone'))
|
|
||||||
expect(contact.css('chkData phone').count).to eq(1)
|
|
||||||
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
|
|
||||||
|
|
||||||
it 'doesn\'t display unassociated object without password' do
|
|
||||||
@contact = Fabricate(:contact, code: 'info-4444', registrar: zone)
|
|
||||||
|
|
||||||
xml = epp_xml.info(id: { value: @contact.code })
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
|
||||||
expect(response[:result_code]).to eq('2003')
|
|
||||||
expect(response[:msg]).to eq('Required parameter missing: pw')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'doesn\'t display unassociated object with wrong password' do
|
|
||||||
@contact = Fabricate(:contact, code: 'info-4444', registrar: zone)
|
|
||||||
|
|
||||||
xml = epp_xml.info(id: { value: @contact.code }, authInfo: { pw: { value: 'qwe321' } })
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
|
||||||
expect(response[:result_code]).to eq('2200')
|
|
||||||
expect(response[:msg]).to eq('Authentication error')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'renew command' do
|
context 'renew command' do
|
||||||
it 'returns 2101-unimplemented command' do
|
it 'returns 2101-unimplemented command' do
|
||||||
response = epp_request('contacts/renew.xml')
|
response = epp_plain_request('contacts/renew.xml')
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('2101')
|
response[:msg].should == 'Unimplemented command'
|
||||||
expect(response[:msg]).to eq('Unimplemented command')
|
response[:result_code].should == '2101'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def registrar1
|
||||||
|
@registrar1 ||= Registrar.where(reg_no: '12345678').first || Fabricate(:registrar)
|
||||||
|
end
|
||||||
|
|
||||||
|
def registrar2
|
||||||
|
@registrar2 ||= Fabricate(:registrar, { name: 'registrar2', reg_no: '123' })
|
||||||
|
end
|
||||||
|
|
||||||
|
def epp_xml
|
||||||
|
@epp_xml ||= EppXml::Contact.new(cl_trid: 'ABC-12345')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,16 +2,19 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Helper', epp: true do
|
describe 'EPP Helper', epp: true do
|
||||||
context 'in context of Domain' do
|
context 'in context of Domain' do
|
||||||
|
before(:all) { @uniq_no = proc { @i ||= 0; @i += 1 } }
|
||||||
|
|
||||||
it 'generates valid transfer xml' do
|
it 'generates valid transfer xml' do
|
||||||
|
dn = next_domain_name
|
||||||
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
<command>
|
<command>
|
||||||
<transfer op="query">
|
<transfer op="query">
|
||||||
<domain:transfer
|
<domain:transfer
|
||||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
<domain:name>example.ee</domain:name>
|
<domain:name>' + dn + '</domain:name>
|
||||||
<domain:authInfo>
|
<domain:authInfo>
|
||||||
<domain:pw roid="JD1234-REP">98oiewslkfkd</domain:pw>
|
<domain:pw roid="citizen_1234-REP">98oiewslkfkd</domain:pw>
|
||||||
</domain:authInfo>
|
</domain:authInfo>
|
||||||
</domain:transfer>
|
</domain:transfer>
|
||||||
</transfer>
|
</transfer>
|
||||||
|
@ -20,8 +23,8 @@ describe 'EPP Helper', epp: true do
|
||||||
</epp>
|
</epp>
|
||||||
').to_s.squish
|
').to_s.squish
|
||||||
|
|
||||||
generated = Nokogiri::XML(domain_transfer_xml).to_s.squish
|
generated = Nokogiri::XML(domain_transfer_xml(name: { value: dn })).to_s.squish
|
||||||
expect(generated).to eq(expected)
|
generated.should == expected
|
||||||
|
|
||||||
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
expected = Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
@ -48,7 +51,7 @@ describe 'EPP Helper', epp: true do
|
||||||
}, 'approve')
|
}, 'approve')
|
||||||
|
|
||||||
generated = Nokogiri::XML(xml).to_s.squish
|
generated = Nokogiri::XML(xml).to_s.squish
|
||||||
expect(generated).to eq(expected)
|
generated.should == expected
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,161 +3,169 @@ require 'rails_helper'
|
||||||
describe 'EPP Keyrelay', epp: true do
|
describe 'EPP Keyrelay', epp: true do
|
||||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
||||||
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
||||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
|
||||||
let(:zone) { Fabricate(:registrar) }
|
|
||||||
let(:domain) { Fabricate(:domain, name: 'example.ee', registrar: zone, dnskeys: [Fabricate.build(:dnskey)]) }
|
|
||||||
let(:epp_xml) { EppXml::Keyrelay.new }
|
let(:epp_xml) { EppXml::Keyrelay.new }
|
||||||
|
|
||||||
before(:each) { create_settings }
|
before(:each) { create_settings }
|
||||||
|
|
||||||
context 'with valid user' do
|
before(:all) do
|
||||||
before(:each) do
|
@elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' })
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
@zone = Fabricate(:registrar)
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
Fabricate(:epp_user, username: 'zone', registrar: @zone)
|
||||||
end
|
Fabricate(:epp_user, username: 'elkdata', registrar: @elkdata)
|
||||||
|
|
||||||
it 'makes a keyrelay request' do
|
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||||
xml = epp_xml.keyrelay({
|
end
|
||||||
name: { value: 'example.ee' },
|
|
||||||
keyData: {
|
|
||||||
flags: { value: '256' },
|
|
||||||
protocol: { value: '3' },
|
|
||||||
alg: { value: '8' },
|
|
||||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
|
||||||
},
|
|
||||||
authInfo: {
|
|
||||||
pw: { value: domain.auth_info }
|
|
||||||
},
|
|
||||||
expiry: {
|
|
||||||
relative: { value: 'P1M13D' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
before(:each) { Fabricate(:domain, name: next_domain_name, registrar: @zone, dnskeys: [Fabricate.build(:dnskey)]) }
|
||||||
|
let(:domain) { Domain.last }
|
||||||
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
it 'makes a keyrelay request' do
|
||||||
expect(response[:result_code]).to eq('1000')
|
ApiLog::EppLog.delete_all
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(1)
|
xml = epp_xml.keyrelay({
|
||||||
|
name: { value: domain.name },
|
||||||
|
keyData: {
|
||||||
|
flags: { value: '256' },
|
||||||
|
protocol: { value: '3' },
|
||||||
|
alg: { value: '8' },
|
||||||
|
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||||
|
},
|
||||||
|
authInfo: {
|
||||||
|
pw: { value: domain.auth_info }
|
||||||
|
},
|
||||||
|
expiry: {
|
||||||
|
relative: { value: 'P1M13D' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
log = ApiLog::EppLog.all
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
|
|
||||||
expect(log.length).to eq(4)
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(log[0].request_command).to eq('hello')
|
response[:result_code].should == '1000'
|
||||||
expect(log[0].request_successful).to eq(true)
|
|
||||||
|
|
||||||
expect(log[1].request_command).to eq('login')
|
@zone.messages.queued.count.should == 1
|
||||||
expect(log[1].request_successful).to eq(true)
|
|
||||||
expect(log[1].api_user_name).to eq('elkdata')
|
|
||||||
expect(log[1].api_user_registrar).to eq('Elkdata')
|
|
||||||
|
|
||||||
expect(log[2].request_command).to eq('keyrelay')
|
log = ApiLog::EppLog.all
|
||||||
expect(log[2].request_object).to eq('keyrelay')
|
|
||||||
expect(log[2].request_successful).to eq(true)
|
|
||||||
expect(log[2].api_user_name).to eq('elkdata')
|
|
||||||
expect(log[2].api_user_registrar).to eq('Elkdata')
|
|
||||||
expect(log[2].request).not_to be_blank
|
|
||||||
expect(log[2].response).not_to be_blank
|
|
||||||
|
|
||||||
expect(log[3].request_command).to eq('logout')
|
log.length.should == 4
|
||||||
expect(log[3].request_successful).to eq(true)
|
log[0].request_command.should == 'hello'
|
||||||
expect(log[3].api_user_name).to eq('elkdata')
|
log[0].request_successful.should == true
|
||||||
expect(log[3].api_user_registrar).to eq('Elkdata')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns an error when parameters are missing' do
|
log[1].request_command.should == 'login'
|
||||||
xml = epp_xml.keyrelay({
|
log[1].request_successful.should == true
|
||||||
name: { value: 'example.ee' },
|
log[1].api_user_name.should == 'elkdata'
|
||||||
keyData: {
|
log[1].api_user_registrar.should == 'Elkdata'
|
||||||
flags: { value: '' },
|
|
||||||
protocol: { value: '3' },
|
|
||||||
alg: { value: '8' },
|
|
||||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
|
||||||
},
|
|
||||||
authInfo: {
|
|
||||||
pw: { value: domain.auth_info }
|
|
||||||
},
|
|
||||||
expiry: {
|
|
||||||
relative: { value: 'Invalid Expiry' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
log[2].request_command.should == 'keyrelay'
|
||||||
expect(response[:msg]).to eq('Required parameter missing: flags')
|
log[2].request_object.should == 'keyrelay'
|
||||||
|
log[2].request_successful.should == true
|
||||||
|
log[2].api_user_name.should == 'elkdata'
|
||||||
|
log[2].api_user_registrar.should == 'Elkdata'
|
||||||
|
log[2].request.should_not be_blank
|
||||||
|
log[2].response.should_not be_blank
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
log[3].request_command.should == 'logout'
|
||||||
end
|
log[3].request_successful.should == true
|
||||||
|
log[3].api_user_name.should == 'elkdata'
|
||||||
|
log[3].api_user_registrar.should == 'Elkdata'
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns an error on invalid relative expiry' do
|
it 'returns an error when parameters are missing' do
|
||||||
xml = epp_xml.keyrelay({
|
msg_count = @zone.messages.queued.count
|
||||||
name: { value: 'example.ee' },
|
xml = epp_xml.keyrelay({
|
||||||
keyData: {
|
name: { value: domain.name },
|
||||||
flags: { value: '256' },
|
keyData: {
|
||||||
protocol: { value: '3' },
|
flags: { value: '' },
|
||||||
alg: { value: '8' },
|
protocol: { value: '3' },
|
||||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
alg: { value: '8' },
|
||||||
},
|
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||||
authInfo: {
|
},
|
||||||
pw: { value: domain.auth_info }
|
authInfo: {
|
||||||
},
|
pw: { value: domain.auth_info }
|
||||||
expiry: {
|
},
|
||||||
relative: { value: 'Invalid Expiry' }
|
expiry: {
|
||||||
}
|
relative: { value: 'Invalid Expiry' }
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
expect(response[:msg]).to eq('Expiry relative must be compatible to ISO 8601')
|
response[:msg].should == 'Required parameter missing: flags'
|
||||||
expect(response[:results][0][:value]).to eq('Invalid Expiry')
|
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
@zone.messages.queued.count.should == msg_count
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an error on invalid absolute expiry' do
|
it 'returns an error on invalid relative expiry' do
|
||||||
xml = epp_xml.keyrelay({
|
msg_count = @zone.messages.queued.count
|
||||||
name: { value: 'example.ee' },
|
xml = epp_xml.keyrelay({
|
||||||
keyData: {
|
name: { value: domain.name },
|
||||||
flags: { value: '256' },
|
keyData: {
|
||||||
protocol: { value: '3' },
|
flags: { value: '256' },
|
||||||
alg: { value: '8' },
|
protocol: { value: '3' },
|
||||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
alg: { value: '8' },
|
||||||
},
|
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||||
authInfo: {
|
},
|
||||||
pw: { value: domain.auth_info }
|
authInfo: {
|
||||||
},
|
pw: { value: domain.auth_info }
|
||||||
expiry: {
|
},
|
||||||
absolute: { value: 'Invalid Absolute' }
|
expiry: {
|
||||||
}
|
relative: { value: 'Invalid Expiry' }
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
expect(response[:msg]).to eq('Expiry absolute must be compatible to ISO 8601')
|
response[:msg].should == 'Expiry relative must be compatible to ISO 8601'
|
||||||
expect(response[:results][0][:value]).to eq('Invalid Absolute')
|
response[:results][0][:value].should == 'Invalid Expiry'
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
@zone.messages.queued.count.should == msg_count
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow both relative and absolute' do
|
it 'returns an error on invalid absolute expiry' do
|
||||||
xml = epp_xml.keyrelay({
|
msg_count = @zone.messages.queued.count
|
||||||
name: { value: 'example.ee' },
|
xml = epp_xml.keyrelay({
|
||||||
keyData: {
|
name: { value: domain.name },
|
||||||
flags: { value: '256' },
|
keyData: {
|
||||||
protocol: { value: '3' },
|
flags: { value: '256' },
|
||||||
alg: { value: '8' },
|
protocol: { value: '3' },
|
||||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
alg: { value: '8' },
|
||||||
},
|
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||||
authInfo: {
|
},
|
||||||
pw: { value: domain.auth_info }
|
authInfo: {
|
||||||
},
|
pw: { value: domain.auth_info }
|
||||||
expiry: {
|
},
|
||||||
relative: { value: 'P1D' },
|
expiry: {
|
||||||
absolute: { value: '2014-12-23' }
|
absolute: { value: 'Invalid Absolute' }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
expect(response[:msg]).to eq('Exactly one parameter required: expiry > relative or expiry > absolute')
|
response[:msg].should == 'Expiry absolute must be compatible to ISO 8601'
|
||||||
|
response[:results][0][:value].should == 'Invalid Absolute'
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
@zone.messages.queued.count.should == msg_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not allow both relative and absolute' do
|
||||||
|
msg_count = @zone.messages.queued.count
|
||||||
|
xml = epp_xml.keyrelay({
|
||||||
|
name: { value: domain.name },
|
||||||
|
keyData: {
|
||||||
|
flags: { value: '256' },
|
||||||
|
protocol: { value: '3' },
|
||||||
|
alg: { value: '8' },
|
||||||
|
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||||
|
},
|
||||||
|
authInfo: {
|
||||||
|
pw: { value: domain.auth_info }
|
||||||
|
},
|
||||||
|
expiry: {
|
||||||
|
relative: { value: 'P1D' },
|
||||||
|
absolute: { value: '2014-12-23' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
|
response[:msg].should == 'Exactly one parameter required: expiry > relative or expiry > absolute'
|
||||||
|
|
||||||
|
@zone.messages.queued.count.should == msg_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,159 +1,158 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Poll', epp: true do
|
describe 'EPP Poll', epp: true do
|
||||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
|
||||||
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
|
||||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
|
||||||
let(:zone) { Fabricate(:registrar) }
|
|
||||||
let(:epp_xml) { EppXml::Session.new }
|
let(:epp_xml) { EppXml::Session.new }
|
||||||
|
|
||||||
before(:each) { create_settings }
|
def registrar1
|
||||||
|
@registrar1 ||= Registrar.where(reg_no: '12345678').first || Fabricate(:registrar)
|
||||||
|
end
|
||||||
|
|
||||||
context 'with valid user' do
|
def registrar2
|
||||||
before(:each) do
|
@registrar2 ||= Fabricate(:registrar, { name: 'registrar2', reg_no: '123' })
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
end
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
|
||||||
|
before(:all) do
|
||||||
|
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||||
|
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||||
|
|
||||||
|
login_as :registrar1
|
||||||
|
|
||||||
|
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||||
|
|
||||||
|
create_settings
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns no messages in poll' do
|
||||||
|
ApiLog::EppLog.delete_all
|
||||||
|
response = epp_plain_request(epp_xml.poll, :xml)
|
||||||
|
|
||||||
|
response[:msg].should == 'Command completed successfully; no messages'
|
||||||
|
response[:result_code].should == '1300'
|
||||||
|
|
||||||
|
log = ApiLog::EppLog.last
|
||||||
|
|
||||||
|
log.request_command.should == 'poll'
|
||||||
|
log.request_object.should == 'poll'
|
||||||
|
log.request_successful.should == true
|
||||||
|
log.api_user_name.should == 'registrar1'
|
||||||
|
log.api_user_registrar.should == 'Registrar OÜ'
|
||||||
|
log.request.should_not be_blank
|
||||||
|
log.response.should_not be_blank
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'queues and dequeues messages' do
|
||||||
|
msg = registrar1.messages.create({ body: 'Balance low.' })
|
||||||
|
|
||||||
|
response = login_as :registrar2 do
|
||||||
|
epp_plain_request(epp_xml.poll, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns no messages in poll' do
|
response[:msg].should == 'Command completed successfully; no messages'
|
||||||
response = epp_request(epp_xml.poll, :xml)
|
response[:result_code].should == '1300'
|
||||||
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully; no messages')
|
response = epp_plain_request(epp_xml.poll, :xml)
|
||||||
expect(response[:result_code]).to eq('1300')
|
response[:msg].should == 'Command completed successfully; ack to dequeue'
|
||||||
|
response[:result_code].should == '1301'
|
||||||
|
msg_q = response[:parsed].css('msgQ')
|
||||||
|
|
||||||
log = ApiLog::EppLog.all
|
msg_q.css('msg').text.should == 'Balance low.'
|
||||||
|
msg_q.first['count'].should == '1'
|
||||||
|
msg_q.first['id'].should == msg.id.to_s
|
||||||
|
|
||||||
expect(log.length).to eq(4)
|
xml = epp_xml.poll(poll: {
|
||||||
expect(log[0].request_command).to eq('hello')
|
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
||||||
expect(log[0].request_successful).to eq(true)
|
})
|
||||||
|
|
||||||
expect(log[1].request_command).to eq('login')
|
response = login_as :registrar2 do
|
||||||
expect(log[1].request_successful).to eq(true)
|
epp_plain_request(xml, :xml)
|
||||||
expect(log[1].api_user_name).to eq('zone')
|
|
||||||
expect(log[1].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
|
|
||||||
expect(log[2].request_command).to eq('poll')
|
|
||||||
expect(log[2].request_object).to eq('poll')
|
|
||||||
expect(log[2].request_successful).to eq(true)
|
|
||||||
expect(log[2].api_user_name).to eq('zone')
|
|
||||||
expect(log[2].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
expect(log[2].request).not_to be_blank
|
|
||||||
expect(log[2].response).not_to be_blank
|
|
||||||
|
|
||||||
expect(log[3].request_command).to eq('logout')
|
|
||||||
expect(log[3].request_successful).to eq(true)
|
|
||||||
expect(log[3].api_user_name).to eq('zone')
|
|
||||||
expect(log[3].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'queues and dequeues messages' do
|
response[:results][0][:msg].should == 'Message was not found'
|
||||||
msg = zone.messages.create({ body: 'Balance low.' })
|
response[:results][0][:result_code].should == '2303'
|
||||||
|
response[:results][0][:value].should == msg_q.first['id']
|
||||||
|
|
||||||
response = epp_request(epp_xml.poll, :xml, :elkdata)
|
response = epp_plain_request(xml, :xml)
|
||||||
expect(response[:msg]).to eq('Command completed successfully; no messages')
|
response[:msg].should == 'Command completed successfully'
|
||||||
expect(response[:result_code]).to eq('1300')
|
msg_q = response[:parsed].css('msgQ')
|
||||||
|
msg_q.first['id'].should_not be_blank
|
||||||
|
msg_q.first['count'].should == '0'
|
||||||
|
|
||||||
response = epp_request(epp_xml.poll, :xml, :zone)
|
response = epp_plain_request(xml, :xml)
|
||||||
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
|
response[:results][0][:msg].should == 'Message was not found'
|
||||||
expect(response[:result_code]).to eq('1301')
|
response[:results][0][:result_code].should == '2303'
|
||||||
msg_q = response[:parsed].css('msgQ')
|
response[:results][0][:value].should == msg_q.first['id']
|
||||||
|
end
|
||||||
|
|
||||||
expect(msg_q.css('msg').text).to eq('Balance low.')
|
it 'returns an error on incorrect op' do
|
||||||
expect(msg_q.first['count']).to eq('1')
|
xml = epp_xml.poll(poll: {
|
||||||
expect(msg_q.first['id']).to eq(msg.id.to_s)
|
value: '', attrs: { op: 'bla' }
|
||||||
|
})
|
||||||
|
|
||||||
xml = epp_xml.poll(poll: {
|
response = epp_plain_request(xml, :xml)
|
||||||
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
response[:msg].should == 'Attribute op is invalid'
|
||||||
})
|
end
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
it 'dequeues multiple messages' do
|
||||||
expect(response[:results][0][:msg]).to eq('Message was not found')
|
registrar1.messages.create({ body: 'Balance low.' })
|
||||||
expect(response[:results][0][:result_code]).to eq('2303')
|
registrar1.messages.create({ body: 'Something.' })
|
||||||
expect(response[:results][0][:value]).to eq(msg_q.first['id'])
|
registrar1.messages.create({ body: 'Smth else.' })
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
response = epp_plain_request(epp_xml.poll, :xml)
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:msg].should == 'Command completed successfully; ack to dequeue'
|
||||||
msg_q = response[:parsed].css('msgQ')
|
response[:result_code].should == '1301'
|
||||||
expect(msg_q.first['id']).to_not be_blank
|
msg_q = response[:parsed].css('msgQ')
|
||||||
expect(msg_q.first['count']).to eq('0')
|
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
msg_q.css('msg').text.should == 'Smth else.'
|
||||||
expect(response[:results][0][:msg]).to eq('Message was not found')
|
msg_q.first['count'].should == '3'
|
||||||
expect(response[:results][0][:result_code]).to eq('2303')
|
|
||||||
expect(response[:results][0][:value]).to eq(msg_q.first['id'])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns an error on incorrect op' do
|
xml = epp_xml.poll(poll: {
|
||||||
xml = epp_xml.poll(poll: {
|
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
||||||
value: '', attrs: { op: 'bla' }
|
})
|
||||||
})
|
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
response = epp_plain_request(xml, :xml)
|
||||||
expect(response[:msg]).to eq('Attribute op is invalid')
|
response[:msg].should == 'Command completed successfully'
|
||||||
end
|
msg_q = response[:parsed].css('msgQ')
|
||||||
|
msg_q.first['id'].should_not be_blank
|
||||||
|
msg_q.first['count'].should == '2'
|
||||||
|
|
||||||
it 'dequeues multiple messages' do
|
response = epp_plain_request(epp_xml.poll, :xml)
|
||||||
zone.messages.create({ body: 'Balance low.' })
|
response[:msg].should == 'Command completed successfully; ack to dequeue'
|
||||||
zone.messages.create({ body: 'Something.' })
|
response[:result_code].should == '1301'
|
||||||
zone.messages.create({ body: 'Smth else.' })
|
msg_q = response[:parsed].css('msgQ')
|
||||||
|
|
||||||
response = epp_request(epp_xml.poll, :xml, :zone)
|
msg_q.css('msg').text.should == 'Something.'
|
||||||
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
|
msg_q.first['count'].should == '2'
|
||||||
expect(response[:result_code]).to eq('1301')
|
|
||||||
msg_q = response[:parsed].css('msgQ')
|
|
||||||
|
|
||||||
expect(msg_q.css('msg').text).to eq('Smth else.')
|
xml = epp_xml.poll(poll: {
|
||||||
expect(msg_q.first['count']).to eq('3')
|
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
||||||
|
})
|
||||||
|
|
||||||
xml = epp_xml.poll(poll: {
|
response = epp_plain_request(xml, :xml)
|
||||||
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
response[:msg].should == 'Command completed successfully'
|
||||||
})
|
msg_q = response[:parsed].css('msgQ')
|
||||||
|
msg_q.first['id'].should_not be_blank
|
||||||
|
msg_q.first['count'].should == '1'
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
response = epp_plain_request(epp_xml.poll, :xml)
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:msg].should == 'Command completed successfully; ack to dequeue'
|
||||||
msg_q = response[:parsed].css('msgQ')
|
response[:result_code].should == '1301'
|
||||||
expect(msg_q.first['id']).to_not be_blank
|
msg_q = response[:parsed].css('msgQ')
|
||||||
expect(msg_q.first['count']).to eq('2')
|
|
||||||
|
|
||||||
response = epp_request(epp_xml.poll, :xml, :zone)
|
msg_q.css('msg').text.should == 'Balance low.'
|
||||||
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
|
msg_q.first['count'].should == '1'
|
||||||
expect(response[:result_code]).to eq('1301')
|
|
||||||
msg_q = response[:parsed].css('msgQ')
|
|
||||||
|
|
||||||
expect(msg_q.css('msg').text).to eq('Something.')
|
xml = epp_xml.poll(poll: {
|
||||||
expect(msg_q.first['count']).to eq('2')
|
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
||||||
|
})
|
||||||
|
|
||||||
xml = epp_xml.poll(poll: {
|
response = epp_plain_request(xml, :xml)
|
||||||
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
response[:msg].should == 'Command completed successfully'
|
||||||
})
|
msg_q = response[:parsed].css('msgQ')
|
||||||
|
msg_q.first['id'].should_not be_blank
|
||||||
|
msg_q.first['count'].should == '0'
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
response = epp_plain_request(epp_xml.poll, :xml)
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
response[:msg].should == 'Command completed successfully; no messages'
|
||||||
msg_q = response[:parsed].css('msgQ')
|
response[:result_code].should == '1300'
|
||||||
expect(msg_q.first['id']).to_not be_blank
|
|
||||||
expect(msg_q.first['count']).to eq('1')
|
|
||||||
|
|
||||||
response = epp_request(epp_xml.poll, :xml, :zone)
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully; ack to dequeue')
|
|
||||||
expect(response[:result_code]).to eq('1301')
|
|
||||||
msg_q = response[:parsed].css('msgQ')
|
|
||||||
|
|
||||||
expect(msg_q.css('msg').text).to eq('Balance low.')
|
|
||||||
expect(msg_q.first['count']).to eq('1')
|
|
||||||
|
|
||||||
xml = epp_xml.poll(poll: {
|
|
||||||
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
|
|
||||||
})
|
|
||||||
|
|
||||||
response = epp_request(xml, :xml, :zone)
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
|
||||||
msg_q = response[:parsed].css('msgQ')
|
|
||||||
expect(msg_q.first['id']).to_not be_blank
|
|
||||||
expect(msg_q.first['count']).to eq('0')
|
|
||||||
|
|
||||||
response = epp_request(epp_xml.poll, :xml, :zone)
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully; no messages')
|
|
||||||
expect(response[:result_code]).to eq('1300')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,86 +1,85 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Session', epp: true do
|
describe 'EPP Session', epp: true do
|
||||||
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
before :all do
|
||||||
let(:epp_xml) { EppXml.new(cl_trid: 'ABC-12345') }
|
@epp_user = Fabricate(:epp_user)
|
||||||
let(:login_xml_cache) { epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' }) }
|
@epp_xml = EppXml.new(cl_trid: 'ABC-12345')
|
||||||
|
@login_xml_cache = @epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' })
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context 'when not connected' do
|
context 'when not connected' do
|
||||||
it 'greets client upon connection' do
|
it 'greets client upon connection' do
|
||||||
response = Nokogiri::XML(server_gitlab.open_connection)
|
response = Nokogiri::XML(server.open_connection)
|
||||||
expect(response.css('epp svID').text).to eq('EPP server (EIS)')
|
response.css('epp svID').text.should == 'EPP server (EIS)'
|
||||||
server_gitlab.close_connection
|
|
||||||
|
|
||||||
puts "RESPONSE:\n\n```xml\n#{response}```\n\n" if ENV['EPP_DOC']
|
puts "RESPONSE:\n\n```xml\n#{response}```\n\n" if ENV['EPP_DOC']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when connected' do
|
context 'when connected' do
|
||||||
before(:each) { server_gitlab.open_connection }
|
before do
|
||||||
after(:each) { server_gitlab.close_connection }
|
server.open_connection
|
||||||
|
|
||||||
context 'with valid user' do
|
|
||||||
before(:each) { Fabricate(:epp_user) }
|
|
||||||
|
|
||||||
it 'logs in epp user' do
|
|
||||||
response = epp_plain_request(login_xml_cache, :xml)
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'logs out epp user' do
|
|
||||||
epp_plain_request(login_xml_cache, :xml)
|
|
||||||
|
|
||||||
expect(EppSession.first[:epp_user_id]).to eq(1)
|
|
||||||
response = epp_plain_request(epp_xml.session.logout, :xml)
|
|
||||||
expect(response[:result_code]).to eq('1500')
|
|
||||||
expect(response[:msg]).to eq('Command completed successfully; ending session')
|
|
||||||
|
|
||||||
expect(EppSession.first[:epp_user_id]).to eq(nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not log in twice' do
|
|
||||||
epp_plain_request(login_xml_cache, :xml)
|
|
||||||
|
|
||||||
response = epp_plain_request(login_xml_cache, :xml)
|
|
||||||
expect(response[:result_code]).to eq('2002')
|
|
||||||
expect(response[:msg]).to match(/Already logged in. Use/)
|
|
||||||
|
|
||||||
log = ApiLog::EppLog.all
|
|
||||||
expect(log.length).to eq(3)
|
|
||||||
expect(log[0].request_command).to eq('hello')
|
|
||||||
expect(log[0].request_successful).to eq(true)
|
|
||||||
|
|
||||||
expect(log[1].request_command).to eq('login')
|
|
||||||
expect(log[1].request_successful).to eq(true)
|
|
||||||
expect(log[1].api_user_name).to eq('gitlab')
|
|
||||||
expect(log[1].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
|
|
||||||
expect(log[2].request_command).to eq('login')
|
|
||||||
expect(log[2].request_successful).to eq(false)
|
|
||||||
expect(log[2].api_user_name).to eq('gitlab')
|
|
||||||
expect(log[2].api_user_registrar).to eq('Registrar OÜ')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not log in with invalid user' do
|
it 'does not log in with invalid user' do
|
||||||
response = epp_plain_request(login_xml_cache, :xml)
|
wrong_user = @epp_xml.session.login(clID: { value: 'wrong-user' }, pw: { value: 'ghyt9e4fu' })
|
||||||
expect(response[:result_code]).to eq('2501')
|
response = epp_plain_request(wrong_user, :xml)
|
||||||
expect(response[:msg]).to eq('Authentication error; server closing connection')
|
response[:msg].should == 'Authentication error; server closing connection'
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
response[:result_code].should == '2501'
|
||||||
|
response[:clTRID].should == 'ABC-12345'
|
||||||
|
end
|
||||||
|
|
||||||
Fabricate(:epp_user, active: false)
|
it 'does not log in with inactive user' do
|
||||||
|
@registrar = Fabricate(:registrar, { name: 'registrar1', reg_no: '123' })
|
||||||
|
Fabricate(:epp_user, username: 'inactive-user', active: false, registrar: @registrar)
|
||||||
|
|
||||||
response = epp_plain_request(login_xml_cache, :xml)
|
inactive = @epp_xml.session.login(clID: { value: 'inactive-user' }, pw: { value: 'ghyt9e4fu' })
|
||||||
expect(response[:result_code]).to eq('2501')
|
response = epp_plain_request(inactive, :xml)
|
||||||
|
response[:result_code].should == '2501'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prohibits further actions unless logged in' do
|
it 'prohibits further actions unless logged in' do
|
||||||
response = epp_plain_request(epp_xml.domain.create, :xml)
|
response = epp_plain_request(@epp_xml.domain.create, :xml)
|
||||||
expect(response[:result_code]).to eq('2002')
|
response[:msg].should == 'You need to login first.'
|
||||||
expect(response[:msg]).to eq('You need to login first.')
|
response[:result_code].should == '2002'
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
response[:clTRID].should == 'ABC-12345'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with valid user' do
|
||||||
|
it 'logs in epp user' do
|
||||||
|
response = epp_plain_request(@login_xml_cache, :xml)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
response[:clTRID].should == 'ABC-12345'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not log in twice' do
|
||||||
|
response = epp_plain_request(@login_xml_cache, :xml)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
response[:clTRID].should == 'ABC-12345'
|
||||||
|
|
||||||
|
response = epp_plain_request(@login_xml_cache, :xml)
|
||||||
|
response[:msg].should match(/Already logged in. Use/)
|
||||||
|
response[:result_code].should == '2002'
|
||||||
|
|
||||||
|
log = ApiLog::EppLog.last
|
||||||
|
log.request_command.should == 'login'
|
||||||
|
log.request_successful.should == false
|
||||||
|
log.api_user_name.should == 'gitlab'
|
||||||
|
log.api_user_registrar.should == 'Registrar OÜ'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'logs out epp user' do
|
||||||
|
epp_plain_request(@login_xml_cache, :xml)
|
||||||
|
|
||||||
|
EppSession.last[:epp_user_id].should == 1
|
||||||
|
response = epp_plain_request(@epp_xml.session.logout, :xml)
|
||||||
|
response[:msg].should == 'Command completed successfully; ending session'
|
||||||
|
response[:result_code].should == '1500'
|
||||||
|
|
||||||
|
EppSession.last[:epp_user_id].should == nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
Fabricator(:contact) do
|
Fabricator(:contact) do
|
||||||
name Faker::Name.name
|
name { sequence(:name) { |i| "#{Faker::Name.name}#{i}" } }
|
||||||
phone '+372.12345678'
|
phone '+372.12345678'
|
||||||
email Faker::Internet.email
|
email Faker::Internet.email
|
||||||
ident '37605030299'
|
ident '37605030299'
|
||||||
code { "sh#{Faker::Number.number(4)}" }
|
code { "sh#{Faker::Number.number(8)}" }
|
||||||
ident_type 'op'
|
ident_type 'op'
|
||||||
auth_info 'ccds4324pok'
|
auth_info 'ccds4324pok'
|
||||||
address
|
address
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Contact do
|
describe Contact do
|
||||||
|
before :all do
|
||||||
|
# DatabaseCleaner.clean_with(:truncation)
|
||||||
|
# DatabaseCleaner.strategy = :transaction
|
||||||
|
end
|
||||||
|
|
||||||
before { create_disclosure_settings }
|
before { create_disclosure_settings }
|
||||||
it { should have_one(:address) }
|
it { should have_one(:address) }
|
||||||
|
|
||||||
|
@ -76,6 +81,11 @@ describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with callbacks' do
|
context 'with callbacks' do
|
||||||
|
before :all do
|
||||||
|
Contact.set_callback(:create, :before, :generate_code)
|
||||||
|
Contact.set_callback(:create, :before, :generate_auth_info)
|
||||||
|
end
|
||||||
|
|
||||||
before(:each) { @contact = Fabricate.build(:contact, code: '123asd', auth_info: 'qwe321') }
|
before(:each) { @contact = Fabricate.build(:contact, code: '123asd', auth_info: 'qwe321') }
|
||||||
|
|
||||||
context 'after create' do
|
context 'after create' do
|
||||||
|
|
|
@ -15,52 +15,52 @@ describe Domain do
|
||||||
create_settings
|
create_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates domain name', skip: true do
|
# it 'validates domain name', skip: true do
|
||||||
d = Fabricate(:domain)
|
# d = Fabricate(:domain)
|
||||||
expect(d.name).to_not be_nil
|
# expect(d.name).to_not be_nil
|
||||||
|
|
||||||
invalid = ['a.ee', "#{'a' * 64}.ee", 'ab.eu', 'test.ab.ee', '-test.ee', '-test-.ee', 'test-.ee', 'te--st.ee',
|
# invalid = ['a.ee', "#{'a' * 64}.ee", 'ab.eu', 'test.ab.ee', '-test.ee', '-test-.ee', 'test-.ee', 'te--st.ee',
|
||||||
'õ.pri.ee', 'test.com', 'www.ab.ee', 'test.eu', ' .ee', 'a b.ee', 'Ž .ee', 'test.edu.ee']
|
# 'õ.pri.ee', 'test.com', 'www.ab.ee', 'test.eu', ' .ee', 'a b.ee', 'Ž .ee', 'test.edu.ee']
|
||||||
|
|
||||||
invalid.each do |x|
|
# invalid.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be false
|
# expect(Fabricate.build(:domain, name: x).valid?).to be false
|
||||||
end
|
# end
|
||||||
|
|
||||||
valid = ['ab.ee', "#{'a' * 63}.ee", 'te-s-t.ee', 'jäääär.ee', 'päike.pri.ee',
|
# valid = ['ab.ee', "#{'a' * 63}.ee", 'te-s-t.ee', 'jäääär.ee', 'päike.pri.ee',
|
||||||
'õigus.com.ee', 'õäöü.fie.ee', 'test.med.ee', 'žä.ee', ' ŽŠ.ee ']
|
# 'õigus.com.ee', 'õäöü.fie.ee', 'test.med.ee', 'žä.ee', ' ŽŠ.ee ']
|
||||||
|
|
||||||
valid.each do |x|
|
# valid.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be true
|
# expect(Fabricate.build(:domain, name: x).valid?).to be true
|
||||||
end
|
# end
|
||||||
|
|
||||||
invalid_punycode = ['xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-4we.pri.ee']
|
# invalid_punycode = ['xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-4we.pri.ee']
|
||||||
|
|
||||||
invalid_punycode.each do |x|
|
# invalid_punycode.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be false
|
# expect(Fabricate.build(:domain, name: x).valid?).to be false
|
||||||
end
|
# end
|
||||||
|
|
||||||
valid_punycode = ['xn--ge-uia.pri.ee', 'xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-9te.pri.ee']
|
# valid_punycode = ['xn--ge-uia.pri.ee', 'xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-9te.pri.ee']
|
||||||
|
|
||||||
valid_punycode.each do |x|
|
# valid_punycode.each do |x|
|
||||||
expect(Fabricate.build(:domain, name: x).valid?).to be true
|
# expect(Fabricate.build(:domain, name: x).valid?).to be true
|
||||||
end
|
# end
|
||||||
|
|
||||||
d = Domain.new
|
# d = Domain.new
|
||||||
expect(d.valid?).to be false
|
# expect(d.valid?).to be false
|
||||||
expect(d.errors.messages).to match_array({
|
# expect(d.errors.messages).to match_array({
|
||||||
owner_contact: ['Registrant is missing'],
|
# owner_contact: ['Registrant is missing'],
|
||||||
admin_contacts: ['Admin contacts count must be between 1 - infinity'],
|
# admin_contacts: ['Admin contacts count must be between 1 - infinity'],
|
||||||
nameservers: ['Nameservers count must be between 2-11'],
|
# nameservers: ['Nameservers count must be between 2-11'],
|
||||||
registrar: ['Registrar is missing'],
|
# registrar: ['Registrar is missing'],
|
||||||
period: ['Period is not a number']
|
# period: ['Period is not a number']
|
||||||
})
|
# })
|
||||||
|
|
||||||
Setting.ns_min_count = 2
|
# Setting.ns_min_count = 2
|
||||||
Setting.ns_max_count = 7
|
# Setting.ns_max_count = 7
|
||||||
|
|
||||||
expect(d.valid?).to be false
|
# expect(d.valid?).to be false
|
||||||
expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
# expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
||||||
end
|
# end
|
||||||
|
|
||||||
it 'downcases domain' do
|
it 'downcases domain' do
|
||||||
d = Domain.new(name: 'TesT.Ee')
|
d = Domain.new(name: 'TesT.Ee')
|
||||||
|
|
|
@ -33,17 +33,18 @@ RSpec.configure do |config|
|
||||||
|
|
||||||
config.before(:suite) do
|
config.before(:suite) do
|
||||||
ActiveRecord::Base.establish_connection :api_log_test
|
ActiveRecord::Base.establish_connection :api_log_test
|
||||||
DatabaseCleaner.strategy = :deletion
|
DatabaseCleaner.clean_with(:truncation)
|
||||||
|
DatabaseCleaner.strategy = nil
|
||||||
|
|
||||||
ActiveRecord::Base.establish_connection :test
|
ActiveRecord::Base.establish_connection :test
|
||||||
DatabaseCleaner.strategy = :truncation
|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:all) do
|
||||||
DatabaseCleaner.strategy = :transaction
|
DatabaseCleaner.clean_with(:truncation)
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each, epp: true) do
|
config.before(:all, epp: true) do
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each, js: true) do
|
config.before(:each, js: true) do
|
||||||
|
@ -54,19 +55,12 @@ RSpec.configure do |config|
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each, type: :model) do
|
||||||
ActiveRecord::Base.establish_connection :api_log_test
|
DatabaseCleaner.strategy = :transaction
|
||||||
DatabaseCleaner.start
|
|
||||||
|
|
||||||
ActiveRecord::Base.establish_connection :test
|
|
||||||
DatabaseCleaner.start
|
DatabaseCleaner.start
|
||||||
end
|
end
|
||||||
|
|
||||||
config.after(:each) do
|
config.after(:each, type: :model) do
|
||||||
ActiveRecord::Base.establish_connection :api_log_test
|
|
||||||
DatabaseCleaner.clean
|
|
||||||
|
|
||||||
ActiveRecord::Base.establish_connection :test
|
|
||||||
DatabaseCleaner.clean
|
DatabaseCleaner.clean
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,6 +82,6 @@ RSpec.configure do |config|
|
||||||
config.infer_spec_type_from_file_location!
|
config.infer_spec_type_from_file_location!
|
||||||
|
|
||||||
config.expect_with :rspec do |c|
|
config.expect_with :rspec do |c|
|
||||||
c.syntax = :expect
|
c.syntax = [:should, :expect]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe Repp::DomainV1 do
|
||||||
# TODO: Maybe there is a way not to convert from and to json again
|
# TODO: Maybe there is a way not to convert from and to json again
|
||||||
expect(body['domains'].to_json).to eq(epp_user.registrar.domains.to_json)
|
expect(body['domains'].to_json).to eq(epp_user.registrar.domains.to_json)
|
||||||
|
|
||||||
log = ApiLog::ReppLog.first
|
log = ApiLog::ReppLog.last
|
||||||
expect(log[:request_path]).to eq('/repp/v1/domains')
|
expect(log[:request_path]).to eq('/repp/v1/domains')
|
||||||
expect(log[:request_method]).to eq('GET')
|
expect(log[:request_method]).to eq('GET')
|
||||||
expect(log[:request_params]).to eq('{}')
|
expect(log[:request_params]).to eq('{}')
|
||||||
|
|
|
@ -1,4 +1,47 @@
|
||||||
module Epp
|
module Epp
|
||||||
|
# Example usage:
|
||||||
|
#
|
||||||
|
# login_as :gitlab
|
||||||
|
#
|
||||||
|
# Use block for temp login:
|
||||||
|
#
|
||||||
|
# login_as :registrar1 do
|
||||||
|
# your test code
|
||||||
|
# # will make request as registrar1 and logins back to previous session
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
def login_as(user)
|
||||||
|
server.open_connection
|
||||||
|
|
||||||
|
if block_given?
|
||||||
|
begin
|
||||||
|
epp_plain_request(login_xml_for(user), :xml)
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
server.open_connection # return back to last login
|
||||||
|
epp_plain_request(login_xml_for(@last_user), :xml)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@last_user = user # save for block
|
||||||
|
epp_plain_request(login_xml_for(user), :xml)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def login_xml_for(user)
|
||||||
|
@xml ||= EppXml.new(cl_trid: 'ABC-12345')
|
||||||
|
case user
|
||||||
|
when :gitlab
|
||||||
|
@gitlab_login_xml ||=
|
||||||
|
@xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' })
|
||||||
|
when :registrar1
|
||||||
|
@registrar1_login_xml ||=
|
||||||
|
@xml.session.login(clID: { value: 'registrar1' }, pw: { value: 'ghyt9e4fu' })
|
||||||
|
when :registrar2
|
||||||
|
@registrar2_login_xml ||=
|
||||||
|
@xml.session.login(clID: { value: 'registrar2' }, pw: { value: 'ghyt9e4fu' })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def read_body(filename)
|
def read_body(filename)
|
||||||
File.read("spec/epp/requests/#{filename}")
|
File.read("spec/epp/requests/#{filename}")
|
||||||
end
|
end
|
||||||
|
@ -23,10 +66,6 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
def epp_plain_request(data, *args)
|
def epp_plain_request(data, *args)
|
||||||
server = server_gitlab
|
|
||||||
server = server_elkdata if args.include?(:elkdata)
|
|
||||||
server = server_zone if args.include?(:zone)
|
|
||||||
|
|
||||||
res = parse_response(server.send_request(data)) if args.include?(:xml)
|
res = parse_response(server.send_request(data)) if args.include?(:xml)
|
||||||
if res
|
if res
|
||||||
log(data, res[:parsed])
|
log(data, res[:parsed])
|
||||||
|
@ -39,6 +78,11 @@ module Epp
|
||||||
rescue => e
|
rescue => e
|
||||||
e
|
e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def server
|
||||||
|
# tag and password not in use, add those at login xml
|
||||||
|
@server ||= Epp::Server.new({ server: 'localhost', port: 701, tag: '', password: '' })
|
||||||
|
end
|
||||||
|
|
||||||
def parse_response(raw)
|
def parse_response(raw)
|
||||||
res = Nokogiri::XML(raw)
|
res = Nokogiri::XML(raw)
|
||||||
|
@ -67,11 +111,15 @@ module Epp
|
||||||
puts r[:parsed].to_s
|
puts r[:parsed].to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def next_domain_name
|
||||||
|
"example#{@uniq_no.call}.ee"
|
||||||
|
end
|
||||||
|
|
||||||
### REQUEST TEMPLATES ###
|
### REQUEST TEMPLATES ###
|
||||||
|
|
||||||
def domain_info_xml(xml_params = {})
|
def domain_info_xml(xml_params = {})
|
||||||
defaults = {
|
defaults = {
|
||||||
name: { value: 'example.ee', attrs: { hosts: 'all' } },
|
name: { value: next_domain_name, attrs: { hosts: 'all' } },
|
||||||
authInfo: {
|
authInfo: {
|
||||||
pw: { value: '2fooBAR' }
|
pw: { value: '2fooBAR' }
|
||||||
}
|
}
|
||||||
|
@ -86,7 +134,7 @@ module Epp
|
||||||
# rubocop: disable Metrics/MethodLength
|
# rubocop: disable Metrics/MethodLength
|
||||||
def domain_create_xml(xml_params = {}, dnssec_params = {})
|
def domain_create_xml(xml_params = {}, dnssec_params = {})
|
||||||
defaults = {
|
defaults = {
|
||||||
name: { value: 'example.ee' },
|
name: { value: next_domain_name },
|
||||||
period: { value: '1', attrs: { unit: 'y' } },
|
period: { value: '1', attrs: { unit: 'y' } },
|
||||||
ns: [
|
ns: [
|
||||||
{
|
{
|
||||||
|
@ -102,7 +150,7 @@ module Epp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
registrant: { value: 'jd1234' },
|
registrant: { value: 'citizen_1234' },
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
||||||
|
@ -138,11 +186,9 @@ module Epp
|
||||||
epp_xml.create(xml_params, dnssec_params, custom_params)
|
epp_xml.create(xml_params, dnssec_params, custom_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_create_xml_with_legal_doc
|
def domain_create_xml_with_legal_doc(xml_params = {})
|
||||||
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
|
defaults = {
|
||||||
|
name: { value: next_domain_name },
|
||||||
epp_xml.create({
|
|
||||||
name: { value: 'example.ee' },
|
|
||||||
period: { value: '1', attrs: { unit: 'y' } },
|
period: { value: '1', attrs: { unit: 'y' } },
|
||||||
ns: [
|
ns: [
|
||||||
{
|
{
|
||||||
|
@ -158,13 +204,19 @@ module Epp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
registrant: { value: 'jd1234' },
|
registrant: { value: 'citizen_1234' },
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
||||||
{ contact: { value: 'sh801333', attrs: { type: 'tech' } } }
|
{ contact: { value: 'sh801333', attrs: { type: 'tech' } } }
|
||||||
]
|
]
|
||||||
}, {}, {
|
}
|
||||||
|
|
||||||
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
|
||||||
|
epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345')
|
||||||
|
|
||||||
|
epp_xml.create(xml_params, {}, {
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
legalDocument: {
|
legalDocument: {
|
||||||
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
|
@ -176,7 +228,7 @@ module Epp
|
||||||
|
|
||||||
def domain_create_with_invalid_ns_ip_xml
|
def domain_create_with_invalid_ns_ip_xml
|
||||||
xml_params = {
|
xml_params = {
|
||||||
name: { value: 'example.ee' },
|
name: { value: next_domain_name },
|
||||||
period: { value: '1', attrs: { unit: 'y' } },
|
period: { value: '1', attrs: { unit: 'y' } },
|
||||||
ns: [
|
ns: [
|
||||||
{
|
{
|
||||||
|
@ -192,7 +244,7 @@ module Epp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
registrant: { value: 'jd1234' },
|
registrant: { value: 'citizen_1234' },
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
||||||
|
@ -220,7 +272,7 @@ module Epp
|
||||||
|
|
||||||
def domain_create_with_host_attrs
|
def domain_create_with_host_attrs
|
||||||
xml_params = {
|
xml_params = {
|
||||||
name: { value: 'example.ee' },
|
name: { value: next_domain_name },
|
||||||
period: { value: '1', attrs: { unit: 'y' } },
|
period: { value: '1', attrs: { unit: 'y' } },
|
||||||
ns: [
|
ns: [
|
||||||
{
|
{
|
||||||
|
@ -236,7 +288,7 @@ module Epp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
registrant: { value: 'jd1234' },
|
registrant: { value: 'citizen_1234' },
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } },
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } },
|
||||||
|
@ -264,7 +316,7 @@ module Epp
|
||||||
|
|
||||||
def domain_update_xml(xml_params = {}, dnssec_params = {}, custom_params = {})
|
def domain_update_xml(xml_params = {}, dnssec_params = {}, custom_params = {})
|
||||||
defaults = {
|
defaults = {
|
||||||
name: { value: 'example.ee' }
|
name: { value: next_domain_name }
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_params = defaults.deep_merge(xml_params)
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
@ -275,7 +327,7 @@ module Epp
|
||||||
def domain_check_xml(xml_params = {})
|
def domain_check_xml(xml_params = {})
|
||||||
defaults = {
|
defaults = {
|
||||||
_anonymus: [
|
_anonymus: [
|
||||||
{ name: { value: 'example.ee' } }
|
{ name: { value: next_domain_name } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
xml_params = defaults.deep_merge(xml_params)
|
xml_params = defaults.deep_merge(xml_params)
|
||||||
|
@ -285,9 +337,9 @@ module Epp
|
||||||
|
|
||||||
def domain_transfer_xml(xml_params = {}, op = 'query', custom_params = {})
|
def domain_transfer_xml(xml_params = {}, op = 'query', custom_params = {})
|
||||||
defaults = {
|
defaults = {
|
||||||
name: { value: 'example.ee' },
|
name: { value: next_domain_name },
|
||||||
authInfo: {
|
authInfo: {
|
||||||
pw: { value: '98oiewslkfkd', attrs: { roid: 'JD1234-REP' } }
|
pw: { value: '98oiewslkfkd', attrs: { roid: 'citizen_1234-REP' } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue