Refactor + tests

This commit is contained in:
Martin Lensment 2015-05-20 13:49:34 +03:00
parent dc1ad9e6c5
commit 19e133ec6a
7 changed files with 37 additions and 25 deletions

View file

@ -39,6 +39,19 @@ describe 'EPP Session', epp: true do
response[:result_code].should == '2501'
end
it 'does not log in with ip that is not whitelisted' do
@registrar = Fabricate(:registrar,
{ name: 'registrar123', reg_no: '1234', white_ips: [Fabricate(:white_ip_repp), Fabricate(:white_ip_registrar)] }
)
Fabricate(:api_user, username: 'invalid-ip-user', registrar: @registrar)
inactive = @epp_xml.session.login(clID: { value: 'invalid-ip-user' }, pw: { value: 'ghyt9e4fu' })
response = epp_plain_request(inactive, :xml)
response[:msg].should == 'IP is not whitelisted'
response[:result_code].should == '2501'
end
it 'prohibits further actions unless logged in' do
response = epp_plain_request(@epp_xml.domain.create, :xml)
response[:msg].should == 'You need to login first.'

View file

@ -10,7 +10,7 @@ Fabricator(:registrar) do
code { sequence(:code) { |i| "REGISTRAR#{i}" } }
reference_no { sequence(:reference_no) { |i| "RF#{i}" } }
accounts(count: 1)
white_ips { [Fabricate(:white_ip_repp, ipv4: '127.0.0.1'), Fabricate(:white_ip, ipv4: '127.0.0.1')] }
white_ips { [Fabricate(:white_ip)] }
end
Fabricator(:registrar_with_no_account_activities, from: :registrar) do

View file

@ -1,8 +1,16 @@
Fabricator(:white_ip) do
ipv4 '127.0.0.1'
interface WhiteIp::EPP
interface WhiteIp::GLOBAL
end
Fabricator(:white_ip_repp, from: :white_ip) do
interface WhiteIp::REPP
end
Fabricator(:white_ip_epp, from: :white_ip) do
interface WhiteIp::EPP
end
Fabricator(:white_ip_registrar, from: :white_ip) do
interface WhiteIp::REGISTRAR
end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
describe Repp::AccountV1 do
it 'should fail without whitelisted IP' do
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip)])
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip_epp), Fabricate(:white_ip_registrar)])
@api_user = Fabricate(:api_user, registrar: @registrar1)
get_with_auth '/repp/v1/accounts/balance', {}, @api_user