Skip to content

Commit

Permalink
Merge pull request #1997 from internetee/1976-autoload-schema-versions
Browse files Browse the repository at this point in the history
Load latest version of an xsd schema by prefix
  • Loading branch information
vohmar authored May 27, 2021
2 parents 8e588f5 + 00a0be2 commit 90b1bfc
Show file tree
Hide file tree
Showing 68 changed files with 566 additions and 483 deletions.
2 changes: 1 addition & 1 deletion app/views/epp/contacts/check.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag!('contact:chkData', 'xmlns:contact' => 'https://epp.tld.ee/schema/contact-ee-1.1.xsd') do
xml.tag!('contact:chkData', 'xmlns:contact' => Xsd::Schema.filename(for_prefix: 'contact-ee')) do
@results.each do |result|
xml.tag!('contact:cd') do
xml.tag! "contact:id", result[:code], avail: result[:avail]
Expand Down
4 changes: 2 additions & 2 deletions app/views/epp/contacts/info.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag!('contact:infData', 'xmlns:contact' => 'https://epp.tld.ee/schema/contact-ee-1.1.xsd') do
xml.tag!('contact:infData', 'xmlns:contact' => Xsd::Schema.filename(for_prefix: 'contact-ee')) do
xml.tag!('contact:id', @contact.code)
xml.tag!('contact:roid', @contact.roid)

Expand Down Expand Up @@ -78,7 +78,7 @@ xml.epp_head do
end
if can? :view_full_info, @contact, @password
xml.tag!('extension') do
xml.tag!('eis:extdata', 'xmlns:eis' => 'https://epp.tld.ee/schema/eis-1.0.xsd') do
xml.tag!('eis:extdata', 'xmlns:eis' => Xsd::Schema.filename(for_prefix: 'eis')) do
xml.tag!('eis:ident', @contact.ident,
type: @contact.ident_type, cc: @contact.ident_country_code)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/epp/contacts/save.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag!('contact:creData', 'xmlns:contact' => 'https://epp.tld.ee/schema/contact-ee-1.1.xsd') do
xml.tag!('contact:creData', 'xmlns:contact' => Xsd::Schema.filename(for_prefix: 'contact-ee')) do
xml.tag!('contact:id', @contact.code)
xml.tag!('contact:crDate', @contact.created_at.try(:iso8601))
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/epp/domains/check.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag!('domain:chkData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
xml.tag!('domain:chkData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do
@domains.each do |x|
xml.tag!('domain:cd') do
xml.tag!('domain:name', x[:name], 'avail' => x[:avail])
Expand Down
2 changes: 1 addition & 1 deletion app/views/epp/domains/create.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag!('domain:creData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
xml.tag!('domain:creData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do
xml.tag!('domain:name', @domain.name)
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
Expand Down
2 changes: 1 addition & 1 deletion app/views/epp/domains/info.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
xml.tag! 'domain:infData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis') do
xml.tag!('domain:name', @domain.name)
xml.tag!('domain:roid', @domain.roid)
@domain.statuses.each do |s|
Expand Down
2 changes: 1 addition & 1 deletion app/views/epp/domains/partials/_transfer.xml.builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
builder.tag!('domain:trnData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
builder.tag!('domain:trnData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do
builder.tag!('domain:name', dt.domain_name)
builder.tag!('domain:trStatus', dt.status)
builder.tag!('domain:reID', dt.new_registrar.code)
Expand Down
2 changes: 1 addition & 1 deletion app/views/epp/domains/renew.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xml.epp_head do
end

xml.resData do
xml.tag!('domain:renData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
xml.tag!('domain:renData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-eis')) do
xml.tag!('domain:name', @domain[:name])
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
end
Expand Down
3 changes: 2 additions & 1 deletion app/views/epp/error.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ xml.epp_head do
xml.result('code' => x[:code]) do
xml.msg(x[:msg], 'lang' => 'en')
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize
prefix = model_name == 'poll' ? 'changePoll' : model_name + '-eis'

xml.value("xmlns:#{model_name}" => "https://epp.tld.ee/schema/#{model_name}-eis-1.0.xsd") do
xml.value("xmlns:#{model_name}" => Xsd::Schema.filename(for_prefix: prefix)) do
value = x[:value][:val]
attrs = {}
attrs["s"] = value if x[:value][:obj] == "status"
Expand Down
4 changes: 2 additions & 2 deletions app/views/epp/poll/_action.xml.builder
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
builder.extension do
builder.tag!('changePoll:changeData',
'xmlns:changePoll' => 'https://epp.tld.ee/schema/changePoll-1.0.xsd') do
'xmlns:changePoll' => Xsd::Schema.filename(for_prefix: 'changePoll')) do
builder.tag!('changePoll:operation', action.operation)
builder.tag!('changePoll:date', action.created_at.utc.xmlschema)
builder.tag!('changePoll:svTRID', action.id)
builder.tag!('changePoll:who', action.user)
end
end
end
2 changes: 1 addition & 1 deletion app/views/epp/poll/poll_req.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ xml.epp_head do
state = @notification.text.include?('unlocked') ? 'unlock' : 'lock'
xml.extension do
xml.tag!('changePoll:changeData',
'xmlns:changePoll': 'https://epp.tld.ee/schema/changePoll-1.0.xsd') do
'xmlns:changePoll': Xsd::Schema.filename(for_prefix: 'changePoll')) do
xml.tag!('changePoll:operation', state)
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/views/epp/sessions/greeting.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ xml.epp_head do
xml.svcMenu do
xml.version '1.0'
xml.lang 'en'
xml.objURI 'https://epp.tld.ee/schema/domain-eis-1.0.xsd'
xml.objURI 'https://epp.tld.ee/schema/contact-ee-1.1.xsd'
xml.objURI Xsd::Schema.filename(for_prefix: 'domain-eis')
xml.objURI Xsd::Schema.filename(for_prefix: 'contact-ee')
xml.objURI 'urn:ietf:params:xml:ns:host-1.0'
xml.svcExtension do
xml.extURI 'urn:ietf:params:xml:ns:secDNS-1.1'
xml.extURI 'https://epp.tld.ee/schema/eis-1.0.xsd'
xml.extURI Xsd::Schema.filename(for_prefix: 'eis')
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<check>
<contact:check
xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee')}">
<contact:id>sh8013</contact:id>
</contact:check>
</check>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<check>
<contact:check
xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee')}">
<contact:id>sh8013</contact:id>
<contact:id>sh13</contact:id>
<contact:id>vsdfvq</contact:id>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:create xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee')}">
<contact:postalInfo>
<contact:name>Sillius Soddus</contact:name>
<contact:addr>
Expand All @@ -20,7 +20,7 @@
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:ident type="org" cc="EE">123</eis:ident>
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<delete>
<contact:delete
xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee')}">
<contact:id>sh8013</contact:id>
<contact:authInfo>
<contact:pw>wrong-one</contact:pw>
</contact:authInfo>
</contact:delete>
</delete>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<info>
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:info xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee')}">
<contact:id>sh8013</contact:id>
<contact:authInfo>
<contact:pw>Aas34fq</contact:pw>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<update>
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:update xmlns:contact="#{Xsd::Schema.filename(for_prefix: 'contact-ee')}">
<contact:id>sh8013</contact:id>
<contact:chg>
<contact:postalInfo>
Expand All @@ -25,7 +25,7 @@
</contact:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<check>
<domain:check
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
</domain:check>
</check>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<update>
<domain:update
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
<domain:rem>
<domain:status s="clientHold"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<create>
<domain:create
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
<domain:period unit="y">1</domain:period>
<domain:ns>
Expand Down Expand Up @@ -31,7 +31,7 @@
<secDNS:pubKey>AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8</secDNS:pubKey>
</secDNS:keyData>
</secDNS:create>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<delete>
<domain:delete
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
</domain:delete>
</delete>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
Expand Down
4 changes: 2 additions & 2 deletions app/views/registrar/xml_consoles/epp_requests/domain/info.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<info>
<domain:info
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name hosts="all">example.ee</domain:name>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<renew>
<domain:renew
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
<domain:curExpDate>2014-08-07</domain:curExpDate>
<domain:period unit="y">1</domain:period>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<transfer op="request">
<domain:transfer
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
<domain:authInfo>
<domain:pw roid="JD1234-REP">2BARfoo</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<update>
<domain:update
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
<domain:name>example.ee</domain:name>
<domain:add>
<domain:ns>
Expand Down Expand Up @@ -43,7 +43,7 @@
</secDNS:keyData>
</secDNS:rem>
</secDNS:update>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis')}">
<eis:legalDocument type="pdf">
dGVzdCBmYWlsCg==
</eis:legalDocument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
<command>
<poll op="req"/>
<clTRID>ABC-12345</clTRID>
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/xsd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'application_service'
require 'xsd/schema'
5 changes: 5 additions & 0 deletions lib/application_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ApplicationService
def self.call(*args, &block)
new(*args, &block).call
end
end
6 changes: 3 additions & 3 deletions lib/epp_constraint.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class EppConstraint
OBJECT_TYPES = {
domain: { domain: 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' },
contact: { contact: 'https://epp.tld.ee/schema/contact-ee-1.1.xsd' }
}
domain: { domain: Xsd::Schema.filename(for_prefix: 'domain-eis') },
contact: { contact: Xsd::Schema.filename(for_prefix: 'contact-ee') },
}.freeze

def initialize(type)
@type = type
Expand Down
2 changes: 1 addition & 1 deletion lib/gem_monkey_patches/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class XmlMarkup
def epp_head
instruct!
epp(
'xmlns' => 'https://epp.tld.ee/schema/epp-ee-1.0.xsd',
'xmlns' => ::Xsd::Schema.filename(for_prefix: 'epp-ee'),
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'lib/schemas/epp-ee-1.0.xsd'
) do
Expand Down
Loading

0 comments on commit 90b1bfc

Please sign in to comment.