diff --git a/app/api/repp/api.rb b/app/api/repp/api.rb index d564b7715..40472e781 100644 --- a/app/api/repp/api.rb +++ b/app/api/repp/api.rb @@ -9,7 +9,7 @@ module Repp before do if request.ip != ENV['webclient_ip'] - error! I18n.t('ip_is_not_whitelisted'), 401 unless @current_user.registrar.repp_ip_white?(request.ip) + error! I18n.t('ip_is_not_whitelisted'), 401 unless @current_user.registrar.api_ip_white?(request.ip) end next if Rails.env.test? || Rails.env.development? diff --git a/app/controllers/epp/sessions_controller.rb b/app/controllers/epp/sessions_controller.rb index ba6cc6ec6..c68e60e09 100644 --- a/app/controllers/epp/sessions_controller.rb +++ b/app/controllers/epp/sessions_controller.rb @@ -37,7 +37,7 @@ class Epp::SessionsController < EppController def ip_white? return true if request.ip == ENV['webclient_ip'] if @api_user - unless @api_user.registrar.epp_ip_white?(request.ip) + unless @api_user.registrar.api_ip_white?(request.ip) @msg = t('ip_is_not_whitelisted') return false end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 7292b4bcb..8387bc08c 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -147,12 +147,8 @@ class Registrar < ActiveRecord::Base self[:code] = code.gsub(/[ :]/, '').upcase if new_record? && code.present? end - def repp_ip_white?(ip) - white_ips.repp.pluck(:ipv4, :ipv6).flatten.include?(ip) || global_ip_white?(ip) - end - - def epp_ip_white?(ip) - white_ips.epp.pluck(:ipv4, :ipv6).flatten.include?(ip) || global_ip_white?(ip) + def api_ip_white?(ip) + white_ips.api.pluck(:ipv4, :ipv6).flatten.include?(ip) || global_ip_white?(ip) end def registrar_ip_white?(ip) diff --git a/app/models/white_ip.rb b/app/models/white_ip.rb index 69c75f4d6..f62cb2f9f 100644 --- a/app/models/white_ip.rb +++ b/app/models/white_ip.rb @@ -13,15 +13,12 @@ class WhiteIp < ActiveRecord::Base errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present)) end - EPP = 'epp' - REPP = 'repp' + API = 'api' REGISTRAR = 'registrar' GLOBAL = 'global' + INTERFACES = [GLOBAL, API, REGISTRAR] - INTERFACES = [GLOBAL, EPP, REPP, REGISTRAR] - - scope :epp, -> { where(interface: EPP) } - scope :repp, -> { where(interface: REPP) } + scope :api, -> { where(interface: API) } scope :registrar, -> { where(interface: REGISTRAR) } scope :global, -> { where(interface: GLOBAL) } diff --git a/spec/fabricators/white_ip_fabricator.rb b/spec/fabricators/white_ip_fabricator.rb index 8c4783093..e6fcae6e0 100644 --- a/spec/fabricators/white_ip_fabricator.rb +++ b/spec/fabricators/white_ip_fabricator.rb @@ -3,14 +3,6 @@ Fabricator(:white_ip) do 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 diff --git a/spec/features/admin/white_ip_spec.rb b/spec/features/admin/white_ip_spec.rb index 71a69f953..261ea134d 100644 --- a/spec/features/admin/white_ip_spec.rb +++ b/spec/features/admin/white_ip_spec.rb @@ -26,7 +26,7 @@ feature 'Api users', type: :feature do fill_in 'IPv4', with: '192.168.1.1' fill_in 'IPv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329' - select 'REPP', from: 'Interface' + select 'API', from: 'Interface' click_button 'Save' page.should have_text('Record created') @@ -34,14 +34,14 @@ feature 'Api users', type: :feature do page.should have_link(@registrar.to_s) page.should have_text('192.168.1.1') page.should have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329') - page.should have_text('REPP') + page.should have_text('API') click_link @registrar.to_s current_path.should == "/admin/registrars/#{@registrar.id}" page.should have_text('192.168.1.1') page.should have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329') - page.should have_text('REPP') + page.should have_text('API') end it 'should not add invalid ip to registrar' do diff --git a/spec/requests/v1/account_spec.rb b/spec/requests/v1/account_spec.rb index 6724936e0..1251583db 100644 --- a/spec/requests/v1/account_spec.rb +++ b/spec/requests/v1/account_spec.rb @@ -3,7 +3,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)]) + @registrar1 = Fabricate(:registrar, white_ips: [Fabricate(:white_ip_registrar)]) @api_user = Fabricate(:api_user, registrar: @registrar1) get_with_auth '/repp/v1/accounts/balance', {}, @api_user