mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +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
|
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
|
||||||
|
|
|
@ -1,30 +1,43 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Repp::AccountV1 do
|
describe Repp::AccountV1 do
|
||||||
before :all do
|
it 'should fail without whitelisted IP' do
|
||||||
@registrar1 = Fabricate(:registrar1, accounts:
|
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip)])
|
||||||
[Fabricate(:account, { balance: '324.45', account_activities: [] })]
|
@api_user = Fabricate(:api_user, registrar: @registrar1)
|
||||||
)
|
|
||||||
@api_user = Fabricate(:gitlab_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
|
end
|
||||||
|
|
||||||
describe 'GET /repp/v1/accounts/balance' do
|
context 'with valid registrar' do
|
||||||
it 'returns account balance of the current registrar', autodoc: true, route_info_doc: true do
|
before :all do
|
||||||
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
|
@registrar1 = Fabricate(:registrar1, accounts:
|
||||||
response.status.should == 200
|
[Fabricate(:account, { balance: '324.45', account_activities: [] })]
|
||||||
|
)
|
||||||
|
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
|
||||||
|
end
|
||||||
|
|
||||||
body = JSON.parse(response.body)
|
describe 'GET /repp/v1/accounts/balance' do
|
||||||
body['balance'].should == '324.45'
|
it 'returns account balance of the current registrar', autodoc: true, route_info_doc: true do
|
||||||
body['currency'].should == 'EUR'
|
get_with_auth '/repp/v1/accounts/balance', {}, @api_user
|
||||||
|
response.status.should == 200
|
||||||
|
|
||||||
log = ApiLog::ReppLog.last
|
body = JSON.parse(response.body)
|
||||||
log[:request_path].should == '/repp/v1/accounts/balance'
|
body['balance'].should == '324.45'
|
||||||
log[:request_method].should == 'GET'
|
body['currency'].should == 'EUR'
|
||||||
log[:request_params].should == '{}'
|
|
||||||
log[:response_code].should == '200'
|
log = ApiLog::ReppLog.last
|
||||||
log[:api_user_name].should == 'gitlab'
|
log[:request_path].should == '/repp/v1/accounts/balance'
|
||||||
log[:api_user_registrar].should == 'registrar1'
|
log[:request_method].should == 'GET'
|
||||||
log[:ip].should == '127.0.0.1'
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue