mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Add test for REPP IP whitelisting
This commit is contained in:
parent
abf47b1e08
commit
9b4e9ca12c
2 changed files with 34 additions and 22 deletions
|
@ -1,9 +1,8 @@
|
|||
Fabricator(:white_ip) do
|
||||
ipv4 '192.168.1.1'
|
||||
ipv4 '127.0.0.1'
|
||||
interface WhiteIp::EPP
|
||||
end
|
||||
|
||||
Fabricator(:white_ip_repp, from: :white_ip) do
|
||||
ipv4 '127.0.0.1'
|
||||
interface WhiteIp::REPP
|
||||
end
|
||||
|
|
|
@ -1,30 +1,43 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Repp::AccountV1 do
|
||||
before :all do
|
||||
@registrar1 = Fabricate(:registrar1, accounts:
|
||||
[Fabricate(:account, { balance: '324.45', account_activities: [] })]
|
||||
)
|
||||
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
|
||||
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
|
||||
|
||||
describe 'GET /repp/v1/accounts/balance' do
|
||||
it 'returns account balance of the current registrar', autodoc: true, route_info_doc: true do
|
||||
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
|
||||
response.status.should == 200
|
||||
context 'with valid registrar' do
|
||||
before :all do
|
||||
@registrar1 = Fabricate(:registrar1, accounts:
|
||||
[Fabricate(:account, { balance: '324.45', account_activities: [] })]
|
||||
)
|
||||
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
|
||||
end
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body['balance'].should == '324.45'
|
||||
body['currency'].should == 'EUR'
|
||||
describe 'GET /repp/v1/accounts/balance' do
|
||||
it 'returns account balance of the current registrar', autodoc: true, route_info_doc: true do
|
||||
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
|
||||
response.status.should == 200
|
||||
|
||||
log = ApiLog::ReppLog.last
|
||||
log[:request_path].should == '/repp/v1/accounts/balance'
|
||||
log[:request_method].should == 'GET'
|
||||
log[:request_params].should == '{}'
|
||||
log[:response_code].should == '200'
|
||||
log[:api_user_name].should == 'gitlab'
|
||||
log[:api_user_registrar].should == 'registrar1'
|
||||
log[:ip].should == '127.0.0.1'
|
||||
body = JSON.parse(response.body)
|
||||
body['balance'].should == '324.45'
|
||||
body['currency'].should == 'EUR'
|
||||
|
||||
log = ApiLog::ReppLog.last
|
||||
log[:request_path].should == '/repp/v1/accounts/balance'
|
||||
log[:request_method].should == 'GET'
|
||||
log[:request_params].should == '{}'
|
||||
log[:response_code].should == '200'
|
||||
log[:api_user_name].should == 'gitlab'
|
||||
log[:api_user_registrar].should == 'registrar1'
|
||||
log[:ip].should == '127.0.0.1'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue