Add test for REPP IP whitelisting

This commit is contained in:
Martin Lensment 2015-05-19 19:24:53 +03:00
parent abf47b1e08
commit 9b4e9ca12c
2 changed files with 34 additions and 22 deletions

View file

@ -1,9 +1,8 @@
Fabricator(:white_ip) do Fabricator(:white_ip) do
ipv4 '192.168.1.1' ipv4 '127.0.0.1'
interface WhiteIp::EPP interface WhiteIp::EPP
end end
Fabricator(:white_ip_repp, from: :white_ip) do Fabricator(:white_ip_repp, from: :white_ip) do
ipv4 '127.0.0.1'
interface WhiteIp::REPP interface WhiteIp::REPP
end end

View file

@ -1,6 +1,18 @@
require 'rails_helper' require 'rails_helper'
describe Repp::AccountV1 do describe Repp::AccountV1 do
it 'should fail without whitelisted IP' do
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip)])
@api_user = Fabricate(:api_user, registrar: @registrar1)
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
response.status.should == 401
body = JSON.parse(response.body)
body['error'].should == 'IP is not whitelisted'
end
context 'with valid registrar' do
before :all do before :all do
@registrar1 = Fabricate(:registrar1, accounts: @registrar1 = Fabricate(:registrar1, accounts:
[Fabricate(:account, { balance: '324.45', account_activities: [] })] [Fabricate(:account, { balance: '324.45', account_activities: [] })]
@ -27,4 +39,5 @@ describe Repp::AccountV1 do
log[:ip].should == '127.0.0.1' log[:ip].should == '127.0.0.1'
end end
end end
end
end end