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