mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
Refactor some xml-ls to epp xml gem
This commit is contained in:
parent
d4e1db4ea4
commit
c9a01f5d11
4 changed files with 35 additions and 26 deletions
2
Gemfile
2
Gemfile
|
@ -85,7 +85,7 @@ group :development, :test do
|
||||||
gem 'epp', '~> 1.4.0'
|
gem 'epp', '~> 1.4.0'
|
||||||
|
|
||||||
# EPP XMLs
|
# EPP XMLs
|
||||||
#gem 'epp-xml', git: 'git@github.com:gitlabeu/epp-xml.git' # TODO: get this from rubygems
|
gem 'epp-xml', git: 'git@github.com:gitlabeu/epp-xml.git' # TODO: get this from rubygems
|
||||||
|
|
||||||
# Replacement for fixtures
|
# Replacement for fixtures
|
||||||
gem 'fabrication', '~> 2.11.3'
|
gem 'fabrication', '~> 2.11.3'
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
GIT
|
||||||
|
remote: git@github.com:gitlabeu/epp-xml.git
|
||||||
|
revision: 4c506960b70246ece25a3e7352075b9aa9060d03
|
||||||
|
specs:
|
||||||
|
epp-xml (0.0.1)
|
||||||
|
activesupport (~> 4.1, >= 4.1.4)
|
||||||
|
builder (~> 3.2, >= 3.2.2)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -359,6 +367,7 @@ DEPENDENCIES
|
||||||
database_cleaner (~> 1.3.0)
|
database_cleaner (~> 1.3.0)
|
||||||
devise (~> 3.3.0)
|
devise (~> 3.3.0)
|
||||||
epp (~> 1.4.0)
|
epp (~> 1.4.0)
|
||||||
|
epp-xml!
|
||||||
fabrication (~> 2.11.3)
|
fabrication (~> 2.11.3)
|
||||||
faker (~> 1.3.0)
|
faker (~> 1.3.0)
|
||||||
guard (~> 2.6.1)
|
guard (~> 2.6.1)
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'returns error if contact does not exists' do
|
it 'returns error if contact does not exists' do
|
||||||
Fabricate(:contact, code: 'jd1234')
|
Fabricate(:contact, code: 'jd1234')
|
||||||
|
|
||||||
response = epp_request(domain_create_xml, :xml)
|
response = epp_request(EppXml::Domain.create, :xml)
|
||||||
|
|
||||||
expect(response[:results][0][:result_code]).to eq('2303')
|
expect(response[:results][0][:result_code]).to eq('2303')
|
||||||
expect(response[:results][0][:msg]).to eq('Contact was not found')
|
expect(response[:results][0][:msg]).to eq('Contact was not found')
|
||||||
|
@ -178,7 +178,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a domain' do
|
it 'creates a domain' do
|
||||||
response = epp_request(domain_create_xml, :xml)
|
response = epp_request(EppXml::Domain.create, :xml)
|
||||||
d = Domain.first
|
d = Domain.first
|
||||||
|
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
@ -214,7 +214,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates ria.ee with valid ds record' do
|
it 'creates ria.ee with valid ds record' do
|
||||||
xml = domain_create_xml({
|
xml = EppXml::Domain.create({
|
||||||
name: { value: 'ria.ee' }
|
name: { value: 'ria.ee' }
|
||||||
}, {
|
}, {
|
||||||
_other: [
|
_other: [
|
||||||
|
@ -240,7 +240,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates nameserver ipv4 when in same zone as domain' do
|
it 'validates nameserver ipv4 when in same zone as domain' do
|
||||||
xml = domain_create_xml({
|
xml = EppXml::Domain.create({
|
||||||
ns: [
|
ns: [
|
||||||
{ hostObj: { value: 'ns1.example.ee' } },
|
{ hostObj: { value: 'ns1.example.ee' } },
|
||||||
{ hostObj: { value: 'ns2.example.ee' } }
|
{ hostObj: { value: 'ns2.example.ee' } }
|
||||||
|
@ -253,8 +253,8 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create duplicate domain' do
|
it 'does not create duplicate domain' do
|
||||||
epp_request(domain_create_xml, :xml)
|
epp_request(EppXml::Domain.create, :xml)
|
||||||
response = epp_request(domain_create_xml, :xml)
|
response = epp_request(EppXml::Domain.create, :xml)
|
||||||
expect(response[:result_code]).to eq('2302')
|
expect(response[:result_code]).to eq('2302')
|
||||||
expect(response[:msg]).to eq('Domain name already exists')
|
expect(response[:msg]).to eq('Domain name already exists')
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
expect(response[:clTRID]).to eq('ABC-12345')
|
||||||
|
@ -263,7 +263,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'does not create reserved domain' do
|
it 'does not create reserved domain' do
|
||||||
Fabricate(:reserved_domain)
|
Fabricate(:reserved_domain)
|
||||||
|
|
||||||
xml = domain_create_xml(name: { value: '1162.ee' })
|
xml = EppXml::Domain.create(name: { value: '1162.ee' })
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('2302')
|
expect(response[:result_code]).to eq('2302')
|
||||||
|
@ -272,7 +272,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create domain without contacts and registrant' do
|
it 'does not create domain without contacts and registrant' do
|
||||||
xml = domain_create_xml(contacts: [], registrant: false)
|
xml = EppXml::Domain.create(contacts: [], registrant: false)
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('2003')
|
expect(response[:results][0][:result_code]).to eq('2003')
|
||||||
|
@ -280,7 +280,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create domain without nameservers' do
|
it 'does not create domain without nameservers' do
|
||||||
xml = domain_create_xml(ns: [])
|
xml = EppXml::Domain.create(ns: [])
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('2003')
|
expect(response[:result_code]).to eq('2003')
|
||||||
expect(response[:msg]).to eq('Required parameter missing: ns')
|
expect(response[:msg]).to eq('Required parameter missing: ns')
|
||||||
|
@ -289,7 +289,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'does not create domain with too many nameservers' do
|
it 'does not create domain with too many nameservers' do
|
||||||
nameservers = []
|
nameservers = []
|
||||||
14.times { |i| nameservers << { hostObj: { value: "ns#{i}.example.net" } } }
|
14.times { |i| nameservers << { hostObj: { value: "ns#{i}.example.net" } } }
|
||||||
xml = domain_create_xml(ns: nameservers)
|
xml = EppXml::Domain.create(ns: nameservers)
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('2004')
|
expect(response[:result_code]).to eq('2004')
|
||||||
|
@ -297,7 +297,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns error when invalid nameservers are present' do
|
it 'returns error when invalid nameservers are present' do
|
||||||
xml = domain_create_xml({
|
xml = EppXml::Domain.create({
|
||||||
ns: [
|
ns: [
|
||||||
{ hostObj: { value: 'invalid1-' } },
|
{ hostObj: { value: 'invalid1-' } },
|
||||||
{ hostObj: { value: '-invalid2' } }
|
{ hostObj: { value: '-invalid2' } }
|
||||||
|
@ -331,7 +331,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a domain with period in days' do
|
it 'creates a domain with period in days' do
|
||||||
xml = domain_create_xml(period_value: 365, period_unit: 'd')
|
xml = EppXml::Domain.create(period_value: 365, period_unit: 'd')
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
@ -340,7 +340,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a domain with invalid period' do
|
it 'does not create a domain with invalid period' do
|
||||||
xml = domain_create_xml({
|
xml = EppXml::Domain.create({
|
||||||
period: { value: '367', attrs: { unit: 'd' } }
|
period: { value: '367', attrs: { unit: 'd' } }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a domain with multiple dnskeys' do
|
it 'creates a domain with multiple dnskeys' do
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ keyData: {
|
{ keyData: {
|
||||||
flags: { value: '257' },
|
flags: { value: '257' },
|
||||||
|
@ -401,7 +401,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
it 'does not create a domain when dnskeys are invalid' do
|
it 'does not create a domain when dnskeys are invalid' do
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ keyData: {
|
{ keyData: {
|
||||||
flags: { value: '250' },
|
flags: { value: '250' },
|
||||||
|
@ -453,7 +453,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a domain with two identical dnskeys' do
|
it 'does not create a domain with two identical dnskeys' do
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ keyData: {
|
{ keyData: {
|
||||||
flags: { value: '257' },
|
flags: { value: '257' },
|
||||||
|
@ -482,7 +482,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'validated dnskeys count' do
|
it 'validated dnskeys count' do
|
||||||
Setting.dnskeys_max_count = 1
|
Setting.dnskeys_max_count = 1
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ keyData: {
|
{ keyData: {
|
||||||
flags: { value: '257' },
|
flags: { value: '257' },
|
||||||
|
@ -508,7 +508,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates domain with ds data' do
|
it 'creates domain with ds data' do
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ dsData: {
|
{ dsData: {
|
||||||
keyTag: { value: '12345' },
|
keyTag: { value: '12345' },
|
||||||
|
@ -534,7 +534,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates domain with ds data with key' do
|
it 'creates domain with ds data with key' do
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ dsData: {
|
{ dsData: {
|
||||||
keyTag: { value: '12345' },
|
keyTag: { value: '12345' },
|
||||||
|
@ -568,7 +568,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'prohibits dsData with key' do
|
it 'prohibits dsData with key' do
|
||||||
Setting.ds_data_with_key_allowed = false
|
Setting.ds_data_with_key_allowed = false
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ dsData: {
|
{ dsData: {
|
||||||
keyTag: { value: '12345' },
|
keyTag: { value: '12345' },
|
||||||
|
@ -593,7 +593,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'prohibits dsData' do
|
it 'prohibits dsData' do
|
||||||
Setting.ds_data_allowed = false
|
Setting.ds_data_allowed = false
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
{ dsData: {
|
{ dsData: {
|
||||||
keyTag: { value: '12345' },
|
keyTag: { value: '12345' },
|
||||||
|
@ -618,7 +618,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'prohibits keyData' do
|
it 'prohibits keyData' do
|
||||||
Setting.key_data_allowed = false
|
Setting.key_data_allowed = false
|
||||||
|
|
||||||
xml = domain_create_xml({}, {
|
xml = EppXml::Domain.create({}, {
|
||||||
_other: [
|
_other: [
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '0' },
|
flags: { value: '0' },
|
||||||
|
@ -642,7 +642,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a domain with contacts' do
|
it 'creates a domain with contacts' do
|
||||||
xml = domain_create_xml({
|
xml = EppXml::Domain.create({
|
||||||
_other: [
|
_other: [
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }
|
{ contact: { value: 'sh8013', attrs: { type: 'admin' } } }
|
||||||
]
|
]
|
||||||
|
@ -661,7 +661,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a domain without admin contact' do
|
it 'does not create a domain without admin contact' do
|
||||||
xml = domain_create_xml({
|
xml = EppXml::Domain.create({
|
||||||
_other: [
|
_other: [
|
||||||
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }
|
{ contact: { value: 'sh8013', attrs: { type: 'tech' } } }
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Session', epp: true do
|
describe 'EPP Session', epp: true do
|
||||||
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
let(:server_gitlab) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
|
||||||
let(:login_xml_cache) { login_xml }
|
let(:login_xml_cache) { EppXml::Session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' }) }
|
||||||
|
|
||||||
context 'when not connected' do
|
context 'when not connected' do
|
||||||
it 'greets client upon connection' do
|
it 'greets client upon connection' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue