From fe74c0bd64bea6751b5656fdf426505091bd3d51 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 16 Jan 2015 16:14:57 +0200 Subject: [PATCH] Test fixes --- app/controllers/concerns/epp/common.rb | 5 +++-- config/routes.rb | 9 +++++---- spec/epp/poll_spec.rb | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/concerns/epp/common.rb b/app/controllers/concerns/epp/common.rb index 2d9cd945b..9448b3884 100644 --- a/app/controllers/concerns/epp/common.rb +++ b/app/controllers/concerns/epp/common.rb @@ -120,9 +120,10 @@ module Epp::Common end def write_to_epp_log + request_command = params[:command] || params[:action] # error receives :command, other methods receive :action ApiLog::EppLog.create({ - request: params[:raw_frame], - request_command: params[:action], + request: params[:raw_frame] || params[:frame], + request_command: request_command, request_successful: epp_errors.empty?, request_object: params[:epp_object_type], # TODO: fix this for login and logout response: @response, diff --git a/config/routes.rb b/config/routes.rb index a4e9fafab..58f4c2020 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,10 +8,11 @@ class EppConstraint @type = type end + # creates parsed_frame, detects epp request object def matches?(request) parsed_frame = Nokogiri::XML(request.params[:raw_frame]) - unless [:keyrelay].include?(@type) + unless [:keyrelay, :poll].include?(@type) element = "//#{@type}:#{request.params[:action]}" return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none? end @@ -24,13 +25,13 @@ end Rails.application.routes.draw do namespace(:epp, defaults: { format: :xml }) do + match 'session/:action', controller: 'sessions', via: :all + post 'command/:action', controller: 'domains', constraints: EppConstraint.new(:domain) post 'command/:action', controller: 'contacts', constraints: EppConstraint.new(:contact) - post 'command/poll', to: 'polls#poll' + post 'command/poll', to: 'polls#poll', constraints: EppConstraint.new(:poll) post 'command/keyrelay', to: 'keyrelays#keyrelay', constraints: EppConstraint.new(:keyrelay) - match 'session/:action', controller: 'sessions', via: :all - # match 'command/:command', to: 'commands#proxy', defaults: { format: :xml }, via: [:post, :get] get 'error/:command', to: 'errors#error' end diff --git a/spec/epp/poll_spec.rb b/spec/epp/poll_spec.rb index 27b7b02b7..060d1e47e 100644 --- a/spec/epp/poll_spec.rb +++ b/spec/epp/poll_spec.rb @@ -33,7 +33,7 @@ describe 'EPP Poll', epp: true do expect(log[1].api_user_registrar).to eq('Registrar OÜ') expect(log[2].request_command).to eq('poll') - expect(log[2].request_object).to eq(nil) + expect(log[2].request_object).to eq('poll') expect(log[2].request_successful).to eq(true) expect(log[2].api_user_name).to eq('zone') expect(log[2].api_user_registrar).to eq('Registrar OÜ')