Merge pull request #145 from internetee/story/118912395-epp-log

Story/118912395 epp log
This commit is contained in:
Timo Võhmar 2016-06-08 14:03:10 +03:00
commit 7fc4558bf5
9 changed files with 42 additions and 8 deletions

View file

@ -2,6 +2,9 @@ $(document).on 'page:change', ->
$('.selectize').selectize({ $('.selectize').selectize({
allowEmptyOption: true allowEmptyOption: true
}) })
$('.selectize_create').selectize({
allowEmptyOption: true, create: true
})
$('.js-datepicker').datepicker({ $('.js-datepicker').datepicker({
showAnim: "", showAnim: "",

View file

@ -56,4 +56,8 @@ class Epp::KeyrelaysController < EppController
# domain # domain
end end
def resource
@domain
end
end end

View file

@ -54,4 +54,8 @@ class Epp::PollsController < EppController
def validate_poll def validate_poll
requires_attribute 'poll', 'op', values: %(ack req), allow_blank: true requires_attribute 'poll', 'op', values: %(ack req), allow_blank: true
end end
def resource
@message
end
end end

View file

@ -137,4 +137,9 @@ class Epp::SessionsController < EppController
pw = params[:parsed_frame].css('pw').first.text pw = params[:parsed_frame].css('pw').first.text
{ username: user, password: pw } { username: user, password: pw }
end end
private
def resource
@api_user
end
end end

View file

@ -6,8 +6,15 @@ class EppController < ApplicationController
before_action :generate_svtrid before_action :generate_svtrid
before_action :latin_only before_action :latin_only
before_action :validate_against_schema before_action :validate_against_schema
before_action :validate_request
before_action :update_epp_session
around_action :catch_epp_errors
helper_method :current_user
helper_method :resource
def validate_against_schema def validate_against_schema
return if ['hello', 'error', 'keyrelay'].include?(params[:action]) return if ['hello', 'error', 'keyrelay'].include?(params[:action])
schema.validate(params[:nokogiri_frame]).each do |error| schema.validate(params[:nokogiri_frame]).each do |error|
@ -20,10 +27,7 @@ class EppController < ApplicationController
handle_errors and return if epp_errors.any? handle_errors and return if epp_errors.any?
end end
before_action :validate_request
before_action :update_epp_session
around_action :catch_epp_errors
def catch_epp_errors def catch_epp_errors
err = catch(:epp_error) do err = catch(:epp_error) do
yield yield
@ -34,7 +38,6 @@ class EppController < ApplicationController
handle_errors handle_errors
end end
helper_method :current_user
rescue_from StandardError do |e| rescue_from StandardError do |e|
@errors ||= [] @errors ||= []
@ -367,7 +370,7 @@ class EppController < ApplicationController
request: trimmed_request, request: trimmed_request,
request_command: request_command, request_command: request_command,
request_successful: epp_errors.empty?, request_successful: epp_errors.empty?,
request_object: params[:epp_object_type], request_object: resource ? "#{params[:epp_object_type]}: #{resource.class} - #{resource.id} - #{resource.name}" : params[:epp_object_type],
response: @response, response: @response,
api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public', api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public',
api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s), api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s),
@ -383,4 +386,9 @@ class EppController < ApplicationController
return if current_user.blank? return if current_user.blank?
counter_update(current_user.registrar_code, ENV['iptables_server_ip']) counter_update(current_user.registrar_code, ENV['iptables_server_ip'])
end end
def resource
name = self.class.to_s.sub("Epp::","").sub("Controller","").underscore.singularize
instance_variable_get("@#{name}")
end
end end

View file

@ -62,6 +62,10 @@ class ApiUser < User
username username
end end
def name
username
end
def queued_messages def queued_messages
registrar.messages.queued registrar.messages.queued
end end

View file

@ -12,4 +12,8 @@ class Message < ActiveRecord::Base
self.queued = false self.queued = false
save save
end end
def name
"-"
end
end end

View file

@ -11,8 +11,10 @@
= f.select :request_command_eq, [[t(:choose),''], 'hello', 'login', 'logout', 'info', 'create', 'update', 'delete', 'check', 'renew', 'transfer', 'poll', 'keyrelay'], {}, class: 'form-control selectize', placeholder: t(:choose) = f.select :request_command_eq, [[t(:choose),''], 'hello', 'login', 'logout', 'info', 'create', 'update', 'delete', 'check', 'renew', 'transfer', 'poll', 'keyrelay'], {}, class: 'form-control selectize', placeholder: t(:choose)
.col-md-3 .col-md-3
.form-group .form-group
- opts = [[t(:choose),''], 'contact', 'domain', 'poll', 'keyrelay']
- opts += [params[:q][:request_object_cont]] if params[:q].present? && params[:q][:request_object_cont].present?
= f.label :request_object = f.label :request_object
= f.select :request_object_eq, [[t(:choose),''], 'contact', 'domain', 'poll', 'keyrelay'], {}, class: 'form-control selectize', placeholder: t(:choose) = f.select :request_object_cont, opts, {}, class: 'form-control selectize_create', placeholder: t(:choose)
.col-md-3 .col-md-3
.form-group .form-group
= f.label :request_successful = f.label :request_successful

View file

@ -7,7 +7,7 @@ Rails.application.routes.draw do
post 'command/:action', controller: 'domains', constraints: EppConstraint.new(:domain) post 'command/:action', controller: 'domains', constraints: EppConstraint.new(:domain)
post 'command/:action', controller: 'contacts', constraints: EppConstraint.new(:contact) post 'command/:action', controller: 'contacts', constraints: EppConstraint.new(:contact)
post 'command/poll', to: 'polls#poll', constraints: EppConstraint.new(:poll) post 'command/poll', to: 'polls#poll', constraints: EppConstraint.new(:poll)
post 'command/keyrelay', to: 'keyrelays#keyrelay', constraints: EppConstraint.new(:keyrelay) post 'command/keyrelay', to: 'keyrelays#keyrelay', constraints: EppConstraint.new(:keyrelay)
post 'command/:command', to: 'errors#not_found', constraints: EppConstraint.new(:not_found) # fallback route post 'command/:command', to: 'errors#not_found', constraints: EppConstraint.new(:not_found) # fallback route