Merge branch 'master' into registry-727

This commit is contained in:
Artur Beljajev 2018-02-24 08:26:10 +02:00
commit 1e5face668
99 changed files with 1134 additions and 566 deletions

View file

@ -1,5 +1,6 @@
FactoryBot.define do
factory :epp_session do
sequence(:session_id) { |n| "test#{n}" }
association :user, factory: :api_user
end
end

View file

@ -1,5 +0,0 @@
FactoryBot.define do
factory :message do
body 'fabricator body'
end
end

View file

@ -1,21 +0,0 @@
require 'rails_helper'
describe EppSession do
let(:epp_session) { create(:epp_session) }
it 'has marshalled data' do
expect(epp_session.read_attribute(:data)).to_not be_blank
expect(epp_session.read_attribute(:data).class).to eq(String)
expect(epp_session.data.class).to eq(Hash)
end
it 'stores data' do
expect(epp_session[:api_user_id]).to eq(1)
epp_session[:api_user_id] = 3
expect(epp_session[:api_user_id]).to eq(3)
epp_session = EppSession.find_by(session_id: 'test')
expect(epp_session[:api_user_id]).to eq(3)
end
end

View file

@ -1,47 +0,0 @@
require 'rails_helper'
describe Message do
context 'with invalid attribute' do
before :all do
@mssage = Message.new
end
it 'should not be valid' do
@mssage.valid?
@mssage.errors.full_messages.should match_array([
"Body is missing"
])
end
it 'should not have any versions' do
@mssage.versions.should == []
end
end
context 'with valid attributes' do
before :all do
@mssage = create(:message)
end
it 'should be valid' do
@mssage.valid?
@mssage.errors.full_messages.should match_array([])
end
it 'should be valid twice' do
@mssage = create(:message)
@mssage.valid?
@mssage.errors.full_messages.should match_array([])
end
it 'should have one version' do
with_versioning do
@mssage.versions.should == []
@mssage.body = 'New body'
@mssage.save
@mssage.errors.full_messages.should match_array([])
@mssage.versions.size.should == 1
end
end
end
end

View file

@ -1,11 +1,14 @@
require 'rails_helper'
RSpec.describe 'EPP contact:create' do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
before do
Setting.address_processing = false
sign_in_to_epp_area
login_as user
end
context 'when all ident params are valid' do

View file

@ -2,7 +2,10 @@ require 'rails_helper'
require_relative '../shared/phone'
RSpec.describe 'EPP contact:create' do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -27,7 +30,7 @@ RSpec.describe 'EPP contact:create' do
}
before do
sign_in_to_epp_area
login_as user
allow(Contact).to receive(:address_processing?).and_return(false)
end

View file

@ -1,6 +1,9 @@
require 'rails_helper'
RSpec.describe 'EPP contact:create' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request_xml_with_address) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -36,7 +39,7 @@ RSpec.describe 'EPP contact:create' do
subject(:address_saved) { Contact.last.attributes.slice(*Contact.address_attribute_names).compact.any? }
before do
sign_in_to_epp_area
login_as user
end
context 'when address processing is enabled' do
@ -46,17 +49,17 @@ RSpec.describe 'EPP contact:create' do
context 'with address' do
it 'returns epp code of 1000' do
post '/epp/command/create', frame: request_xml_with_address
post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'returns epp description' do
post '/epp/command/create', frame: request_xml_with_address
post '/epp/command/create', { frame: request_xml_with_address}, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully')
end
it 'saves address' do
post '/epp/command/create', frame: request_xml_with_address
post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(address_saved).to be_truthy
end
end
@ -69,17 +72,17 @@ RSpec.describe 'EPP contact:create' do
context 'with address' do
it 'returns epp code of 1100' do
post '/epp/command/create', frame: request_xml_with_address
post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1100')
end
it 'returns epp description' do
post '/epp/command/create', frame: request_xml_with_address
post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully; Postal address data discarded')
end
it 'does not save address' do
post '/epp/command/create', frame: request_xml_with_address
post '/epp/command/create', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(address_saved).to be_falsey
end
end
@ -110,12 +113,12 @@ RSpec.describe 'EPP contact:create' do
}
it 'returns epp code of 1000' do
post '/epp/command/create', frame: request_xml_without_address
post '/epp/command/create', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'returns epp description' do
post '/epp/command/create', frame: request_xml_without_address
post '/epp/command/create', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully')
end
end

View file

@ -1,10 +1,11 @@
require 'rails_helper'
RSpec.describe 'EPP contact:delete' do
let(:session_id) { create(:epp_session, user: user).session_id }
let(:user) { create(:api_user, registrar: registrar) }
let(:registrar) { create(:registrar) }
let!(:registrant) { create(:registrant, registrar: registrar, code: 'TEST') }
let(:request) { post '/epp/command/delete', frame: request_xml }
let(:request) { post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -20,7 +21,7 @@ RSpec.describe 'EPP contact:delete' do
}
before do
sign_in_to_epp_area(user: user)
login_as user
end
context 'when contact is used' do

View file

@ -1,6 +1,9 @@
require 'rails_helper'
RSpec.describe 'EPP contact:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request_xml) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -19,7 +22,7 @@ RSpec.describe 'EPP contact:update' do
.count }
before do
sign_in_to_epp_area
login_as user
create(:contact, code: 'TEST')
end
@ -29,12 +32,12 @@ RSpec.describe 'EPP contact:update' do
end
it 'returns epp code of 1000' do
post '/epp/command/info', frame: request_xml
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'returns address' do
post '/epp/command/info', frame: request_xml
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(address_count).to_not be_zero
end
end
@ -45,12 +48,12 @@ RSpec.describe 'EPP contact:update' do
end
it 'returns epp code of 1000' do
post '/epp/command/info', frame: request_xml
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'does not return address' do
post '/epp/command/info', frame: request_xml
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(address_count).to be_zero
end
end

View file

@ -3,8 +3,11 @@ require 'rails_helper'
# https://github.com/internetee/registry/issues/576
RSpec.describe 'EPP contact:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:ident) { contact.identifier }
let(:request) { post '/epp/command/update', frame: request_xml }
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -30,7 +33,7 @@ RSpec.describe 'EPP contact:update' do
}
before do
sign_in_to_epp_area
login_as user
end
context 'when contact ident is valid' do

View file

@ -2,8 +2,11 @@ require 'rails_helper'
require_relative '../shared/phone'
RSpec.describe 'EPP contact:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let!(:contact) { create(:contact, code: 'TEST') }
let(:request) { post '/epp/command/update', frame: request_xml }
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -22,7 +25,7 @@ RSpec.describe 'EPP contact:update' do
}
before do
sign_in_to_epp_area
login_as user
allow(Contact).to receive(:address_processing?).and_return(false)
end

View file

@ -1,6 +1,9 @@
require 'rails_helper'
RSpec.describe 'EPP contact:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request_xml_with_address) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
@ -33,7 +36,7 @@ RSpec.describe 'EPP contact:update' do
subject(:response_description) { response_xml.css('result msg').text }
before do
sign_in_to_epp_area
login_as user
create(:contact, code: 'TEST')
end
@ -44,12 +47,12 @@ RSpec.describe 'EPP contact:update' do
context 'with address' do
it 'returns epp code of 1000' do
post '/epp/command/update', frame: request_xml_with_address
post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'returns epp description' do
post '/epp/command/update', frame: request_xml_with_address
post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully')
end
end
@ -62,12 +65,12 @@ RSpec.describe 'EPP contact:update' do
context 'with address' do
it 'returns epp code of 1100' do
post '/epp/command/update', frame: request_xml_with_address
post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1100')
end
it 'returns epp description' do
post '/epp/command/update', frame: request_xml_with_address
post '/epp/command/update', { frame: request_xml_with_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully; Postal address data discarded')
end
end
@ -92,12 +95,12 @@ RSpec.describe 'EPP contact:update' do
}
it 'returns epp code of 1000' do
post '/epp/command/update', frame: request_xml_without_address
post '/epp/command/update', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'returns epp description' do
post '/epp/command/update', frame: request_xml_without_address
post '/epp/command/update', { frame: request_xml_without_address }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully')
end
end

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:create', settings: false do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:contact) { create(:contact, code: 'test') }
let!(:zone) { create(:zone, origin: 'test') }
@ -36,7 +37,7 @@ RSpec.describe 'EPP domain:create', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when account balance is sufficient' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:create', settings: false do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:contact) { create(:contact, code: 'test') }
let!(:zone) { create(:zone, origin: 'test') }
@ -37,7 +38,7 @@ RSpec.describe 'EPP domain:create', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010 10:30')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when period is absent' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:create', settings: false do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:registrar) { create(:registrar_with_unlimited_balance) }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:contact) { create(:contact, code: 'test') }
@ -17,7 +18,7 @@ RSpec.describe 'EPP domain:create', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
sign_in_to_epp_area(user: user)
login_as user
end
context 'when nameserver is optional' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:create', settings: false do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:contact) { create(:contact, code: 'test') }
let!(:zone) { create(:zone, origin: 'test') }
@ -10,7 +11,7 @@ RSpec.describe 'EPP domain:create', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010 10:30')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when period is 3 months' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:create', settings: false do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:contact) { create(:contact, code: 'test') }
let!(:zone) { create(:zone, origin: 'test') }
@ -30,7 +31,7 @@ RSpec.describe 'EPP domain:create', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when price is present' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:create', settings: false do
let(:request) { post '/epp/command/create', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:registrar) { create(:registrar_with_unlimited_balance) }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:contact) { create(:contact, code: 'test') }
@ -17,7 +18,7 @@ RSpec.describe 'EPP domain:create', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
sign_in_to_epp_area(user: user)
login_as user
end
context 'when nameserver is required' do

View file

@ -1,6 +1,9 @@
require 'rails_helper'
RSpec.describe 'EPP domain:delete' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -21,14 +24,14 @@ RSpec.describe 'EPP domain:delete' do
}
before :example do
sign_in_to_epp_area
login_as user
end
context 'when domain is not discarded' do
let!(:domain) { create(:domain, name: 'test.com') }
it 'returns epp code of 1001' do
post '/epp/command/delete', frame: request_xml
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(1001)
end
end
@ -37,7 +40,7 @@ RSpec.describe 'EPP domain:delete' do
let!(:domain) { create(:domain_discarded, name: 'test.com') }
it 'returns epp code of 2105' do
post '/epp/command/delete', frame: request_xml
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(2105)
end
end

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew' do
let(:request) { post '/epp/command/renew', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:zone) { create(:zone, origin: 'test') }
let!(:price) { create(:price,
@ -16,7 +17,7 @@ RSpec.describe 'EPP domain:renew' do
before :example do
Setting.days_to_renew_domain_before_expire = 0
travel_to Time.zone.parse('05.07.2010')
sign_in_to_epp_area(user: user)
login_as user
end
context 'when account balance is sufficient' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew', settings: false do
let(:request) { post '/epp/command/renew', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:zone) { create(:zone, origin: 'test') }
let!(:registrar) { create(:registrar_with_unlimited_balance) }
@ -37,7 +38,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when period is absent' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew' do
let(:request) { post '/epp/command/renew', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:registrar) { create(:registrar_with_unlimited_balance) }
let!(:zone) { create(:zone, origin: 'test') }
@ -17,7 +18,7 @@ RSpec.describe 'EPP domain:renew' do
before :example do
Setting.days_to_renew_domain_before_expire = 0
travel_to Time.zone.parse('05.07.2010')
sign_in_to_epp_area(user: user)
login_as user
end
context 'when given expire time and current match' do

View file

@ -1,6 +1,7 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew' do
let(:session_id) { create(:epp_session, user: user).session_id }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:registrar) { create(:registrar_with_unlimited_balance) }
let!(:zone) { create(:zone, origin: 'test') }
@ -19,7 +20,7 @@ RSpec.describe 'EPP domain:renew' do
before :example do
travel_to Time.zone.parse('05.07.2010')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when domain can be renewed' do
@ -45,12 +46,12 @@ RSpec.describe 'EPP domain:renew' do
}
it 'returns epp code of 1000' do
post '/epp/command/renew', frame: request_xml
post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000')
end
it 'returns epp description' do
post '/epp/command/renew', frame: request_xml
post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Command completed successfully')
end
end
@ -78,12 +79,12 @@ RSpec.describe 'EPP domain:renew' do
}
it 'returns epp code of 2105' do
post '/epp/command/renew', frame: request_xml
post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('2105')
end
it 'returns epp description' do
post '/epp/command/renew', frame: request_xml
post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_description).to eq('Object is not eligible for renewal; ' \
'Expiration date must be before 2021-07-05')
end

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew', settings: false do
let(:request) { post '/epp/command/renew', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:zone) { create(:zone, origin: 'test') }
let!(:registrar) { create(:registrar_with_unlimited_balance) }
@ -14,7 +15,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when period is 3 months' do

View file

@ -1,7 +1,8 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew', settings: false do
let(:request) { post '/epp/command/renew', frame: request_xml }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:zone) { create(:zone, origin: 'test') }
let!(:registrar) { create(:registrar_with_unlimited_balance) }
@ -29,7 +30,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
Setting.days_to_renew_domain_before_expire = 0
sign_in_to_epp_area(user: user)
login_as user
end
context 'when price is present' do

View file

@ -1,42 +0,0 @@
require 'rails_helper'
RSpec.describe 'EPP domain:transfer' do
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<transfer op="request">
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>test.com</domain:name>
<domain:authInfo>
<domain:pw>98oiewslkfkd</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
}
before :example do
sign_in_to_epp_area
end
context 'when domain is not discarded' do
let!(:domain) { create(:domain, name: 'test.com') }
it 'returns epp code of 1000' do
post '/epp/command/transfer', frame: request_xml
expect(response).to have_code_of(1000)
end
end
context 'when domain is discarded' do
let!(:domain) { create(:domain_discarded, name: 'test.com') }
it 'returns epp code of 2105' do
post '/epp/command/transfer', frame: request_xml
expect(response).to have_code_of(2105)
end
end
end

