mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor EPP users to API users
This commit is contained in:
parent
b8494993ea
commit
c91c9c8ebf
44 changed files with 154 additions and 150 deletions
|
@ -4,7 +4,7 @@ module Repp
|
|||
prefix :repp
|
||||
|
||||
http_basic do |username, password|
|
||||
@current_api_user ||= EppUser.find_by(username: username, password: password)
|
||||
@current_api_user ||= ApiUser.find_by(username: username, password: password)
|
||||
end
|
||||
|
||||
helpers do
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
class Admin::EppUsersController < AdminController
|
||||
class Admin::ApiUsersController < AdminController
|
||||
load_and_authorize_resource
|
||||
before_action :set_epp_user, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_api_user, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@q = EppUser.search(params[:q])
|
||||
@epp_users = @q.result.page(params[:page])
|
||||
@q = ApiUser.search(params[:q])
|
||||
@api_users = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@epp_user = EppUser.new
|
||||
@api_user = ApiUser.new
|
||||
end
|
||||
|
||||
def create
|
||||
@epp_user = EppUser.new(epp_user_params)
|
||||
@api_user = ApiUser.new(api_user_params)
|
||||
|
||||
if @epp_user.save
|
||||
if @api_user.save
|
||||
flash[:notice] = I18n.t('record_created')
|
||||
redirect_to [:admin, @epp_user]
|
||||
redirect_to [:admin, @api_user]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_create_record')
|
||||
render 'new'
|
||||
|
@ -28,9 +28,9 @@ class Admin::EppUsersController < AdminController
|
|||
def edit; end
|
||||
|
||||
def update
|
||||
if @epp_user.update(epp_user_params)
|
||||
if @api_user.update(api_user_params)
|
||||
flash[:notice] = I18n.t('record_updated')
|
||||
redirect_to [:admin, @epp_user]
|
||||
redirect_to [:admin, @api_user]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_record')
|
||||
render 'edit'
|
||||
|
@ -38,9 +38,9 @@ class Admin::EppUsersController < AdminController
|
|||
end
|
||||
|
||||
def destroy
|
||||
if @epp_user.destroy
|
||||
if @api_user.destroy
|
||||
flash[:notice] = I18n.t('record_deleted')
|
||||
redirect_to admin_epp_users_path
|
||||
redirect_to admin_api_users_path
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_delete_record')
|
||||
render 'show'
|
||||
|
@ -49,11 +49,11 @@ class Admin::EppUsersController < AdminController
|
|||
|
||||
private
|
||||
|
||||
def set_epp_user
|
||||
@epp_user = EppUser.find(params[:id])
|
||||
def set_api_user
|
||||
@api_user = ApiUser.find(params[:id])
|
||||
end
|
||||
|
||||
def epp_user_params
|
||||
params.require(:epp_user).permit(:username, :password, :crt, :active, :registrar_id, :registrar_typeahead)
|
||||
def api_user_params
|
||||
params.require(:api_user).permit(:username, :password, :crt, :active, :registrar_id, :registrar_typeahead)
|
||||
end
|
||||
end
|
|
@ -5,9 +5,9 @@ module Shared::UserStamper
|
|||
return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
|
||||
|
||||
if obj.new_record?
|
||||
obj.created_by_id = current_epp_user.id
|
||||
obj.created_by_id = current_api_user.id
|
||||
else
|
||||
obj.updated_by_id = current_epp_user.id
|
||||
obj.updated_by_id = current_api_user.id
|
||||
end
|
||||
|
||||
true
|
||||
|
|
|
@ -3,12 +3,12 @@ class Epp::ContactsController < EppController
|
|||
helper WhodunnitHelper ## Refactor this?
|
||||
|
||||
def user_for_paper_trail ## Refactor this?
|
||||
current_epp_user ? "#{current_epp_user.id}-EppUser" : nil
|
||||
current_api_user ? "#{current_api_user.id}-ApiUser" : nil
|
||||
end
|
||||
|
||||
def create
|
||||
@contact = Contact.new(contact_and_address_attributes)
|
||||
@contact.registrar = current_epp_user.registrar
|
||||
@contact.registrar = current_api_user.registrar
|
||||
render_epp_response '/epp/contacts/create' and return if stamp(@contact) && @contact.save
|
||||
handle_errors(@contact)
|
||||
end
|
||||
|
@ -113,7 +113,7 @@ class Epp::ContactsController < EppController
|
|||
return false unless xml_attrs_present?(@ph, [['id']])
|
||||
@contact = find_contact
|
||||
return false unless @contact
|
||||
return true if current_epp_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
|
||||
return true if current_api_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
|
||||
false
|
||||
end
|
||||
|
||||
|
@ -135,7 +135,7 @@ class Epp::ContactsController < EppController
|
|||
|
||||
def owner?(with_errors = true)
|
||||
return false unless find_contact
|
||||
return true if @contact.registrar == current_epp_user.registrar
|
||||
return true if @contact.registrar == current_api_user.registrar
|
||||
return false unless with_errors
|
||||
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
|
||||
false
|
||||
|
@ -144,7 +144,7 @@ class Epp::ContactsController < EppController
|
|||
def rights?
|
||||
pw = @ph.try(:[], :authInfo).try(:[], :pw)
|
||||
|
||||
return true if current_epp_user.try(:registrar) == @contact.try(:registrar)
|
||||
return true if current_api_user.try(:registrar) == @contact.try(:registrar)
|
||||
return true if pw && @contact.auth_info_matches(pw) # @contact.try(:auth_info_matches, pw)
|
||||
|
||||
epp_errors << { code: '2200', msg: t('errors.messages.epp_authentication_error') }
|
||||
|
|
|
@ -175,7 +175,7 @@ class Epp::DomainsController < EppController
|
|||
|
||||
{
|
||||
name: name,
|
||||
registrar_id: current_epp_user.registrar.try(:id),
|
||||
registrar_id: current_api_user.registrar.try(:id),
|
||||
registered_at: Time.now,
|
||||
period: (period.to_i == 0) ? 1 : period.to_i,
|
||||
period_unit: Epp::EppDomain.parse_period_unit_from_frame(params[:parsed_frame]) || 'y'
|
||||
|
@ -186,7 +186,7 @@ class Epp::DomainsController < EppController
|
|||
res = {}
|
||||
res[:pw] = params[:parsed_frame].css('pw').first.try(:text)
|
||||
res[:action] = params[:parsed_frame].css('transfer').first[:op]
|
||||
res[:current_user] = current_epp_user
|
||||
res[:current_user] = current_api_user
|
||||
res
|
||||
end
|
||||
|
||||
|
@ -205,7 +205,7 @@ class Epp::DomainsController < EppController
|
|||
|
||||
return domain if domain.auth_info == params[:parsed_frame].css('authInfo pw').text
|
||||
|
||||
if (domain.registrar != current_epp_user.registrar && secure[:secure] == true) &&
|
||||
if (domain.registrar != current_api_user.registrar && secure[:secure] == true) &&
|
||||
epp_errors << {
|
||||
code: '2302',
|
||||
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
|
||||
|
|
|
@ -6,7 +6,7 @@ class Epp::KeyrelaysController < EppController
|
|||
|
||||
handle_errors(@domain) and return unless @domain
|
||||
handle_errors(@domain) and return unless @domain.authenticate(params[:parsed_frame].css('pw').text)
|
||||
handle_errors(@domain) and return unless @domain.keyrelay(params[:parsed_frame], current_epp_user.registrar)
|
||||
handle_errors(@domain) and return unless @domain.keyrelay(params[:parsed_frame], current_api_user.registrar)
|
||||
|
||||
render_epp_response '/epp/shared/success'
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class Epp::PollsController < EppController
|
|||
end
|
||||
|
||||
def req_poll
|
||||
@message = current_epp_user.queued_messages.last
|
||||
@message = current_api_user.queued_messages.last
|
||||
render_epp_response 'epp/poll/poll_no_messages' and return unless @message
|
||||
|
||||
if @message.attached_obj_type && @message.attached_obj_id
|
||||
|
@ -20,7 +20,7 @@ class Epp::PollsController < EppController
|
|||
end
|
||||
|
||||
def ack_poll
|
||||
@message = current_epp_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
|
||||
@message = current_api_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
|
||||
|
||||
unless @message
|
||||
epp_errors << {
|
||||
|
|
|
@ -4,10 +4,10 @@ class Epp::SessionsController < EppController
|
|||
end
|
||||
|
||||
def login
|
||||
@epp_user = EppUser.find_by(login_params)
|
||||
@api_user = ApiUser.find_by(login_params)
|
||||
|
||||
if @epp_user.try(:active)
|
||||
epp_session[:epp_user_id] = @epp_user.id
|
||||
if @api_user.try(:active)
|
||||
epp_session[:api_user_id] = @api_user.id
|
||||
render_epp_response('login_success')
|
||||
else
|
||||
response.headers['X-EPP-Returncode'] = '2200'
|
||||
|
@ -16,8 +16,8 @@ class Epp::SessionsController < EppController
|
|||
end
|
||||
|
||||
def logout
|
||||
@epp_user = current_epp_user # cache current_epp_user for logging
|
||||
epp_session[:epp_user_id] = nil
|
||||
@api_user = current_api_user # cache current_api_user for logging
|
||||
epp_session[:api_user_id] = nil
|
||||
response.headers['X-EPP-Returncode'] = '1500'
|
||||
render_epp_response('logout')
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ class EppController < ApplicationController
|
|||
before_action :generate_svtrid
|
||||
before_action :validate_request
|
||||
layout false
|
||||
helper_method :current_epp_user
|
||||
helper_method :current_api_user
|
||||
|
||||
def generate_svtrid
|
||||
# rubocop: disable Style/VariableName
|
||||
|
@ -21,8 +21,8 @@ class EppController < ApplicationController
|
|||
EppSession.find_or_initialize_by(session_id: cookie['session'])
|
||||
end
|
||||
|
||||
def current_epp_user
|
||||
@current_epp_user ||= EppUser.find(epp_session[:epp_user_id]) if epp_session[:epp_user_id]
|
||||
def current_api_user
|
||||
@current_api_user ||= ApiUser.find(epp_session[:api_user_id]) if epp_session[:api_user_id]
|
||||
end
|
||||
|
||||
# ERROR + RESPONSE HANDLING
|
||||
|
@ -198,8 +198,8 @@ class EppController < ApplicationController
|
|||
request_successful: epp_errors.empty?,
|
||||
request_object: params[:epp_object_type],
|
||||
response: @response,
|
||||
api_user_name: @epp_user.try(:to_s) || current_epp_user.try(:to_s),
|
||||
api_user_registrar: @epp_user.try(:registrar).try(:to_s) || current_epp_user.try(:registrar).try(:to_s),
|
||||
api_user_name: @api_user.try(:to_s) || current_api_user.try(:to_s),
|
||||
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_api_user.try(:registrar).try(:to_s),
|
||||
ip: request.ip
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module WhodunnitHelper
|
||||
def link_to_whodunnit(whodunnit)
|
||||
return nil unless whodunnit
|
||||
if whodunnit.include?('-EppUser')
|
||||
user = EppUser.find(whodunnit)
|
||||
if whodunnit.include?('-ApiUser')
|
||||
user = ApiUser.find(whodunnit)
|
||||
return link_to(user.username, admin_epp_user_path(user))
|
||||
end
|
||||
user = User.find(whodunnit)
|
||||
|
@ -13,8 +13,8 @@ module WhodunnitHelper
|
|||
|
||||
def whodunnit_with_protocol(whodunnit)
|
||||
return nil unless whodunnit
|
||||
if whodunnit.include?('-EppUser')
|
||||
user = EppUser.find(whodunnit)
|
||||
if whodunnit.include?('-ApiUser')
|
||||
user = ApiUser.find(whodunnit)
|
||||
return "#{user.username} (EPP)"
|
||||
end
|
||||
user = User.find(whodunnit)
|
||||
|
|
|
@ -29,7 +29,7 @@ class Ability
|
|||
can :manage, ZonefileSetting
|
||||
can :manage, DomainVersion
|
||||
can :manage, User
|
||||
can :manage, EppUser
|
||||
can :manage, ApiUser
|
||||
can :manage, Keyrelay
|
||||
can :manage, LegalDocument
|
||||
can :read, ApiLog::EppLog
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# rubocop: disable Metrics/ClassLength
|
||||
class EppUser < ActiveRecord::Base
|
||||
class ApiUser < ActiveRecord::Base
|
||||
# TODO: should have max request limit per day
|
||||
belongs_to :registrar
|
||||
has_many :contacts
|
|
@ -7,7 +7,7 @@ module UserEvents
|
|||
return [] unless registrar
|
||||
@events = []
|
||||
registrar.users.each { |user| @events << user_events(user.id) }
|
||||
registrar.epp_users.each { |user| @events << epp_user_events(user.id) }
|
||||
registrar.api_users.each { |user| @events << epp_user_events(user.id) }
|
||||
@events
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ module UserEvents
|
|||
end
|
||||
|
||||
def epp_user_events(id)
|
||||
where(whodunnit: "#{id}-EppUser")
|
||||
where(whodunnit: "#{id}-ApiUser")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,8 @@ class Contact < ActiveRecord::Base
|
|||
has_many :statuses, class_name: 'ContactStatus'
|
||||
|
||||
# TODO: remove the x_by
|
||||
belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id
|
||||
belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id
|
||||
belongs_to :created_by, class_name: 'ApiUser', foreign_key: :created_by_id
|
||||
belongs_to :updated_by, class_name: 'ApiUser', foreign_key: :updated_by_id
|
||||
belongs_to :registrar
|
||||
|
||||
accepts_nested_attributes_for :address, :disclosure
|
||||
|
|
|
@ -2,7 +2,7 @@ class Registrar < ActiveRecord::Base
|
|||
belongs_to :country
|
||||
has_many :domains, dependent: :restrict_with_error
|
||||
has_many :contacts, dependent: :restrict_with_error
|
||||
has_many :epp_users, dependent: :restrict_with_error
|
||||
has_many :api_users, dependent: :restrict_with_error
|
||||
has_many :messages
|
||||
|
||||
validates :name, :reg_no, :address, :country, presence: true
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
= form_for([:admin, @epp_user]) do |f|
|
||||
- if @epp_user.errors.any?
|
||||
- @epp_user.errors.each do |attr, err|
|
||||
= form_for([:admin, @api_user]) do |f|
|
||||
- if @api_user.errors.any?
|
||||
- @api_user.errors.each do |attr, err|
|
||||
= err
|
||||
%br
|
||||
- if @epp_user.errors.any?
|
||||
- if @api_user.errors.any?
|
||||
%hr
|
||||
|
||||
.row
|
||||
|
@ -23,7 +23,7 @@
|
|||
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
|
||||
.form-group
|
||||
.checkbox
|
||||
%label{for: 'epp_user_active'}
|
||||
%label{for: 'api_user_active'}
|
||||
= f.check_box(:active)
|
||||
= t('active')
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t('edit_epp_user')}"
|
||||
= "#{t('edit_api_user')}"
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('back_to_epp_user'), [:admin, @epp_user], class: 'btn btn-default')
|
||||
= link_to(t('back_to_api_user'), [:admin, @api_user], class: 'btn btn-default')
|
||||
%hr
|
||||
= render 'form'
|
|
@ -1,9 +1,9 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs= t('epp_users')
|
||||
%h2.text-center-xs= t('api_users')
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('create_new_epp_user'), new_admin_epp_user_path, class: 'btn btn-primary')
|
||||
= link_to(t('create_new_api_user'), new_admin_api_user_path, class: 'btn btn-primary')
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
|
@ -18,11 +18,11 @@
|
|||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'active', t('active'))
|
||||
%tbody
|
||||
- @epp_users.each do |x|
|
||||
- @api_users.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, [:admin, x])
|
||||
%td= link_to(x.registrar, [:admin, x.registrar])
|
||||
%td= x.active
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @epp_users
|
||||
= paginate @api_users
|
3
app/views/admin/api_users/new.haml
Normal file
3
app/views/admin/api_users/new.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%h2= t('create_new_api_user')
|
||||
%hr
|
||||
= render 'form'
|
|
@ -1,18 +1,18 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs
|
||||
= "#{t('epp_user_details')}"
|
||||
= "#{t('api_user_details')}"
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('edit'), edit_admin_epp_user_path(@epp_user), class: 'btn btn-primary')
|
||||
= link_to(t('delete'), admin_epp_user_path(@epp_user), method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-danger')
|
||||
= link_to(t('edit'), edit_admin_api_user_path(@api_user), class: 'btn btn-primary')
|
||||
= link_to(t('delete'), admin_api_user_path(@api_user), method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-danger')
|
||||
|
||||
%hr
|
||||
- if @epp_user.errors.any?
|
||||
- @epp_user.errors.each do |attr, err|
|
||||
- if @api_user.errors.any?
|
||||
- @api_user.errors.each do |attr, err|
|
||||
= err
|
||||
%br
|
||||
- if @epp_user.errors.any?
|
||||
- if @api_user.errors.any?
|
||||
%hr
|
||||
.row
|
||||
.col-md-6
|
||||
|
@ -22,13 +22,13 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('username')
|
||||
%dd= @epp_user.username
|
||||
%dd= @api_user.username
|
||||
|
||||
%dt= t('password')
|
||||
%dd= @epp_user.password
|
||||
%dd= @api_user.password
|
||||
|
||||
%dt= t('active')
|
||||
%dd= @epp_user.active
|
||||
%dd= @api_user.active
|
||||
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
|
@ -37,7 +37,7 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('csr')
|
||||
%dd= @epp_user.csr
|
||||
%dd= @api_user.csr
|
||||
|
||||
%dt= t('crt')
|
||||
%dd= @epp_user.crt
|
||||
%dd= @api_user.crt
|
|
@ -1,3 +0,0 @@
|
|||
%h2= t('create_new_epp_user')
|
||||
%hr
|
||||
= render 'form'
|
|
@ -49,7 +49,7 @@
|
|||
.col-md-12
|
||||
#epp-users.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t('epp_users')
|
||||
= t('api_users')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
|
@ -57,7 +57,7 @@
|
|||
%th{class: 'col-xs-6'}= t('username')
|
||||
%th{class: 'col-xs-6'}= t('active')
|
||||
%tbody
|
||||
- @registrar.epp_users.each do |x|
|
||||
- @registrar.api_users.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, [:admin, x])
|
||||
%td= x.active
|
||||
|
|
|
@ -4,7 +4,7 @@ xml.epp_head do
|
|||
xml.msg 'Command completed successfully'
|
||||
end
|
||||
|
||||
xml.tag!('msgQ', 'count' => current_epp_user.queued_messages.count, 'id' => @message.id)
|
||||
xml.tag!('msgQ', 'count' => current_api_user.queued_messages.count, 'id' => @message.id)
|
||||
|
||||
xml << render('/epp/shared/trID')
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ xml.epp(
|
|||
xml.msg 'Command completed successfully; ack to dequeue'
|
||||
end
|
||||
|
||||
xml.tag!('msgQ', 'count' => current_epp_user.queued_messages.count, 'id' => @message.id) do
|
||||
xml.tag!('msgQ', 'count' => current_api_user.queued_messages.count, 'id' => @message.id) do
|
||||
xml.qDate @message.created_at
|
||||
xml.msg @message.body
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ xml.epp_head do
|
|||
xml.msg 'Command completed successfully; ack to dequeue'
|
||||
end
|
||||
|
||||
xml.tag!('msgQ', 'count' => current_epp_user.queued_messages.count, 'id' => @message.id) do
|
||||
xml.tag!('msgQ', 'count' => current_api_user.queued_messages.count, 'id' => @message.id) do
|
||||
xml.qDate @message.created_at
|
||||
xml.msg @message.body
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
%li.divider
|
||||
%li.dropdown-header= t('users')
|
||||
%li= link_to t(:admin_users), admin_users_path
|
||||
%li= link_to t(:epp_users), admin_epp_users_path
|
||||
%li= link_to t(:api_users), admin_api_users_path
|
||||
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li= link_to t('log_out', user: current_user), '/logout'
|
||||
|
|
|
@ -183,7 +183,7 @@ en:
|
|||
registrar:
|
||||
blank: 'Registrar is missing'
|
||||
|
||||
epp_user:
|
||||
api_user:
|
||||
attributes:
|
||||
username:
|
||||
blank: 'Username is missing'
|
||||
|
@ -280,7 +280,7 @@ en:
|
|||
system: 'System'
|
||||
settings: 'Settings'
|
||||
domains: 'Domains'
|
||||
epp_users: 'EPP Users'
|
||||
api_users: 'API users'
|
||||
registrars: 'Registrars'
|
||||
valid_to: 'Valid to'
|
||||
name: 'Name'
|
||||
|
@ -408,13 +408,13 @@ en:
|
|||
edit_user: 'Edit user'
|
||||
back_to_user: 'Back to user'
|
||||
|
||||
create_new_epp_user: 'Create new EPP user'
|
||||
create_new_api_user: 'Create new API user'
|
||||
certificate_signing_req: 'Certificate signing request'
|
||||
csr: 'CSR'
|
||||
crt: 'CRT'
|
||||
epp_user_details: 'EPP user details'
|
||||
edit_epp_user: 'Edit EPP user'
|
||||
back_to_epp_user: 'Back to EPP user'
|
||||
api_user_details: 'API user details'
|
||||
edit_api_user: 'Edit API user'
|
||||
back_to_api_user: 'Back to API user'
|
||||
|
||||
dnskey: 'DNS key'
|
||||
dnskeys: 'DNS Keys'
|
||||
|
@ -458,7 +458,6 @@ en:
|
|||
domain_history: Domain history
|
||||
domains_history: Domains history
|
||||
admin_users: Admin users
|
||||
epp_users: EPP users
|
||||
role: 'Role'
|
||||
admin: 'Administrator'
|
||||
user: 'User'
|
||||
|
|
|
@ -65,7 +65,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :users
|
||||
resources :epp_users
|
||||
resources :api_users
|
||||
resources :domain_versions
|
||||
|
||||
resources :delayed_jobs
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class RenameEppUsersToApiUsers < ActiveRecord::Migration
|
||||
def change
|
||||
rename_table('epp_users', 'api_users')
|
||||
end
|
||||
end
|
24
db/schema.rb
24
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150122091557) do
|
||||
ActiveRecord::Schema.define(version: 20150129114042) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -39,6 +39,17 @@ ActiveRecord::Schema.define(version: 20150122091557) do
|
|||
t.string "street3", limit: 255
|
||||
end
|
||||
|
||||
create_table "api_users", force: :cascade do |t|
|
||||
t.integer "registrar_id"
|
||||
t.string "username", limit: 255
|
||||
t.string "password", limit: 255
|
||||
t.boolean "active", default: false
|
||||
t.text "csr"
|
||||
t.text "crt"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "cached_nameservers", id: false, force: :cascade do |t|
|
||||
t.string "hostname", limit: 255
|
||||
t.string "ipv4", limit: 255
|
||||
|
@ -218,17 +229,6 @@ ActiveRecord::Schema.define(version: 20150122091557) do
|
|||
add_index "epp_sessions", ["session_id"], name: "index_epp_sessions_on_session_id", unique: true, using: :btree
|
||||
add_index "epp_sessions", ["updated_at"], name: "index_epp_sessions_on_updated_at", using: :btree
|
||||
|
||||
create_table "epp_users", force: :cascade do |t|
|
||||
t.integer "registrar_id"
|
||||
t.string "username", limit: 255
|
||||
t.string "password", limit: 255
|
||||
t.boolean "active", default: false
|
||||
t.text "csr"
|
||||
t.text "crt"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "keyrelays", force: :cascade do |t|
|
||||
t.integer "domain_id"
|
||||
t.datetime "pa_date"
|
||||
|
|
|
@ -16,7 +16,7 @@ registrar1 = Registrar.where(
|
|||
country: Country.first
|
||||
).first_or_create
|
||||
|
||||
EppUser.where(
|
||||
ApiUser.where(
|
||||
username: 'registrar1',
|
||||
password: 'test1',
|
||||
active: true,
|
||||
|
@ -30,7 +30,7 @@ registrar2 = Registrar.where(
|
|||
country: Country.first
|
||||
).first_or_create
|
||||
|
||||
EppUser.where(
|
||||
ApiUser.where(
|
||||
username: 'registrar2',
|
||||
password: 'test2',
|
||||
active: true,
|
||||
|
|
|
@ -2,9 +2,9 @@ require 'rails_helper'
|
|||
|
||||
describe 'EPP Contact', epp: true do
|
||||
before :all do
|
||||
Fabricate(:epp_user)
|
||||
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||
Fabricate(:api_user)
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
|
||||
|
||||
login_as :gitlab
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe 'EPP Contact', epp: true do
|
|||
@contact = Contact.last
|
||||
|
||||
@contact.registrar.should == registrar1
|
||||
registrar1.epp_users.should include(@contact.created_by)
|
||||
registrar1.api_users.should include(@contact.created_by)
|
||||
@contact.updated_by_id.should == nil
|
||||
@contact.ident.should == '37605030299'
|
||||
@contact.address.street.should == '123 Example'
|
||||
|
@ -216,7 +216,7 @@ describe 'EPP Contact', epp: true do
|
|||
code: 'sh8013disclosure',
|
||||
auth_info: '2fooBAR',
|
||||
registrar: registrar1,
|
||||
created_by_id: EppUser.first.id,
|
||||
created_by_id: ApiUser.first.id,
|
||||
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
||||
|
||||
xml = {
|
||||
|
@ -245,7 +245,7 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
it 'deletes contact' do
|
||||
@contact_deleted =
|
||||
Fabricate(:contact, code: 'dwa1234', created_by_id: EppUser.first.id, registrar: registrar1)
|
||||
Fabricate(:contact, code: 'dwa1234', created_by_id: ApiUser.first.id, registrar: registrar1)
|
||||
|
||||
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
|
|
|
@ -12,8 +12,8 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
before(:all) do
|
||||
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
|
||||
|
||||
login_as :registrar1
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ describe 'EPP Keyrelay', epp: true do
|
|||
before(:all) do
|
||||
@elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' })
|
||||
@zone = Fabricate(:registrar)
|
||||
Fabricate(:epp_user, username: 'zone', registrar: @zone)
|
||||
Fabricate(:epp_user, username: 'elkdata', registrar: @elkdata)
|
||||
Fabricate(:api_user, username: 'zone', registrar: @zone)
|
||||
Fabricate(:api_user, username: 'elkdata', registrar: @elkdata)
|
||||
|
||||
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||
end
|
||||
|
|
|
@ -12,8 +12,8 @@ describe 'EPP Poll', epp: true do
|
|||
end
|
||||
|
||||
before(:all) do
|
||||
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
|
||||
|
||||
login_as :registrar1
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
|||
|
||||
describe 'EPP Session', epp: true do
|
||||
before :all do
|
||||
@epp_user = Fabricate(:epp_user)
|
||||
@api_user = Fabricate(:api_user)
|
||||
@epp_xml = EppXml.new(cl_trid: 'ABC-12345')
|
||||
@login_xml_cache = @epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' })
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe 'EPP Session', epp: true do
|
|||
|
||||
it 'does not log in with inactive user' do
|
||||
@registrar = Fabricate(:registrar, { name: 'registrar1', reg_no: '123' })
|
||||
Fabricate(:epp_user, username: 'inactive-user', active: false, registrar: @registrar)
|
||||
Fabricate(:api_user, username: 'inactive-user', active: false, registrar: @registrar)
|
||||
|
||||
inactive = @epp_xml.session.login(clID: { value: 'inactive-user' }, pw: { value: 'ghyt9e4fu' })
|
||||
response = epp_plain_request(inactive, :xml)
|
||||
|
@ -73,12 +73,12 @@ describe 'EPP Session', epp: true do
|
|||
it 'logs out epp user' do
|
||||
epp_plain_request(@login_xml_cache, :xml)
|
||||
|
||||
EppSession.last[:epp_user_id].should == 1
|
||||
EppSession.last[:api_user_id].should == 1
|
||||
response = epp_plain_request(@epp_xml.session.logout, :xml)
|
||||
response[:msg].should == 'Command completed successfully; ending session'
|
||||
response[:result_code].should == '1500'
|
||||
|
||||
EppSession.last[:epp_user_id].should == nil
|
||||
EppSession.last[:api_user_id].should == nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Fabricator(:epp_user) do
|
||||
Fabricator(:api_user) do
|
||||
username 'gitlab'
|
||||
password 'ghyt9e4fu'
|
||||
registrar
|
|
@ -1,5 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe EppUser do
|
||||
describe ApiUser do
|
||||
it { should belong_to(:registrar) }
|
||||
end
|
|
@ -3,7 +3,7 @@ require 'rails_helper'
|
|||
describe Contact do
|
||||
before :all do
|
||||
create_disclosure_settings
|
||||
@epp_user = Fabricate(:epp_user)
|
||||
@api_user = Fabricate(:api_user)
|
||||
end
|
||||
|
||||
it { should have_one(:address) }
|
||||
|
@ -150,7 +150,7 @@ describe Contact do
|
|||
|
||||
context 'with creator' do
|
||||
before :all do
|
||||
@contact.created_by = @epp_user
|
||||
@contact.created_by = @api_user
|
||||
end
|
||||
|
||||
# TODO: change cr_id to something else
|
||||
|
@ -161,7 +161,7 @@ describe Contact do
|
|||
|
||||
context 'with updater' do
|
||||
before :all do
|
||||
@contact.updated_by = @epp_user
|
||||
@contact.updated_by = @api_user
|
||||
end
|
||||
|
||||
# TODO: change up_id to something else
|
||||
|
|
|
@ -10,12 +10,12 @@ describe EppSession do
|
|||
end
|
||||
|
||||
it 'stores data' do
|
||||
expect(epp_session[:epp_user_id]).to eq(1)
|
||||
expect(epp_session[:api_user_id]).to eq(1)
|
||||
|
||||
epp_session[:epp_user_id] = 3
|
||||
expect(epp_session[:epp_user_id]).to eq(3)
|
||||
epp_session[:api_user_id] = 3
|
||||
expect(epp_session[:api_user_id]).to eq(3)
|
||||
|
||||
epp_session = EppSession.find_by(session_id: 'test')
|
||||
expect(epp_session[:epp_user_id]).to eq(3)
|
||||
expect(epp_session[:api_user_id]).to eq(3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ require 'rails_helper'
|
|||
describe Registrar do
|
||||
it { should belong_to(:country) }
|
||||
it { should have_many(:domains) }
|
||||
it { should have_many(:epp_users) }
|
||||
it { should have_many(:api_users) }
|
||||
it { should have_many(:messages) }
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe User do
|
|||
it { should be_able_to(:manage, ZonefileSetting.new) }
|
||||
it { should be_able_to(:manage, DomainVersion.new) }
|
||||
it { should be_able_to(:manage, User.new) }
|
||||
it { should be_able_to(:manage, EppUser.new) }
|
||||
it { should be_able_to(:manage, ApiUser.new) }
|
||||
it { should be_able_to(:manage, Keyrelay.new) }
|
||||
it { should be_able_to(:manage, LegalDocument.new) }
|
||||
it { should be_able_to(:read, ApiLog::EppLog.new) }
|
||||
|
@ -36,7 +36,7 @@ describe User do
|
|||
it { should_not be_able_to(:manage, ZonefileSetting.new) }
|
||||
it { should_not be_able_to(:manage, DomainVersion.new) }
|
||||
it { should_not be_able_to(:manage, User.new) }
|
||||
it { should_not be_able_to(:manage, EppUser.new) }
|
||||
it { should_not be_able_to(:manage, ApiUser.new) }
|
||||
it { should_not be_able_to(:manage, LegalDocument.new) }
|
||||
it { should_not be_able_to(:read, ApiLog::EppLog.new) }
|
||||
it { should_not be_able_to(:read, ApiLog::ReppLog.new) }
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Repp::ContactV1 do
|
||||
let(:epp_user) { Fabricate(:epp_user) }
|
||||
let(:api_user) { Fabricate(:api_user) }
|
||||
|
||||
before(:each) { create_settings }
|
||||
|
||||
describe 'GET /repp/v1/contacts' do
|
||||
it 'returns contacts of the current registrar' do
|
||||
Fabricate.times(2, :contact, registrar: epp_user.registrar)
|
||||
Fabricate.times(2, :contact, registrar: api_user.registrar)
|
||||
Fabricate.times(2, :contact)
|
||||
|
||||
get_with_auth '/repp/v1/contacts', {}, epp_user
|
||||
get_with_auth '/repp/v1/contacts', {}, api_user
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
expect(body['total_pages']).to eq(1)
|
||||
|
||||
# TODO: Maybe there is a way not to convert from and to json again
|
||||
expect(body['contacts'].to_json).to eq(epp_user.registrar.contacts.to_json)
|
||||
expect(body['contacts'].to_json).to eq(api_user.registrar.contacts.to_json)
|
||||
|
||||
log = ApiLog::ReppLog.first
|
||||
expect(log[:request_path]).to eq('/repp/v1/contacts')
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Repp::DomainV1 do
|
||||
let(:epp_user) { Fabricate(:epp_user) }
|
||||
let(:api_user) { Fabricate(:api_user) }
|
||||
|
||||
before(:each) { create_settings }
|
||||
|
||||
describe 'GET /repp/v1/domains' do
|
||||
it 'returns domains of the current registrar' do
|
||||
Fabricate.times(2, :domain, registrar: epp_user.registrar)
|
||||
Fabricate.times(2, :domain, registrar: api_user.registrar)
|
||||
|
||||
get_with_auth '/repp/v1/domains', {}, epp_user
|
||||
get_with_auth '/repp/v1/domains', {}, api_user
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
expect(body['total_pages']).to eq(1)
|
||||
|
||||
# TODO: Maybe there is a way not to convert from and to json again
|
||||
expect(body['domains'].to_json).to eq(epp_user.registrar.domains.to_json)
|
||||
expect(body['domains'].to_json).to eq(api_user.registrar.domains.to_json)
|
||||
|
||||
log = ApiLog::ReppLog.last
|
||||
expect(log[:request_path]).to eq('/repp/v1/domains')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue