mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 17:53:35 +02:00
parent
8c474b2465
commit
666ba69456
9 changed files with 243 additions and 148 deletions
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Contact do
|
describe Contact do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
@api_user = Fabricate(:api_user)
|
@api_user = Fabricate(:api_user)
|
||||||
end
|
end
|
||||||
|
@ -363,3 +382,25 @@ describe Contact, '.destroy_orphans' do
|
||||||
Contact.count.should == cc
|
Contact.count.should == cc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RSpec.describe Contact, db: false do
|
||||||
|
describe '::names' do
|
||||||
|
before :example do
|
||||||
|
expect(described_class).to receive(:pluck).with(:name).and_return('names')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns names' do
|
||||||
|
expect(described_class.names).to eq('names')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '::emails' do
|
||||||
|
before :example do
|
||||||
|
expect(described_class).to receive(:pluck).with(:email).and_return('emails')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns emails' do
|
||||||
|
expect(described_class.emails).to eq('emails')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Dnskey do
|
describe Dnskey do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Domain do
|
RSpec.describe Domain do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
Fabricate(:zonefile_setting, origin: 'pri.ee')
|
Fabricate(:zonefile_setting, origin: 'pri.ee')
|
||||||
Fabricate(:zonefile_setting, origin: 'med.ee')
|
Fabricate(:zonefile_setting, origin: 'med.ee')
|
||||||
|
@ -842,6 +861,9 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe Domain, db: false do
|
RSpec.describe Domain, db: false do
|
||||||
|
it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) }
|
||||||
|
it { is_expected.to alias_attribute(:delete_time, :delete_at) }
|
||||||
|
|
||||||
describe '#set_server_hold' do
|
describe '#set_server_hold' do
|
||||||
let(:domain) { described_class.new }
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
@ -858,4 +880,77 @@ RSpec.describe Domain, db: false do
|
||||||
expect(domain.outzone_at).to eq(Time.zone.parse('05.07.2010'))
|
expect(domain.outzone_at).to eq(Time.zone.parse('05.07.2010'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#admin_contact_names' do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
expect(Contact).to receive(:names).and_return('names')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns admin contact names' do
|
||||||
|
expect(domain.admin_contact_names).to eq('names')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#admin_contact_emails' do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
expect(Contact).to receive(:emails).and_return('emails')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns admin contact emails' do
|
||||||
|
expect(domain.admin_contact_emails).to eq('emails')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#tech_contact_names' do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
expect(Contact).to receive(:names).and_return('names')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns technical contact names' do
|
||||||
|
expect(domain.tech_contact_names).to eq('names')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#nameserver_hostnames' do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
expect(Nameserver).to receive(:hostnames).and_return('hostnames')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns name server hostnames' do
|
||||||
|
expect(domain.nameserver_hostnames).to eq('hostnames')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#registered?' do
|
||||||
|
before :example do
|
||||||
|
travel_to Time.zone.parse('05.07.2010 00:00:01')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when :valid_to is in the future' do
|
||||||
|
let(:domain) { described_class.new(valid_to: Time.zone.parse('06.07.2010')) }
|
||||||
|
|
||||||
|
specify { expect(domain).to be_registered }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when :valid_to is the same as current time' do
|
||||||
|
let(:domain) { described_class.new(valid_to: Time.zone.parse('05.07.2010 00:00:01')) }
|
||||||
|
|
||||||
|
|
||||||
|
specify { expect(domain).to be_registered }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when :valid_to is in the past' do
|
||||||
|
let(:domain) { described_class.new(valid_to: Time.zone.parse('04.07.2010 23:59:59')) }
|
||||||
|
|
||||||
|
specify { expect(domain).to_not be_registered }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe DomainTransfer do
|
describe DomainTransfer do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Keyrelay do
|
describe Keyrelay do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe Nameserver do
|
describe Nameserver do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -92,3 +111,15 @@ describe Nameserver do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RSpec.describe Nameserver do
|
||||||
|
describe '::hostnames', db: false do
|
||||||
|
before :example do
|
||||||
|
expect(described_class).to receive(:pluck).with(:hostname).and_return('hostnames')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns names' do
|
||||||
|
expect(described_class.hostnames).to eq('hostnames')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -2,6 +2,25 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe RegistrantVerification do
|
describe RegistrantVerification do
|
||||||
before :example do
|
before :example do
|
||||||
|
Setting.ds_algorithm = 2
|
||||||
|
Setting.ds_data_allowed = true
|
||||||
|
Setting.ds_data_with_key_allowed = true
|
||||||
|
Setting.key_data_allowed = true
|
||||||
|
|
||||||
|
Setting.dnskeys_min_count = 0
|
||||||
|
Setting.dnskeys_max_count = 9
|
||||||
|
Setting.ns_min_count = 2
|
||||||
|
Setting.ns_max_count = 11
|
||||||
|
|
||||||
|
Setting.transfer_wait_time = 0
|
||||||
|
|
||||||
|
Setting.admin_contacts_min_count = 1
|
||||||
|
Setting.admin_contacts_max_count = 10
|
||||||
|
Setting.tech_contacts_min_count = 0
|
||||||
|
Setting.tech_contacts_max_count = 10
|
||||||
|
|
||||||
|
Setting.client_side_status_editing_enabled = true
|
||||||
|
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
end
|
end
|
||||||
context 'with invalid attribute' do
|
context 'with invalid attribute' do
|
||||||
|
|
|
@ -15,33 +15,10 @@ require 'support/matchers/alias_attribute'
|
||||||
require 'support/matchers/active_job'
|
require 'support/matchers/active_job'
|
||||||
require 'support/capybara'
|
require 'support/capybara'
|
||||||
require 'support/database_cleaner'
|
require 'support/database_cleaner'
|
||||||
require 'support/request'
|
|
||||||
require 'support/paper_trail'
|
require 'support/paper_trail'
|
||||||
|
|
||||||
ActiveRecord::Migration.maintain_test_schema!
|
ActiveRecord::Migration.maintain_test_schema!
|
||||||
|
|
||||||
# create general settings
|
|
||||||
def create_settings
|
|
||||||
Setting.ds_algorithm = 2
|
|
||||||
Setting.ds_data_allowed = true
|
|
||||||
Setting.ds_data_with_key_allowed = true
|
|
||||||
Setting.key_data_allowed = true
|
|
||||||
|
|
||||||
Setting.dnskeys_min_count = 0
|
|
||||||
Setting.dnskeys_max_count = 9
|
|
||||||
Setting.ns_min_count = 2
|
|
||||||
Setting.ns_max_count = 11
|
|
||||||
|
|
||||||
Setting.transfer_wait_time = 0
|
|
||||||
|
|
||||||
Setting.admin_contacts_min_count = 1
|
|
||||||
Setting.admin_contacts_max_count = 10
|
|
||||||
Setting.tech_contacts_min_count = 0
|
|
||||||
Setting.tech_contacts_max_count = 10
|
|
||||||
|
|
||||||
Setting.client_side_status_editing_enabled = true
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include ActionView::TestCase::Behavior, type: :presenter
|
config.include ActionView::TestCase::Behavior, type: :presenter
|
||||||
config.include ActiveSupport::Testing::TimeHelpers
|
config.include ActiveSupport::Testing::TimeHelpers
|
||||||
|
@ -52,27 +29,6 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.use_transactional_fixtures = false
|
config.use_transactional_fixtures = false
|
||||||
|
|
||||||
config.before(:all) do
|
|
||||||
create_settings
|
|
||||||
end
|
|
||||||
|
|
||||||
config.before(:all, epp: true) do
|
|
||||||
create_settings
|
|
||||||
end
|
|
||||||
|
|
||||||
config.before(:each, js: true) do
|
|
||||||
create_settings
|
|
||||||
end
|
|
||||||
|
|
||||||
config.before(:each, type: :request) do
|
|
||||||
create_settings
|
|
||||||
end
|
|
||||||
|
|
||||||
config.before(:each, type: :model) do
|
|
||||||
create_settings
|
|
||||||
end
|
|
||||||
|
|
||||||
config.infer_spec_type_from_file_location!
|
config.infer_spec_type_from_file_location!
|
||||||
|
|
||||||
config.expect_with :rspec do |c|
|
config.expect_with :rspec do |c|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
module Request
|
|
||||||
def get_with_auth(path, params, epp_user)
|
|
||||||
get path, params, env_with_auth(epp_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete_with_auth(path, epp_user)
|
|
||||||
delete path, params, env_with_auth(epp_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def post_with_auth(path, params, epp_user)
|
|
||||||
post path, params, env_with_auth(epp_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def patch_with_auth(path, params, epp_user)
|
|
||||||
patch path, params, env_with_auth(epp_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def env
|
|
||||||
{
|
|
||||||
'Accept' => 'application/json',
|
|
||||||
'Content-Type' => 'application/json'
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def env_with_auth(epp_user)
|
|
||||||
env.merge({
|
|
||||||
'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(
|
|
||||||
epp_user.username, epp_user.password
|
|
||||||
)
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module Autodoc
|
|
||||||
class Document
|
|
||||||
def route_info_doc
|
|
||||||
return unless example.metadata[:route_info_doc]
|
|
||||||
route = request.env["rack.routing_args"][:route_info]
|
|
||||||
return unless route.route_params.is_a?(Hash)
|
|
||||||
return if route.route_params.empty?
|
|
||||||
|
|
||||||
rows = [
|
|
||||||
"| Field name | Required | Type | Allowed values | Description |",
|
|
||||||
"| ---------- | -------- | ---- | -------------- | ----------- |"
|
|
||||||
]
|
|
||||||
|
|
||||||
route.route_params.each do |name, desc|
|
|
||||||
details = []
|
|
||||||
details << "| #{name} "
|
|
||||||
details << "| #{desc[:required]} "
|
|
||||||
details << "| #{desc[:type]} "
|
|
||||||
details << "| #{ranges_from_array(desc[:values])} "
|
|
||||||
details << "| #{desc[:desc]} |"
|
|
||||||
rows << details.join
|
|
||||||
end
|
|
||||||
|
|
||||||
pretty_table(rows).join("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
def pretty_table(rows)
|
|
||||||
# longest_in_col = 0
|
|
||||||
matrix_array = []
|
|
||||||
rows.each do |x|
|
|
||||||
matrix_array << x.split('|') + [''] # [''] is because split loses last |
|
|
||||||
end
|
|
||||||
|
|
||||||
new_arr = []
|
|
||||||
matrix_array.transpose.each do |col|
|
|
||||||
new_col = []
|
|
||||||
longest = col.max_by(&:size).size
|
|
||||||
|
|
||||||
col.each do |r|
|
|
||||||
new_col << r.center(longest)
|
|
||||||
end
|
|
||||||
new_arr << new_col
|
|
||||||
end
|
|
||||||
|
|
||||||
matrix_array = []
|
|
||||||
new_arr.transpose.each do |x|
|
|
||||||
matrix_array << x.join('|')
|
|
||||||
end
|
|
||||||
|
|
||||||
matrix_array
|
|
||||||
end
|
|
||||||
|
|
||||||
def ranges_from_array(a)
|
|
||||||
return unless a
|
|
||||||
ranges = a.sort.uniq.reduce([]) do |spans, n|
|
|
||||||
return a if n.is_a?(String)
|
|
||||||
if spans.empty? || spans.last.last != n - 1
|
|
||||||
spans + [n..n]
|
|
||||||
else
|
|
||||||
spans[0..-2] + [spans.last.first..n]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ranges
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.configure do |c|
|
|
||||||
c.include Request, type: :request
|
|
||||||
end
|
|
Loading…
Add table
Add a link
Reference in a new issue