View file

@ -1,6 +1,9 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -16,14 +19,14 @@ RSpec.describe 'EPP domain:update' do
}
before :example do
sign_in_to_epp_area
login_as user
end
context 'when domain is not discarded' do
let!(:domain) { create(:domain, name: 'test.com') }
it 'returns epp code of 1000' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(1000)
end
end
@ -32,7 +35,7 @@ RSpec.describe 'EPP domain:update' do
let!(:domain) { create(:domain_discarded, name: 'test.com') }
it 'returns epp code of 2105' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(2105)
end
end

View file

@ -1,13 +1,16 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let!(:domain) { create(:domain, name: 'test.com') }
subject(:response_xml) { Nokogiri::XML(response.body) }
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
subject(:response_description) { response_xml.css('result msg').text }
before :example do
sign_in_to_epp_area
login_as user
allow(Domain).to receive(:nameserver_required?).and_return(false)
Setting.ns_min_count = 2
@ -37,12 +40,12 @@ RSpec.describe 'EPP domain:update' do
}
it 'returns epp code of 2308' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})"
end
it 'returns epp description' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
description = 'Data management policy violation;' \
" Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \
@ -78,12 +81,12 @@ RSpec.describe 'EPP domain:update' do
}
it 'returns epp code of 1000' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
end
it 'removes inactive status' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
domain = Domain.find_by(name: 'test.com')
expect(domain.statuses).to_not include(DomainStatus::INACTIVE)

View file

@ -1,13 +1,15 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
subject(:response_xml) { Nokogiri::XML(response.body) }
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
subject(:response_description) { response_xml.css('result msg').text }
before :example do
sign_in_to_epp_area
login_as user
allow(Domain).to receive(:nameserver_required?).and_return(false)
end
@ -43,12 +45,12 @@ RSpec.describe 'EPP domain:update' do
end
it 'returns epp code of 2308' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('2308'), "Expected EPP code of 2308, got #{response_code} (#{response_description})"
end
it 'returns epp description' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
description = 'Data management policy violation;' \
" Nameserver count must be between #{Setting.ns_min_count}-#{Setting.ns_max_count}" \
@ -91,13 +93,13 @@ RSpec.describe 'EPP domain:update' do
end
it 'returns epp code of 1000' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
end
describe 'domain' do
it 'has status of inactive' do
post '/epp/command/update', frame: request_xml
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
domain = Domain.find_by(name: 'test.com')
expect(domain.statuses).to include(DomainStatus::INACTIVE)
end

View file

@ -1,11 +1,14 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:request) { post '/epp/command/update', frame: request_xml }
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:domain) { create(:domain, name: 'test.com', registrant: registrant) }
before :example do
sign_in_to_epp_area
login_as user
end
context 'when registrant change confirmation is enabled' do

View file

@ -1,13 +1,16 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:request) { post '/epp/command/update', frame: request_xml }
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let!(:registrant) { create(:registrant, code: 'old-code') }
let!(:domain) { create(:domain, name: 'test.com', registrant: registrant) }
let!(:new_registrant) { create(:registrant, code: 'new-code') }
before :example do
sign_in_to_epp_area
login_as user
end
context 'when registrant change confirmation is enabled' do

View file

@ -1,7 +1,10 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:request) { post '/epp/command/update', frame: request_xml }
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -17,7 +20,7 @@ RSpec.describe 'EPP domain:update' do
}
before :example do
sign_in_to_epp_area
login_as user
end
context 'when domain has both SERVER_DELETE_PROHIBITED and PENDING_UPDATE statuses' do

View file

@ -1,34 +1,5 @@
module Requests
module SessionHelpers
def sign_in_to_epp_area(user: create(:api_user_epp))
login_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
<epp xmlns=\"https://epp.tld.ee/schema/epp-ee-1.0.xsd\">
<command>
<login>
<clID>#{user.username}</clID>
<pw>#{user.password}</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<svcs>
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
<svcExtension>
<extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
<extURI>https://epp.tld.ee/schema/eis-1.0.xsd</extURI>
</svcExtension>
</svcs>
</login>
<clTRID>ABC-12345</clTRID>
</command>
</epp>"
post '/epp/session/login', frame: login_xml
end
def sign_in_to_admin_area(user: create(:admin_user))
post admin_sessions_path, admin_user: { username: user.username, password: user.password }
end