diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb
index 16e788500..931dbc62d 100644
--- a/app/controllers/epp_controller.rb
+++ b/app/controllers/epp_controller.rb
@@ -9,13 +9,9 @@ class EppController < ApplicationController
before_action :validate_against_schema
def validate_against_schema
- # filename =
- # if params[:epp_object_type] == :domain
-
return if params[:action] == 'hello'
params[:schema] = 'epp-1.0.xsd' unless params[:schema]
-
- xsd = Nokogiri::XML::Schema(File.read("doc/schemas/#{params[:schema]}"))
+ xsd = Nokogiri::XML::Schema(File.read("lib/schemas/#{params[:schema]}"))
xsd.validate(Nokogiri::XML(params[:raw_frame])).each do |error|
epp_errors << {
code: 2001,
@@ -23,7 +19,6 @@ class EppController < ApplicationController
}
end
- # end
handle_errors and return if epp_errors.any?
end
diff --git a/config/routes.rb b/config/routes.rb
index bb1828c36..4ec266d9a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,8 +2,8 @@ require 'epp_constraint'
Rails.application.routes.draw do
namespace(:epp, defaults: { format: :xml }) do
- match 'session/:action', controller: 'sessions', via: :all
- match 'session/pki/:action', controller: 'sessions', via: :all
+ match 'session/:action', controller: 'sessions', via: :all, constraints: EppConstraint.new(:session)
+ match 'session/pki/:action', controller: 'sessions', via: :all, constraints: EppConstraint.new(:session)
post 'command/:action', controller: 'domains', constraints: EppConstraint.new(:domain)
post 'command/:action', controller: 'contacts', constraints: EppConstraint.new(:contact)
diff --git a/doc/epp-doc.md b/doc/epp-doc.md
index cf4a84d71..cf6ae2788 100644
--- a/doc/epp-doc.md
+++ b/doc/epp-doc.md
@@ -16,15 +16,11 @@ Our implementation supports following protocols:
[RFC5910 - DNSSEC Mapping](http://tools.ietf.org/html/rfc5910)
[RFC3735 - Guidelines for Extending the EPP](http://tools.ietf.org/html/rfc3735)
-Related XML Schema Definitions (may differ from policies applied to registry):
+EIS specific XML Schema Definitions (may differ from policies applied to registry):
[contact-eis-1.0.xsd](schemas/contact-eis-1.0.xsd)
[domain-eis-1.0.xsd](schemas/domain-eis-1.0.xsd)
[eis-1.0.xsd](schemas/eis-1.0.xsd)
-[epp-1.0.xsd](schemas/epp-1.0.xsd)
-[eppcom-1.0.xsd](schemas/eppcom-1.0.xsd)
-[host-1.0.xsd](schemas/host-1.0.xsd)
-[secDNS-1.1.xsd](schemas/secDNS-1.1.xsd)
More info about The Extensible Provisioning Protocol (EPP):
http://en.wikipedia.org/wiki/Extensible_Provisioning_Protocol
diff --git a/doc/schemas/domain-eis-1.0.xsd b/doc/schemas/domain-eis-1.0.xsd
index a0b89c0c6..89d304ed6 100644
--- a/doc/schemas/domain-eis-1.0.xsd
+++ b/doc/schemas/domain-eis-1.0.xsd
@@ -11,10 +11,10 @@
-
-
-
-
+
+
+
+
diff --git a/lib/epp_constraint.rb b/lib/epp_constraint.rb
index c4c5e712e..842ecf218 100644
--- a/lib/epp_constraint.rb
+++ b/lib/epp_constraint.rb
@@ -12,9 +12,10 @@ class EppConstraint
def matches?(request)
parsed_frame = Nokogiri::XML(request.params[:raw_frame])
- unless [:keyrelay, :poll].include?(@type)
+ unless [:keyrelay, :poll, :session].include?(@type)
element = "//#{@type}:#{request.params[:action]}"
return false if parsed_frame.xpath("#{element}", OBJECT_TYPES[@type]).none?
+ # TODO: Support multiple schemas
request.params[:schema] = OBJECT_TYPES[@type][@type].split('/').last
end
diff --git a/lib/schemas/contact-eis-1.0.xsd b/lib/schemas/contact-eis-1.0.xsd
new file mode 100644
index 000000000..66d12ba13
--- /dev/null
+++ b/lib/schemas/contact-eis-1.0.xsd
@@ -0,0 +1,366 @@
+
+
+
+
+
+
+
+
+
+
+
+ Extensible Provisioning Protocol v1.0
+ contact provisioning schema.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/schemas/domain-eis-1.0.xsd b/lib/schemas/domain-eis-1.0.xsd
new file mode 100644
index 000000000..eeea51493
--- /dev/null
+++ b/lib/schemas/domain-eis-1.0.xsd
@@ -0,0 +1,451 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Extensible Provisioning Protocol v1.0
+ domain provisioning schema.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/schemas/eis-1.0.xsd b/lib/schemas/eis-1.0.xsd
new file mode 100644
index 000000000..2612b5e57
--- /dev/null
+++ b/lib/schemas/eis-1.0.xsd
@@ -0,0 +1,102 @@
+
+
+
+
+
+ EIS Extensible Provisioning Protocol v1.0 extension schema.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/schemas/epp-1.0.xsd b/lib/schemas/epp-1.0.xsd
similarity index 99%
rename from doc/schemas/epp-1.0.xsd
rename to lib/schemas/epp-1.0.xsd
index 1efc25947..448b9ae25 100644
--- a/doc/schemas/epp-1.0.xsd
+++ b/lib/schemas/epp-1.0.xsd
@@ -9,7 +9,7 @@
-
+
diff --git a/doc/schemas/eppcom-1.0.xsd b/lib/schemas/eppcom-1.0.xsd
similarity index 100%
rename from doc/schemas/eppcom-1.0.xsd
rename to lib/schemas/eppcom-1.0.xsd
diff --git a/doc/schemas/host-1.0.xsd b/lib/schemas/host-1.0.xsd
similarity index 100%
rename from doc/schemas/host-1.0.xsd
rename to lib/schemas/host-1.0.xsd
diff --git a/doc/schemas/secDNS-1.1.xsd b/lib/schemas/secDNS-1.1.xsd
similarity index 100%
rename from doc/schemas/secDNS-1.1.xsd
rename to lib/schemas/secDNS-1.1.xsd
diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb
index 166ce8659..98bb94bdf 100644
--- a/spec/epp/contact_spec.rb
+++ b/spec/epp/contact_spec.rb
@@ -2,7 +2,7 @@ require 'rails_helper'
describe 'EPP Contact', epp: true do
before :all do
- @xsd = Nokogiri::XML::Schema(File.read('doc/schemas/contact-eis-1.0.xsd'))
+ @xsd = Nokogiri::XML::Schema(File.read('lib/schemas/contact-eis-1.0.xsd'))
@registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2)
@epp_xml = EppXml::Contact.new(cl_trid: 'ABC-12345')
diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb
index 6d7ab9fb5..985c6d134 100644
--- a/spec/epp/domain_spec.rb
+++ b/spec/epp/domain_spec.rb
@@ -2,7 +2,7 @@ require 'rails_helper'
describe 'EPP Domain', epp: true do
before(:all) do
- @xsd = Nokogiri::XML::Schema(File.read('doc/schemas/domain-eis-1.0.xsd'))
+ @xsd = Nokogiri::XML::Schema(File.read('lib/schemas/domain-eis-1.0.xsd'))
@epp_xml = EppXml.new(cl_trid: 'ABC-12345')
@registrar1 = Fabricate(:registrar1, code: 'REGDOMAIN1')
@registrar1.credit!({ sum: 10000 })
diff --git a/spec/epp/poll_spec.rb b/spec/epp/poll_spec.rb
index aceb22c3b..12f6c5cee 100644
--- a/spec/epp/poll_spec.rb
+++ b/spec/epp/poll_spec.rb
@@ -12,7 +12,7 @@ describe 'EPP Poll', epp: true do
end
before(:all) do
- @xsd = Nokogiri::XML::Schema(File.read('doc/schemas/epp-1.0.xsd'))
+ @xsd = Nokogiri::XML::Schema(File.read('lib/schemas/epp-1.0.xsd'))
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
diff --git a/spec/epp/session_spec.rb b/spec/epp/session_spec.rb
index d5438ad7a..63b34e52b 100644
--- a/spec/epp/session_spec.rb
+++ b/spec/epp/session_spec.rb
@@ -5,7 +5,7 @@ describe 'EPP Session', epp: true do
@api_user = Fabricate(:gitlab_api_user)
@epp_xml = EppXml.new(cl_trid: 'ABC-12345')
@login_xml_cache = @epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' })
- @xsd = Nokogiri::XML::Schema(File.read('doc/schemas/epp-1.0.xsd'))
+ @xsd = Nokogiri::XML::Schema(File.read('lib/schemas/epp-1.0.xsd'))
end
context 'when not connected' do
@@ -51,7 +51,7 @@ describe 'EPP Session', epp: true do
end
it 'prohibits further actions unless logged in' do
- @xsd = Nokogiri::XML::Schema(File.read('doc/schemas/domain-eis-1.0.xsd'))
+ @xsd = Nokogiri::XML::Schema(File.read('lib/schemas/domain-eis-1.0.xsd'))
response = epp_plain_request(@epp_xml.domain.info(name: { value: 'test.ee' }))
response[:msg].should == 'You need to login first.'
response[:result_code].should == '2002'