mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 01:03:35 +02:00
Requests in tests can be made by different registrars now
This commit is contained in:
parent
8929072b71
commit
142db654c4
4 changed files with 57 additions and 33 deletions
|
@ -1,11 +1,17 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Contact', epp: true do
|
describe 'EPP Contact', epp: true do
|
||||||
let(:server) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', 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(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||||
|
let(:zone) { Fabricate(:registrar) }
|
||||||
|
|
||||||
context 'with valid user' do
|
context 'with valid user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:epp_user)
|
Fabricate(:epp_user)
|
||||||
|
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||||
|
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||||
Fabricate(:domain_validation_setting_group)
|
Fabricate(:domain_validation_setting_group)
|
||||||
end
|
end
|
||||||
context 'create command' do
|
context 'create command' do
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Domain', epp: true do
|
describe 'EPP Domain', epp: true do
|
||||||
let(:server) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', 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(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||||
|
let(:zone) { Fabricate(:registrar) }
|
||||||
|
|
||||||
context 'with valid user' do
|
context 'with valid user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Fabricate(:epp_user)
|
Fabricate(:epp_user)
|
||||||
|
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||||
|
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||||
|
|
||||||
Fabricate(:domain_validation_setting_group)
|
Fabricate(:domain_validation_setting_group)
|
||||||
Fabricate(:domain_statuses_setting_group)
|
Fabricate(:domain_statuses_setting_group)
|
||||||
end
|
end
|
||||||
|
@ -31,19 +38,12 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
context 'with two epp users' do
|
context 'with two epp users' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
elkdata = Fabricate(
|
|
||||||
:registrar,
|
|
||||||
name: 'Elkdata',
|
|
||||||
reg_no: '123'
|
|
||||||
)
|
|
||||||
|
|
||||||
Fabricate(:epp_user, username: 'elkdata_user', registrar: elkdata)
|
|
||||||
Fabricate(:domain_general_setting_group)
|
Fabricate(:domain_general_setting_group)
|
||||||
Fabricate(:domain, name: 'example.ee', registrar: elkdata)
|
Fabricate(:domain, name: 'example.ee', registrar: zone) # belongs to zone
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can not see other registrar domains' do
|
it 'can not see other registrar domains' do
|
||||||
response = epp_request(domain_info_xml, :xml)
|
response = epp_request(domain_info_xml, :xml, :elkdata)
|
||||||
expect(response[:result_code]).to eq('2303')
|
expect(response[:result_code]).to eq('2303')
|
||||||
expect(response[:msg]).to eq('Domain not found')
|
expect(response[:msg]).to eq('Domain not found')
|
||||||
end
|
end
|
||||||
|
@ -51,23 +51,28 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'transfers a domain' do
|
it 'transfers a domain' do
|
||||||
pw = Domain.first.auth_info
|
pw = Domain.first.auth_info
|
||||||
xml = domain_transfer_xml(pw: pw)
|
xml = domain_transfer_xml(pw: pw)
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
|
|
||||||
d = Domain.first
|
d = Domain.first
|
||||||
dtl = d.domain_transfers.last
|
dtl = d.domain_transfers.last
|
||||||
trn_data = response[:parsed].css('trnData')
|
trn_data = response[:parsed].css('trnData')
|
||||||
expect(trn_data.css('name').text).to eq('example.ee')
|
expect(trn_data.css('name').text).to eq('example.ee')
|
||||||
expect(trn_data.css('trStatus').text).to eq('serverApproved')
|
expect(trn_data.css('trStatus').text).to eq('serverApproved')
|
||||||
expect(trn_data.css('reID').text).to eq('10577829')
|
expect(trn_data.css('reID').text).to eq('123')
|
||||||
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
||||||
expect(trn_data.css('acID').text).to eq('123')
|
expect(trn_data.css('acID').text).to eq('10577829')
|
||||||
expect(trn_data.css('acDate').text).to eq(dtl.transferred_at.to_time.utc.to_s)
|
expect(trn_data.css('acDate').text).to eq(dtl.transferred_at.to_time.utc.to_s)
|
||||||
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
|
|
||||||
|
expect(d.registrar).to eq(elkdata)
|
||||||
|
|
||||||
s = Setting.find_by(code: 'transfer_wait_time')
|
s = Setting.find_by(code: 'transfer_wait_time')
|
||||||
s.update(value: 1)
|
s.update(value: 1)
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
pw = Domain.first.auth_info
|
||||||
|
xml = domain_transfer_xml(pw: pw) # request with new password
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml, :zone)
|
||||||
trn_data = response[:parsed].css('trnData')
|
trn_data = response[:parsed].css('trnData')
|
||||||
|
|
||||||
d = Domain.first
|
d = Domain.first
|
||||||
|
@ -79,11 +84,13 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(trn_data.css('trStatus').text).to eq('pending')
|
expect(trn_data.css('trStatus').text).to eq('pending')
|
||||||
expect(trn_data.css('reID').text).to eq('10577829')
|
expect(trn_data.css('reID').text).to eq('10577829')
|
||||||
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
||||||
expect(trn_data.css('acID').text).to eq('10577829')
|
expect(trn_data.css('acID').text).to eq('123')
|
||||||
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
|
|
||||||
|
expect(d.registrar).to eq(elkdata)
|
||||||
|
|
||||||
# should return same data if pending already
|
# should return same data if pending already
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml, :zone)
|
||||||
trn_data = response[:parsed].css('trnData')
|
trn_data = response[:parsed].css('trnData')
|
||||||
|
|
||||||
expect(d.domain_transfers.count).to eq(2)
|
expect(d.domain_transfers.count).to eq(2)
|
||||||
|
@ -91,11 +98,14 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(trn_data.css('trStatus').text).to eq('pending')
|
expect(trn_data.css('trStatus').text).to eq('pending')
|
||||||
expect(trn_data.css('reID').text).to eq('10577829')
|
expect(trn_data.css('reID').text).to eq('10577829')
|
||||||
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
||||||
expect(trn_data.css('acID').text).to eq('10577829')
|
expect(trn_data.css('acID').text).to eq('123')
|
||||||
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
|
|
||||||
|
expect(d.registrar).to eq(elkdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'approves the transfer request' do
|
it 'approves the transfer request', pending: true do
|
||||||
|
fail 'Check if domain belongs to approving user'
|
||||||
s = Setting.find_by(code: 'transfer_wait_time')
|
s = Setting.find_by(code: 'transfer_wait_time')
|
||||||
s.update(value: 1)
|
s.update(value: 1)
|
||||||
|
|
||||||
|
@ -104,16 +114,16 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
epp_request(xml, :xml)
|
epp_request(xml, :xml)
|
||||||
xml = domain_transfer_xml(op: 'approve', pw: pw)
|
xml = domain_transfer_xml(op: 'approve', pw: pw)
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
trn_data = response[:parsed].css('trnData')
|
trn_data = response[:parsed].css('trnData')
|
||||||
d = Domain.first
|
d = Domain.first
|
||||||
dtl = d.domain_transfers.last
|
dtl = d.domain_transfers.last
|
||||||
|
|
||||||
expect(trn_data.css('name').text).to eq('example.ee')
|
expect(trn_data.css('name').text).to eq('example.ee')
|
||||||
expect(trn_data.css('trStatus').text).to eq('clientApproved')
|
expect(trn_data.css('trStatus').text).to eq('clientApproved')
|
||||||
expect(trn_data.css('reID').text).to eq('10577829')
|
expect(trn_data.css('reID').text).to eq('10577829') # TODO See if this is correct
|
||||||
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
|
||||||
expect(trn_data.css('acID').text).to eq('123')
|
expect(trn_data.css('acID').text).to eq('10577829') # TODO See if this is correct
|
||||||
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Session', epp: true do
|
describe 'EPP Session', epp: true do
|
||||||
let(:server) { server = Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
||||||
|
|
||||||
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.open_connection)
|
response = Nokogiri::XML(server_gitlab.open_connection)
|
||||||
expect(response.css('epp svID').text).to eq('EPP server (DSDng)')
|
expect(response.css('epp svID').text).to eq('EPP server (DSDng)')
|
||||||
server.close_connection
|
server_gitlab.close_connection
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when connected' do
|
context 'when connected' do
|
||||||
before(:each) { server.open_connection }
|
before(:each) { server_gitlab.open_connection }
|
||||||
after(:each) { server.close_connection }
|
after(:each) { server_gitlab.close_connection }
|
||||||
|
|
||||||
it 'does not log in with invalid user' do
|
it 'does not log in with invalid user' do
|
||||||
response = epp_plain_request('login.xml')
|
response = epp_plain_request('login.xml')
|
||||||
|
|
|
@ -4,16 +4,24 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
# handles connection and login automatically
|
# handles connection and login automatically
|
||||||
def epp_request(data, type = :filename)
|
def epp_request(data, *args)
|
||||||
return parse_response(server.request(read_body(data))) if type == :filename
|
server = server_gitlab
|
||||||
return parse_response(server.request(data))
|
server = server_elkdata if args.include?(:elkdata)
|
||||||
|
server = server_zone if args.include?(:zone)
|
||||||
|
|
||||||
|
return parse_response(server.request(data)) if args.include?(:xml)
|
||||||
|
return parse_response(server.request(read_body(data)))
|
||||||
rescue => e
|
rescue => e
|
||||||
e
|
e
|
||||||
end
|
end
|
||||||
|
|
||||||
def epp_plain_request(data, type = :filename)
|
def epp_plain_request(data, *args)
|
||||||
return parse_response(server.send_request(read_body(data))) if type == :filename
|
server = server_gitlab
|
||||||
return parse_response(server.send_request(data))
|
server = server_elkdata if args.include?(:elkdata)
|
||||||
|
server = server_zone if args.include?(:zone)
|
||||||
|
|
||||||
|
return parse_response(server.send_request(data)) if args.include?(:xml)
|
||||||
|
return parse_response(server.send_request(read_body(data)))
|
||||||
rescue => e
|
rescue => e
|
||||||
e
|
e
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue