mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Added some missing model specs + PaperTrail session fix
This commit is contained in:
parent
c248a957a6
commit
a637eb5e01
39 changed files with 1447 additions and 845 deletions
|
@ -1,29 +1,24 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe 'EPP Keyrelay', epp: true do
|
||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
||||
let(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
||||
let(:epp_xml) { EppXml::Keyrelay.new }
|
||||
|
||||
before(:each) { create_settings }
|
||||
|
||||
before(:all) do
|
||||
@elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' })
|
||||
@zone = Fabricate(:registrar)
|
||||
Fabricate(:api_user, username: 'zone', registrar: @zone)
|
||||
Fabricate(:api_user, username: 'elkdata', registrar: @elkdata)
|
||||
create_settings
|
||||
@registrar1 = Fabricate(:registrar1)
|
||||
@registrar2 = Fabricate(:registrar2)
|
||||
@domain = Fabricate(:domain, registrar: @registrar2)
|
||||
@epp_xml = EppXml::Keyrelay.new
|
||||
|
||||
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: @registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: @registrar2)
|
||||
|
||||
login_as :registrar1
|
||||
end
|
||||
|
||||
before(:each) { Fabricate(:domain, name: next_domain_name, registrar: @zone, dnskeys: [Fabricate.build(:dnskey)]) }
|
||||
let(:domain) { Domain.last }
|
||||
|
||||
it 'makes a keyrelay request' do
|
||||
ApiLog::EppLog.delete_all
|
||||
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
|
@ -31,72 +26,53 @@ describe 'EPP Keyrelay', epp: true do
|
|||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'P1M13D' }
|
||||
}
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
response[:result_code].should == '1000'
|
||||
|
||||
@zone.messages.queued.count.should == 1
|
||||
@registrar2.messages.queued.count.should == 1
|
||||
|
||||
log = ApiLog::EppLog.all
|
||||
|
||||
log.length.should == 4
|
||||
log[0].request_command.should == 'hello'
|
||||
log[0].request_successful.should == true
|
||||
|
||||
log[1].request_command.should == 'login'
|
||||
log[1].request_successful.should == true
|
||||
log[1].api_user_name.should == 'elkdata'
|
||||
log[1].api_user_registrar.should == 'Elkdata'
|
||||
|
||||
log[2].request_command.should == 'keyrelay'
|
||||
log[2].request_object.should == 'keyrelay'
|
||||
log[2].request_successful.should == true
|
||||
log[2].api_user_name.should == 'elkdata'
|
||||
log[2].api_user_registrar.should == 'Elkdata'
|
||||
log[2].request.should_not be_blank
|
||||
log[2].response.should_not be_blank
|
||||
|
||||
log[3].request_command.should == 'logout'
|
||||
log[3].request_successful.should == true
|
||||
log[3].api_user_name.should == 'elkdata'
|
||||
log[3].api_user_registrar.should == 'Elkdata'
|
||||
log = ApiLog::EppLog.last
|
||||
log.request_command.should == 'keyrelay'
|
||||
log.request_successful.should == true
|
||||
log.api_user_name.should == '1-api-registrar1'
|
||||
end
|
||||
|
||||
it 'returns an error when parameters are missing' do
|
||||
msg_count = @zone.messages.queued.count
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
msg_count = @registrar2.messages.queued.count
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
protocol: { value: '3' },
|
||||
alg: { value: '8' },
|
||||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'Invalid Expiry' }
|
||||
}
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Required parameter missing: keyrelay > keyData > flags'
|
||||
|
||||
@zone.messages.queued.count.should == msg_count
|
||||
@registrar2.messages.queued.count.should == msg_count
|
||||
end
|
||||
|
||||
it 'returns an error on invalid relative expiry' do
|
||||
msg_count = @zone.messages.queued.count
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
msg_count = @registrar2.messages.queued.count
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
|
@ -104,24 +80,24 @@ describe 'EPP Keyrelay', epp: true do
|
|||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'Invalid Expiry' }
|
||||
}
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Expiry relative must be compatible to ISO 8601'
|
||||
response[:results][0][:value].should == 'Invalid Expiry'
|
||||
|
||||
@zone.messages.queued.count.should == msg_count
|
||||
@registrar2.messages.queued.count.should == msg_count
|
||||
end
|
||||
|
||||
it 'returns an error on invalid absolute expiry' do
|
||||
msg_count = @zone.messages.queued.count
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
msg_count = @registrar2.messages.queued.count
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
|
@ -129,24 +105,24 @@ describe 'EPP Keyrelay', epp: true do
|
|||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
absolute: { value: 'Invalid Absolute' }
|
||||
}
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Expiry absolute must be compatible to ISO 8601'
|
||||
response[:results][0][:value].should == 'Invalid Absolute'
|
||||
|
||||
@zone.messages.queued.count.should == msg_count
|
||||
@registrar2.messages.queued.count.should == msg_count
|
||||
end
|
||||
|
||||
it 'does not allow both relative and absolute' do
|
||||
msg_count = @zone.messages.queued.count
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
msg_count = @registrar2.messages.queued.count
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
|
@ -154,7 +130,7 @@ describe 'EPP Keyrelay', epp: true do
|
|||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'P1D' },
|
||||
|
@ -162,16 +138,16 @@ describe 'EPP Keyrelay', epp: true do
|
|||
}
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Exactly one parameter required: keyrelay > expiry > relative OR '\
|
||||
'keyrelay > expiry > absolute'
|
||||
|
||||
@zone.messages.queued.count.should == msg_count
|
||||
@registrar2.messages.queued.count.should == msg_count
|
||||
end
|
||||
|
||||
it 'saves legal document with keyrelay' do
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
|
@ -179,7 +155,7 @@ describe 'EPP Keyrelay', epp: true do
|
|||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'P1D' }
|
||||
|
@ -193,7 +169,7 @@ describe 'EPP Keyrelay', epp: true do
|
|||
]
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
|
||||
docs = Keyrelay.last.legal_documents
|
||||
|
@ -203,8 +179,8 @@ describe 'EPP Keyrelay', epp: true do
|
|||
end
|
||||
|
||||
it 'validates legal document types' do
|
||||
xml = epp_xml.keyrelay({
|
||||
name: { value: domain.name },
|
||||
xml = @epp_xml.keyrelay({
|
||||
name: { value: @domain.name },
|
||||
keyData: {
|
||||
flags: { value: '256' },
|
||||
protocol: { value: '3' },
|
||||
|
@ -212,7 +188,7 @@ describe 'EPP Keyrelay', epp: true do
|
|||
pubKey: { value: 'cmlraXN0aGViZXN0' }
|
||||
},
|
||||
authInfo: {
|
||||
pw: { value: domain.auth_info }
|
||||
pw: { value: @domain.auth_info }
|
||||
},
|
||||
expiry: {
|
||||
relative: { value: 'P1D' }
|
||||
|
@ -226,7 +202,7 @@ describe 'EPP Keyrelay', epp: true do
|
|||
]
|
||||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Attribute is invalid: type'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue