Merge branch 'experimental-live-schema-support'

This commit is contained in:
Martin Lensment 2015-07-27 16:24:26 +03:00
commit 48af3e77cd
65 changed files with 1346 additions and 1205 deletions

View file

@ -75,8 +75,8 @@ class Epp::SessionsController < EppController
end
if success
if parsed_frame.css('newPW').first
unless @api_user.update(password: parsed_frame.css('newPW').first.text)
if params[:parsed_frame].css('newPW').first
unless @api_user.update(password: params[:parsed_frame].css('newPW').first.text)
response.headers['X-EPP-Returncode'] = '2500'
handle_errors(@api_user) and return
end
@ -124,11 +124,8 @@ class Epp::SessionsController < EppController
### HELPER METHODS ###
def login_params
ph = params_hash['epp']['command']['login']
{ username: ph[:clID], password: ph[:pw] }
end
def parsed_frame
@parsed_frame ||= Nokogiri::XML(request.params[:raw_frame]).remove_namespaces!
user = params[:parsed_frame].css('clID').first.text
pw = params[:parsed_frame].css('pw').first.text
{ username: user, password: pw }
end
end

View file

@ -6,6 +6,20 @@ class EppController < ApplicationController
before_action :generate_svtrid
before_action :latin_only
before_action :validate_against_schema
def validate_against_schema
return if ['hello', 'error', 'keyrelay'].include?(params[:action])
schema.validate(params[:nokogiri_frame]).each do |error|
epp_errors << {
code: 2001,
msg: error
}
end
handle_errors and return if epp_errors.any?
end
before_action :validate_request
before_action :update_epp_session
@ -58,6 +72,13 @@ class EppController < ApplicationController
render_epp_response '/epp/error'
end
def schema
# TODO: Support multiple schemas
return DOMAIN_SCHEMA if params[:epp_object_type] == :domain
return CONTACT_SCHEMA if params[:epp_object_type] == :contact
EPP_SCHEMA
end
def generate_svtrid
# rubocop: disable Style/VariableName
@svTRID = "ccReg-#{format('%010d', rand(10**10))}"