Remove reduntant test, fix REPP text

This commit is contained in:
Martin Lensment 2015-05-20 17:25:09 +03:00
parent e27132bab7
commit 865e0adef8
5 changed files with 7 additions and 15 deletions

View file

@ -8,7 +8,7 @@ module Repp
end
before do
unless Rails.env.development?
if request.ip != ENV['webclient_ip']
error! I18n.t('ip_is_not_whitelisted'), 401 unless @current_user.registrar.repp_ip_white?(request.ip)
end

View file

@ -35,6 +35,7 @@ class Epp::SessionsController < EppController
end
def ip_white?
return true if request.ip == ENV['webclient_ip']
if @api_user
unless @api_user.registrar.epp_ip_white?(request.ip)
@msg = t('ip_is_not_whitelisted')

View file

@ -39,19 +39,6 @@ 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

@ -16,7 +16,9 @@ feature 'Sessions', type: :feature do
it 'should not get in with invalid ip' do
Fabricate(:registrar, white_ips: [Fabricate(:white_ip), Fabricate(:white_ip_registrar)])
@api_user_invalid_ip = Fabricate(:api_user, identity_code: '37810013294', registrar: Fabricate(:registrar, white_ips: []))
@api_user_invalid_ip = Fabricate(
:api_user, identity_code: '37810013294', registrar: Fabricate(:registrar, white_ips: [])
)
visit registrar_login_path
fill_in 'depp_user_tag', with: @api_user_invalid_ip.username
fill_in 'depp_user_password', with: @api_user_invalid_ip.password

View file

@ -2,6 +2,7 @@ require 'rails_helper'
describe Repp::AccountV1 do
it 'should fail without whitelisted IP' do
ENV['webclient_ip'] = '192.188.1.1'
@registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip_epp), Fabricate(:white_ip_registrar)])
@api_user = Fabricate(:api_user, registrar: @registrar1)
@ -10,6 +11,7 @@ describe Repp::AccountV1 do
body = JSON.parse(response.body)
body['error'].should == 'IP is not whitelisted'
ENV['webclient_ip'] = '127.0.0.1'
end
context 'with valid registrar' do