mirror of
https://github.com/internetee/registry.git
synced 2025-06-14 16:44:46 +02:00
Refactor keyrelay specs
This commit is contained in:
parent
418695ccc7
commit
bfb8670233
3 changed files with 154 additions and 140 deletions
|
@ -90,12 +90,6 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with citizen as an owner' do
|
context 'with citizen as an owner' do
|
||||||
# before(:each) do
|
|
||||||
# Fabricate(:contact, code: 'citizen_1234')
|
|
||||||
# Fabricate(:contact, code: 'sh8013')
|
|
||||||
# Fabricate(:contact, code: 'sh801333')
|
|
||||||
# end
|
|
||||||
|
|
||||||
it 'creates a domain' do
|
it 'creates a domain' do
|
||||||
dn = next_domain_name
|
dn = next_domain_name
|
||||||
response = epp_request(domain_create_xml({
|
response = epp_request(domain_create_xml({
|
||||||
|
|
|
@ -3,22 +3,25 @@ require 'rails_helper'
|
||||||
describe 'EPP Keyrelay', epp: true do
|
describe 'EPP Keyrelay', epp: true do
|
||||||
let(:server_zone) { Epp::Server.new({ server: 'localhost', tag: 'zone', password: 'ghyt9e4fu', port: 701 }) }
|
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(:server_elkdata) { Epp::Server.new({ server: 'localhost', tag: 'elkdata', password: 'ghyt9e4fu', port: 701 }) }
|
||||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
|
||||||
let(:zone) { Fabricate(:registrar) }
|
|
||||||
let(:domain) { Fabricate(:domain, name: 'example.ee', registrar: zone, dnskeys: [Fabricate.build(:dnskey)]) }
|
|
||||||
let(:epp_xml) { EppXml::Keyrelay.new }
|
let(:epp_xml) { EppXml::Keyrelay.new }
|
||||||
|
|
||||||
before(:each) { create_settings }
|
before(:each) { create_settings }
|
||||||
|
|
||||||
context 'with valid user' do
|
before(:all) do
|
||||||
before(:each) do
|
@elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' })
|
||||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
@zone = Fabricate(:registrar)
|
||||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
Fabricate(:epp_user, username: 'zone', registrar: @zone)
|
||||||
|
Fabricate(:epp_user, username: 'elkdata', registrar: @elkdata)
|
||||||
|
|
||||||
|
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||||
end
|
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
|
it 'makes a keyrelay request' do
|
||||||
xml = epp_xml.keyrelay({
|
xml = epp_xml.keyrelay({
|
||||||
name: { value: 'example.ee' },
|
name: { value: domain.name },
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '256' },
|
flags: { value: '256' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
|
@ -38,7 +41,7 @@ describe 'EPP Keyrelay', epp: true do
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(1)
|
expect(@zone.messages.queued.count).to eq(1)
|
||||||
|
|
||||||
log = ApiLog::EppLog.all
|
log = ApiLog::EppLog.all
|
||||||
|
|
||||||
|
@ -66,8 +69,9 @@ describe 'EPP Keyrelay', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an error when parameters are missing' do
|
it 'returns an error when parameters are missing' do
|
||||||
|
msg_count = @zone.messages.queued.count
|
||||||
xml = epp_xml.keyrelay({
|
xml = epp_xml.keyrelay({
|
||||||
name: { value: 'example.ee' },
|
name: { value: domain.name },
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '' },
|
flags: { value: '' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
|
@ -85,12 +89,13 @@ describe 'EPP Keyrelay', epp: true do
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
expect(response[:msg]).to eq('Required parameter missing: flags')
|
expect(response[:msg]).to eq('Required parameter missing: flags')
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
expect(@zone.messages.queued.count).to eq(msg_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an error on invalid relative expiry' do
|
it 'returns an error on invalid relative expiry' do
|
||||||
|
msg_count = @zone.messages.queued.count
|
||||||
xml = epp_xml.keyrelay({
|
xml = epp_xml.keyrelay({
|
||||||
name: { value: 'example.ee' },
|
name: { value: domain.name },
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '256' },
|
flags: { value: '256' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
|
@ -109,12 +114,13 @@ describe 'EPP Keyrelay', epp: true do
|
||||||
expect(response[:msg]).to eq('Expiry relative must be compatible to ISO 8601')
|
expect(response[:msg]).to eq('Expiry relative must be compatible to ISO 8601')
|
||||||
expect(response[:results][0][:value]).to eq('Invalid Expiry')
|
expect(response[:results][0][:value]).to eq('Invalid Expiry')
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
expect(@zone.messages.queued.count).to eq(msg_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an error on invalid absolute expiry' do
|
it 'returns an error on invalid absolute expiry' do
|
||||||
|
msg_count = @zone.messages.queued.count
|
||||||
xml = epp_xml.keyrelay({
|
xml = epp_xml.keyrelay({
|
||||||
name: { value: 'example.ee' },
|
name: { value: domain.name },
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '256' },
|
flags: { value: '256' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
|
@ -133,12 +139,13 @@ describe 'EPP Keyrelay', epp: true do
|
||||||
expect(response[:msg]).to eq('Expiry absolute must be compatible to ISO 8601')
|
expect(response[:msg]).to eq('Expiry absolute must be compatible to ISO 8601')
|
||||||
expect(response[:results][0][:value]).to eq('Invalid Absolute')
|
expect(response[:results][0][:value]).to eq('Invalid Absolute')
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
expect(@zone.messages.queued.count).to eq(msg_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not allow both relative and absolute' do
|
it 'does not allow both relative and absolute' do
|
||||||
|
msg_count = @zone.messages.queued.count
|
||||||
xml = epp_xml.keyrelay({
|
xml = epp_xml.keyrelay({
|
||||||
name: { value: 'example.ee' },
|
name: { value: domain.name },
|
||||||
keyData: {
|
keyData: {
|
||||||
flags: { value: '256' },
|
flags: { value: '256' },
|
||||||
protocol: { value: '3' },
|
protocol: { value: '3' },
|
||||||
|
@ -157,7 +164,6 @@ describe 'EPP Keyrelay', epp: true do
|
||||||
response = epp_request(xml, :xml, :elkdata)
|
response = epp_request(xml, :xml, :elkdata)
|
||||||
expect(response[:msg]).to eq('Exactly one parameter required: expiry > relative or expiry > absolute')
|
expect(response[:msg]).to eq('Exactly one parameter required: expiry > relative or expiry > absolute')
|
||||||
|
|
||||||
expect(zone.messages.queued.count).to eq(0)
|
expect(@zone.messages.queued.count).to eq(msg_count)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,13 +31,11 @@ RSpec.configure do |config|
|
||||||
# instead of true.
|
# instead of true.
|
||||||
config.use_transactional_fixtures = false
|
config.use_transactional_fixtures = false
|
||||||
|
|
||||||
config.before(:suite) do
|
config.before(:all) do
|
||||||
ActiveRecord::Base.establish_connection :api_log_test
|
ActiveRecord::Base.establish_connection :api_log_test
|
||||||
DatabaseCleaner.strategy = :deletion
|
DatabaseCleaner.strategy = :deletion
|
||||||
DatabaseCleaner.clean
|
|
||||||
ActiveRecord::Base.establish_connection :test
|
ActiveRecord::Base.establish_connection :test
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
DatabaseCleaner.clean
|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
|
@ -48,6 +46,22 @@ RSpec.configure do |config|
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.before(:all, epp: true) do
|
||||||
|
ActiveRecord::Base.establish_connection :api_log_test
|
||||||
|
DatabaseCleaner.clean
|
||||||
|
|
||||||
|
ActiveRecord::Base.establish_connection :test
|
||||||
|
DatabaseCleaner.clean
|
||||||
|
end
|
||||||
|
|
||||||
|
config.after(:all, epp: true) do
|
||||||
|
ActiveRecord::Base.establish_connection :api_log_test
|
||||||
|
DatabaseCleaner.clean
|
||||||
|
|
||||||
|
ActiveRecord::Base.establish_connection :test
|
||||||
|
DatabaseCleaner.clean
|
||||||
|
end
|
||||||
|
|
||||||
config.before(:each, js: true) do
|
config.before(:each, js: true) do
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue