mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
commit
ab9c7fa351
160 changed files with 1962 additions and 7650 deletions
|
@ -38,7 +38,6 @@ exclude_patterns:
|
||||||
- "lib/tasks/import.rake"
|
- "lib/tasks/import.rake"
|
||||||
- "lib/tasks/legal_doc.rake"
|
- "lib/tasks/legal_doc.rake"
|
||||||
- "lib/tasks/whois.rake"
|
- "lib/tasks/whois.rake"
|
||||||
- "spec/"
|
|
||||||
- "test/"
|
- "test/"
|
||||||
- "vendor/"
|
- "vendor/"
|
||||||
- "CHANGELOG.md"
|
- "CHANGELOG.md"
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
SimpleCov.start 'rails' do
|
|
||||||
add_filter '/app/models/legacy/'
|
|
||||||
add_filter '/app/models/version/'
|
|
||||||
add_filter '/lib/action_controller/'
|
|
||||||
add_filter '/lib/core_ext/'
|
|
||||||
add_filter '/lib/daemons/'
|
|
||||||
add_filter '/lib/gem_ext/'
|
|
||||||
end
|
|
|
@ -23,7 +23,6 @@ before_script:
|
||||||
- "chmod +x ./cc-test-reporter"
|
- "chmod +x ./cc-test-reporter"
|
||||||
- "./cc-test-reporter before-build"
|
- "./cc-test-reporter before-build"
|
||||||
script:
|
script:
|
||||||
- "bundle exec rspec"
|
|
||||||
- "bundle exec rake test"
|
- "bundle exec rake test"
|
||||||
after_script:
|
after_script:
|
||||||
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -89,9 +89,7 @@ group :development do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'factory_bot_rails'
|
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
gem 'rspec-rails', '~> 3.6'
|
|
||||||
gem 'selenium-webdriver'
|
gem 'selenium-webdriver'
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
|
|
15
Gemfile.lock
15
Gemfile.lock
|
@ -176,11 +176,6 @@ GEM
|
||||||
equalizer (0.0.11)
|
equalizer (0.0.11)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
factory_bot (4.8.2)
|
|
||||||
activesupport (>= 3.0.0)
|
|
||||||
factory_bot_rails (4.8.2)
|
|
||||||
factory_bot (~> 4.8.2)
|
|
||||||
railties (>= 3.0.0)
|
|
||||||
ffi (1.9.25)
|
ffi (1.9.25)
|
||||||
figaro (1.1.1)
|
figaro (1.1.1)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
|
@ -341,14 +336,6 @@ GEM
|
||||||
rspec-mocks (3.6.0)
|
rspec-mocks (3.6.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.6.0)
|
rspec-support (~> 3.6.0)
|
||||||
rspec-rails (3.6.0)
|
|
||||||
actionpack (>= 3.0)
|
|
||||||
activesupport (>= 3.0)
|
|
||||||
railties (>= 3.0)
|
|
||||||
rspec-core (~> 3.6.0)
|
|
||||||
rspec-expectations (~> 3.6.0)
|
|
||||||
rspec-mocks (~> 3.6.0)
|
|
||||||
rspec-support (~> 3.6.0)
|
|
||||||
rspec-support (3.6.0)
|
rspec-support (3.6.0)
|
||||||
rubyzip (1.2.2)
|
rubyzip (1.2.2)
|
||||||
safe_yaml (1.0.5)
|
safe_yaml (1.0.5)
|
||||||
|
@ -458,7 +445,6 @@ DEPENDENCIES
|
||||||
e_invoice!
|
e_invoice!
|
||||||
epp (= 1.5.0)!
|
epp (= 1.5.0)!
|
||||||
epp-xml (= 1.1.0)!
|
epp-xml (= 1.1.0)!
|
||||||
factory_bot_rails
|
|
||||||
figaro (= 1.1.1)
|
figaro (= 1.1.1)
|
||||||
grape
|
grape
|
||||||
haml
|
haml
|
||||||
|
@ -483,7 +469,6 @@ DEPENDENCIES
|
||||||
rails-settings-cached (= 0.7.2)
|
rails-settings-cached (= 0.7.2)
|
||||||
ransack (= 1.5.1)
|
ransack (= 1.5.1)
|
||||||
rest-client
|
rest-client
|
||||||
rspec-rails (~> 3.6)
|
|
||||||
sass-rails (= 5.0.6)
|
sass-rails (= 5.0.6)
|
||||||
sdoc (= 0.4.1)
|
sdoc (= 0.4.1)
|
||||||
select2-rails (= 3.5.9.3)
|
select2-rails (= 3.5.9.3)
|
||||||
|
|
16
bin/rspec
16
bin/rspec
|
@ -1,16 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
#
|
|
||||||
# This file was generated by Bundler.
|
|
||||||
#
|
|
||||||
# The application 'rspec' is installed as part of a gem, and
|
|
||||||
# this file is here to facilitate running it.
|
|
||||||
#
|
|
||||||
|
|
||||||
require 'pathname'
|
|
||||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
||||||
Pathname.new(__FILE__).realpath)
|
|
||||||
|
|
||||||
require 'rubygems'
|
|
||||||
require 'bundler/setup'
|
|
||||||
|
|
||||||
load Gem.bin_path('rspec-core', 'rspec')
|
|
|
@ -76,9 +76,6 @@ module DomainNameRegistry
|
||||||
config.action_mailer.perform_deliveries = true
|
config.action_mailer.perform_deliveries = true
|
||||||
config.action_mailer.raise_delivery_errors = true
|
config.action_mailer.raise_delivery_errors = true
|
||||||
|
|
||||||
# Override "spec/mailers/previews" that RSpec sets
|
|
||||||
config.action_mailer.preview_path = "#{Rails.root}/test/mailers/previews"
|
|
||||||
|
|
||||||
config.action_mailer.smtp_settings = {
|
config.action_mailer.smtp_settings = {
|
||||||
address: ENV['smtp_address'],
|
address: ENV['smtp_address'],
|
||||||
port: ENV['smtp_port'],
|
port: ENV['smtp_port'],
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Repp::ContactV1, db: true do
|
|
||||||
let(:user) { create(:api_user, registrar: registrar) }
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
|
|
||||||
describe '/contacts' do
|
|
||||||
let(:returned_attributes) { HashWithIndifferentAccess.new(JSON.parse(response.body)['contacts'].first).keys }
|
|
||||||
subject(:address_included) { Contact.address_attribute_names.any? { |attr| returned_attributes.include?(attr.to_s) } }
|
|
||||||
|
|
||||||
before do
|
|
||||||
Grape::Endpoint.before_each do |endpoint|
|
|
||||||
allow(endpoint).to receive(:current_user).and_return(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
registrar.contacts << create(:contact)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'responds with success' do
|
|
||||||
get '/repp/v1/contacts', { limit: 1, details: true }, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
|
||||||
expect(response).to have_http_status(:success)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when address processing is enabled' do
|
|
||||||
before do
|
|
||||||
expect(Contact).to receive(:address_processing?).and_return(true)
|
|
||||||
get '/repp/v1/contacts', { limit: 1, details: true }, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns contact address' do
|
|
||||||
expect(address_included).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when address processing is disabled' do
|
|
||||||
before do
|
|
||||||
expect(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
get '/repp/v1/contacts', { limit: 1, details: true }, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not return contact address' do
|
|
||||||
expect(address_included).to be_falsy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def http_auth_key
|
|
||||||
ActionController::HttpAuthentication::Basic.encode_credentials(user.username, user.plain_text_password)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :account do
|
|
||||||
account_type Account::CASH
|
|
||||||
balance 1
|
|
||||||
currency 'EUR'
|
|
||||||
registrar
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :account_activity do
|
|
||||||
sum 1.0
|
|
||||||
account
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :admin_domain_contact, parent: :domain_contact, class: AdminDomainContact do
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :admin_user do
|
|
||||||
username 'test'
|
|
||||||
sequence(:email) { |n| "test#{n}@test.com" }
|
|
||||||
password 'a' * AdminUser.min_password_length
|
|
||||||
password_confirmation { password }
|
|
||||||
country_code 'de'
|
|
||||||
roles ['admin']
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,23 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :api_user do
|
|
||||||
sequence(:username) { |n| "test#{n}" }
|
|
||||||
plain_text_password 'a' * ApiUser.min_password_length
|
|
||||||
roles ['super']
|
|
||||||
registrar
|
|
||||||
|
|
||||||
factory :api_user_epp do
|
|
||||||
roles %w(epp static_registrant)
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :api_user_with_unlimited_balance do
|
|
||||||
transient do
|
|
||||||
registrar false
|
|
||||||
end
|
|
||||||
|
|
||||||
after :build do |api_user, evaluator|
|
|
||||||
registrar = (evaluator.registrar || create(:registrar_with_unlimited_balance))
|
|
||||||
api_user.registrar = registrar
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,18 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :price, class: Billing::Price do
|
|
||||||
price Money.from_amount(1)
|
|
||||||
valid_from Time.zone.parse('05.07.2010')
|
|
||||||
valid_to Time.zone.parse('05.07.2010')
|
|
||||||
duration '1 year'
|
|
||||||
operation_category Billing::Price.operation_categories.first
|
|
||||||
zone
|
|
||||||
|
|
||||||
factory :effective_price do
|
|
||||||
expire_time { Time.zone.now + 1.day }
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :expired_price do
|
|
||||||
expire_time { Time.zone.now - 1.day }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,39 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :contact do
|
|
||||||
name 'test'
|
|
||||||
sequence(:code) { |n| "test#{n}" }
|
|
||||||
phone '+123.456789'
|
|
||||||
email 'test@test.com'
|
|
||||||
street 'test'
|
|
||||||
city 'test'
|
|
||||||
zip 12345
|
|
||||||
country_code 'EE'
|
|
||||||
ident '37605030299'
|
|
||||||
ident_type 'priv'
|
|
||||||
ident_country_code 'EE'
|
|
||||||
registrar
|
|
||||||
|
|
||||||
factory :contact_private_entity do
|
|
||||||
ident_type 'priv'
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :contact_legal_entity do
|
|
||||||
ident_type 'org'
|
|
||||||
ident '12345678' # valid reg no for .ee
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :contact_with_address do
|
|
||||||
street 'test'
|
|
||||||
city 'test'
|
|
||||||
zip 12345
|
|
||||||
country_code 'EE'
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :contact_without_address do
|
|
||||||
street nil
|
|
||||||
city nil
|
|
||||||
zip nil
|
|
||||||
country_code nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :zone, class: DNS::Zone do
|
|
||||||
sequence(:origin) { |n| "test#{n}" }
|
|
||||||
ttl 1
|
|
||||||
refresh 1
|
|
||||||
add_attribute :retry, 1
|
|
||||||
expire 1
|
|
||||||
minimum_ttl 1
|
|
||||||
email 'test.test'
|
|
||||||
master_nameserver 'test.test'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :dnskey do
|
|
||||||
alg Dnskey::ALGORITHMS.first
|
|
||||||
flags Dnskey::FLAGS.first
|
|
||||||
protocol Dnskey::PROTOCOLS.first
|
|
||||||
ds_digest_type 2
|
|
||||||
public_key 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\
|
|
||||||
'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\
|
|
||||||
'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\
|
|
||||||
'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
|
|
||||||
'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
|
|
||||||
'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs='
|
|
||||||
domain
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :domain do
|
|
||||||
sequence(:name) { |n| "test#{n}.com" }
|
|
||||||
period 1
|
|
||||||
period_unit 'y' # Year
|
|
||||||
valid_to Time.zone.parse('2010-07-05')
|
|
||||||
registrar
|
|
||||||
registrant
|
|
||||||
|
|
||||||
after :build do |domain|
|
|
||||||
domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact)
|
|
||||||
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :domain_contact do
|
|
||||||
contact
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :epp_session do
|
|
||||||
sequence(:session_id) { |n| "test#{n}" }
|
|
||||||
association :user, factory: :api_user
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :keyrelay do
|
|
||||||
pa_date { Time.zone.now }
|
|
||||||
expiry_relative 'P1W'
|
|
||||||
key_data_public_key 'abc'
|
|
||||||
key_data_flags 0
|
|
||||||
key_data_protocol 3
|
|
||||||
key_data_alg 3
|
|
||||||
auth_info_pw 'abc'
|
|
||||||
domain
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :nameserver do
|
|
||||||
sequence(:hostname) { |n| "ns.test#{n}.ee" }
|
|
||||||
ipv4 '192.168.1.1'
|
|
||||||
domain
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :registrant, parent: :contact, class: Registrant do
|
|
||||||
name 'test'
|
|
||||||
|
|
||||||
factory :registrant_private_entity, class: Registrant, parent: :contact_private_entity
|
|
||||||
factory :registrant_legal_entity, class: Registrant, parent: :contact_legal_entity
|
|
||||||
factory :registrant_with_address, class: Registrant, parent: :contact_with_address
|
|
||||||
factory :registrant_without_address, class: Registrant, parent: :contact_without_address
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :registrant_user do
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :registrant_verification do
|
|
||||||
sequence(:domain_name) { |i| "domain#{i}.ee" }
|
|
||||||
domain
|
|
||||||
verification_token '123'
|
|
||||||
action 'confirmed'
|
|
||||||
action_type 'registrant_change'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,26 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :registrar do
|
|
||||||
sequence(:name) { |n| "test#{n}" }
|
|
||||||
sequence(:code) { |n| "test#{n}" }
|
|
||||||
sequence(:reg_no) { |n| "test#{n}" }
|
|
||||||
email 'test@test.com'
|
|
||||||
address_street 'test'
|
|
||||||
address_city 'test'
|
|
||||||
address_country_code 'US'
|
|
||||||
accounting_customer_code 'test'
|
|
||||||
language 'en'
|
|
||||||
sequence(:reference_no) { |n| "1234#{n}" }
|
|
||||||
|
|
||||||
factory :registrar_with_unlimited_balance do
|
|
||||||
after :create do |registrar|
|
|
||||||
create(:account, registrar: registrar, balance: 1_000_000)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :registrar_with_zero_balance do
|
|
||||||
after :create do |registrar|
|
|
||||||
create(:account, registrar: registrar, balance: 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :reserved_domain do
|
|
||||||
sequence(:name) { |i| "domain#{i}.ee" }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :tech_domain_contact, parent: :domain_contact, class: TechDomainContact do
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
FactoryBot.define do
|
|
||||||
factory :white_ip do
|
|
||||||
ipv4 '127.0.0.1'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
require_relative 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'FactoryBot', db: true do
|
|
||||||
before :example do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'lints factories' do
|
|
||||||
factories_to_lint = FactoryBot.factories.reject do |factory|
|
|
||||||
%i(reserved_domain).include?(factory.name) || factory.name.to_s =~ /^domain/ # Ignore the ones with domain_name validator
|
|
||||||
end
|
|
||||||
|
|
||||||
FactoryBot.lint factories_to_lint
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Editing price in admin area', settings: false do
|
|
||||||
given!(:price) { create(:effective_price) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'updates price' do
|
|
||||||
visit admin_prices_path
|
|
||||||
open_form
|
|
||||||
submit_form
|
|
||||||
|
|
||||||
expect(page).to have_text(t('admin.billing.prices.update.updated'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_form
|
|
||||||
find('.edit-price-btn').click
|
|
||||||
end
|
|
||||||
|
|
||||||
def submit_form
|
|
||||||
click_link_or_button t('admin.billing.prices.form.update_btn')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Expiring price in admin area', settings: false do
|
|
||||||
given!(:price) { create(:effective_price) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'expires price' do
|
|
||||||
visit admin_prices_path
|
|
||||||
open_edit_form
|
|
||||||
expire
|
|
||||||
|
|
||||||
expect(page).to have_text(t('admin.billing.prices.expire.expired'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_edit_form
|
|
||||||
find('.edit-price-btn').click
|
|
||||||
end
|
|
||||||
|
|
||||||
def expire
|
|
||||||
click_link_or_button t('admin.billing.prices.edit.expire_btn')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,33 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Viewing prices in admin area', settings: false do
|
|
||||||
given!(:effective_price) { create(:effective_price) }
|
|
||||||
given!(:expired_price) { create(:expired_price) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'search' do
|
|
||||||
context 'when status is not selected' do
|
|
||||||
scenario 'shows effective prices' do
|
|
||||||
visit admin_prices_path
|
|
||||||
expect(page).to have_css('.price', count: 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when status is given' do
|
|
||||||
scenario 'filters by given status' do
|
|
||||||
visit admin_prices_path
|
|
||||||
select Admin::Billing::PricesController.default_status.capitalize, from: 'search_status'
|
|
||||||
submit_search_form
|
|
||||||
|
|
||||||
expect(page).to have_css('.price', count: 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def submit_search_form
|
|
||||||
find('.price-search-form-search-btn').click
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,37 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'New price in admin area', settings: false do
|
|
||||||
given!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it creates new price' do
|
|
||||||
open_list
|
|
||||||
open_form
|
|
||||||
fill_form
|
|
||||||
submit_form
|
|
||||||
|
|
||||||
expect(page).to have_text(t('admin.billing.prices.create.created'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_list
|
|
||||||
click_link_or_button t('admin.base.menu.prices')
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_form
|
|
||||||
click_link_or_button t('admin.billing.prices.index.new_btn')
|
|
||||||
end
|
|
||||||
|
|
||||||
def fill_form
|
|
||||||
select 'test', from: 'price_zone_id'
|
|
||||||
select Billing::Price.operation_categories.first, from: 'price_operation_category'
|
|
||||||
select '3 months', from: 'price_duration'
|
|
||||||
fill_in 'price_price', with: '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
def submit_form
|
|
||||||
click_link_or_button t('admin.billing.prices.form.create_btn')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,29 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Editing zone in admin area', settings: false do
|
|
||||||
given!(:zone) { create(:zone) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'updates zone' do
|
|
||||||
visit admin_zones_url
|
|
||||||
open_form
|
|
||||||
submit_form
|
|
||||||
|
|
||||||
expect(page).to have_text(t('admin.dns.zones.update.updated'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_list
|
|
||||||
click_link_or_button t('admin.base.menu.zones')
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_form
|
|
||||||
click_link_or_button 'admin-edit-zone-btn'
|
|
||||||
end
|
|
||||||
|
|
||||||
def submit_form
|
|
||||||
click_link_or_button t('admin.dns.zones.form.update_btn')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,39 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'New zone in admin area', settings: false do
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'it creates new zone' do
|
|
||||||
open_list
|
|
||||||
open_form
|
|
||||||
fill_form
|
|
||||||
submit_form
|
|
||||||
|
|
||||||
expect(page).to have_text(t('admin.dns.zones.create.created'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_list
|
|
||||||
click_link_or_button t('admin.base.menu.zones')
|
|
||||||
end
|
|
||||||
|
|
||||||
def open_form
|
|
||||||
click_link_or_button t('admin.dns.zones.index.new_btn')
|
|
||||||
end
|
|
||||||
|
|
||||||
def fill_form
|
|
||||||
fill_in 'zone_origin', with: 'test'
|
|
||||||
fill_in 'zone_ttl', with: '1'
|
|
||||||
fill_in 'zone_refresh', with: '1'
|
|
||||||
fill_in 'zone_retry', with: '1'
|
|
||||||
fill_in 'zone_expire', with: '1'
|
|
||||||
fill_in 'zone_minimum_ttl', with: '1'
|
|
||||||
fill_in 'zone_email', with: 'test@test.com'
|
|
||||||
fill_in 'zone_master_nameserver', with: 'test.test'
|
|
||||||
end
|
|
||||||
|
|
||||||
def submit_form
|
|
||||||
click_link_or_button t('admin.dns.zones.form.create_btn')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Admin settings' do
|
|
||||||
background do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves settings' do
|
|
||||||
visit admin_settings_path
|
|
||||||
click_link_or_button 'Save'
|
|
||||||
expect(page).to have_text(t('admin.settings.create.saved'))
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,50 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
class FakeDeppContact
|
|
||||||
include ActiveModel::Model
|
|
||||||
|
|
||||||
def id
|
|
||||||
'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
def name
|
|
||||||
'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
def persisted?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def password
|
|
||||||
'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.feature 'Contact deletion in registrar area' do
|
|
||||||
given!(:registrar) { create(:registrar) }
|
|
||||||
given!(:contact) { create(:contact, registrar: registrar) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
allow(Depp::Contact).to receive(:find_by_id).and_return(FakeDeppContact.new)
|
|
||||||
allow(Depp::Contact).to receive(:new).and_return(FakeDeppContact.new)
|
|
||||||
sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance, registrar: registrar))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'deletes contact' do
|
|
||||||
visit registrar_contacts_url
|
|
||||||
click_link_or_button 'Delete'
|
|
||||||
confirm
|
|
||||||
|
|
||||||
expect(page).to have_text('Destroyed')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def confirm
|
|
||||||
click_link_or_button 'Delete'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Contact list', settings: false do
|
|
||||||
given!(:registrar) { create(:registrar) }
|
|
||||||
given!(:contact) { create(:contact, registrar: registrar) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance, registrar: registrar))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is visible' do
|
|
||||||
visit registrar_contacts_path
|
|
||||||
expect(page).to have_css('.contacts')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'New domain in registrar area', settings: false do
|
|
||||||
background do
|
|
||||||
sign_in_to_registrar_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has default period' do
|
|
||||||
visit registrar_domains_path
|
|
||||||
click_link_or_button t('new')
|
|
||||||
|
|
||||||
expect(page).to have_field('domain_period', with: Depp::Domain.default_period)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,18 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Renew domain in registrar area' do
|
|
||||||
given!(:registrar) { create(:registrar) }
|
|
||||||
given!(:user) { create(:api_user, registrar: registrar) }
|
|
||||||
given!(:domain) { create(:domain, registrar: registrar) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_registrar_area(user: user)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has default period' do
|
|
||||||
visit registrar_domains_path
|
|
||||||
click_link_or_button t('renew')
|
|
||||||
|
|
||||||
expect(page).to have_field('period', with: Depp::Domain.default_period)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Registrar area IP restriction', settings: false do
|
|
||||||
before do
|
|
||||||
@original_registrar_ip_whitelist_enabled = Setting.registrar_ip_whitelist_enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
Setting.registrar_ip_whitelist_enabled = @original_registrar_ip_whitelist_enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'notifies the user if his IP is not allowed' do
|
|
||||||
Setting.registrar_ip_whitelist_enabled = true
|
|
||||||
visit registrar_root_path
|
|
||||||
expect(page).to have_text('Access denied from IP 127.0.0.1')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Registrar area linked users', settings: false do
|
|
||||||
given!(:current_user) { create(:api_user_with_unlimited_balance, id: 1, identity_code: 'test') }
|
|
||||||
given!(:linked_user) { create(:api_user_with_unlimited_balance, id: 2, identity_code: 'test',
|
|
||||||
username: 'new-user-name') }
|
|
||||||
|
|
||||||
background do
|
|
||||||
sign_in_to_registrar_area(user: current_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'switches current user to a linked one' do
|
|
||||||
visit registrar_account_path
|
|
||||||
click_link_or_button 'switch-current-user-2-btn'
|
|
||||||
expect(page).to have_text('You are now signed in as a user "new-user-name"')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,43 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DomainExpireEmailJob do
|
|
||||||
describe '#run' do
|
|
||||||
let(:domain) { instance_double(Domain) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
expect(Domain).to receive(:find).and_return(domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
after :example do
|
|
||||||
domain_id = 1
|
|
||||||
described_class.enqueue(domain_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when domain is expired' do
|
|
||||||
let(:message) { instance_double(ActionMailer::MessageDelivery) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
allow(domain).to receive_messages(
|
|
||||||
registrar: 'registrar',
|
|
||||||
registered?: false,
|
|
||||||
primary_contact_emails: %w(test@test.com test@test.com))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends email' do
|
|
||||||
expect(DomainExpireMailer).to receive(:expired).with(domain: domain, registrar: 'registrar')
|
|
||||||
.and_return(message)
|
|
||||||
expect(message).to receive(:deliver_now)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when domain is registered' do
|
|
||||||
before :example do
|
|
||||||
allow(domain).to receive(:registered?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not send email' do
|
|
||||||
expect(DomainExpireMailer).to_not receive(:expired)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,40 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe RegistrantChangeExpiredEmailJob do
|
|
||||||
describe '#run' do
|
|
||||||
let(:domain) { instance_double(Domain,
|
|
||||||
id: 1,
|
|
||||||
name: 'test.com',
|
|
||||||
new_registrant_email: 'new-registrant@test.com',
|
|
||||||
registrar: 'registrar',
|
|
||||||
registrant: 'registrant')
|
|
||||||
}
|
|
||||||
let(:message) { instance_double(ActionMailer::MessageDelivery) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
expect(Domain).to receive(:find).and_return(domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
after :example do
|
|
||||||
domain_id = 1
|
|
||||||
described_class.enqueue(domain_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates log record' do
|
|
||||||
log_message = 'Send RegistrantChangeMailer#expired email for domain test.com (#1) to new-registrant@test.com'
|
|
||||||
|
|
||||||
allow(RegistrantChangeMailer).to receive(:expired).and_return(message)
|
|
||||||
allow(message).to receive(:deliver_now)
|
|
||||||
|
|
||||||
expect(Rails.logger).to receive(:info).with(log_message)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends email' do
|
|
||||||
expect(RegistrantChangeMailer).to receive(:expired).with(domain: domain,
|
|
||||||
registrar: 'registrar',
|
|
||||||
registrant: 'registrant')
|
|
||||||
.and_return(message)
|
|
||||||
expect(message).to receive(:deliver_now)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,29 +0,0 @@
|
||||||
# https://en.wikipedia.org/wiki/E.164
|
|
||||||
|
|
||||||
RSpec.shared_examples 'e164' do
|
|
||||||
describe 'validation' do
|
|
||||||
it 'rejects invalid format' do
|
|
||||||
model.send("#{attribute}=", '+.1')
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to be_added(attribute, :invalid)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects longer than max length' do
|
|
||||||
model.send("#{attribute}=", '1' * 18)
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to be_added(attribute, :too_long, count: 17)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid format' do
|
|
||||||
model.send("#{attribute}=", '+123.4')
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to_not be_added(attribute, :invalid)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts max length' do
|
|
||||||
model.send("#{attribute}=", '1' * 17)
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to_not be_added(attribute, :too_long, count: 17)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,23 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
RSpec.describe EmailValidator do
|
|
||||||
describe '#valid?' do
|
|
||||||
subject(:valid) { described_class.new(email).valid? }
|
|
||||||
|
|
||||||
context 'when email is valid' do
|
|
||||||
let(:email) { 'test@test.com' }
|
|
||||||
|
|
||||||
it 'returns truthy' do
|
|
||||||
expect(valid).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when email is invalid' do
|
|
||||||
let(:email) { 'invalid' }
|
|
||||||
|
|
||||||
it 'returns falsey' do
|
|
||||||
expect(valid).to be_falsey
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
# https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
||||||
|
|
||||||
RSpec.shared_examples 'iso31661_alpha2' do
|
|
||||||
describe 'validation' do
|
|
||||||
it 'rejects invalid' do
|
|
||||||
model.send("#{attribute}=", 'invalid')
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to be_added(attribute, :invalid_iso31661_alpha2)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
model.send("#{attribute}=", 'US')
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to_not be_added(attribute, :invalid_iso31661_alpha2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
# https://en.wikipedia.org/wiki/ISO_8601
|
|
||||||
|
|
||||||
RSpec.shared_examples 'iso8601' do
|
|
||||||
describe 'validation' do
|
|
||||||
it 'rejects invalid' do
|
|
||||||
model.send("#{attribute}=", '2010-07-0')
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to be_added(attribute, :invalid_iso8601_date)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
model.send("#{attribute}=", '2010-07-05')
|
|
||||||
model.validate
|
|
||||||
expect(model.errors).to_not be_added(attribute, :invalid_iso8601_date)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe AccountActivity do
|
|
||||||
describe 'account validation', db: false do
|
|
||||||
subject(:account_activity) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
account_activity.account = nil
|
|
||||||
account_activity.validate
|
|
||||||
expect(account_activity.errors).to have_key(:account)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Account do
|
|
||||||
describe 'registrar validation', db: false do
|
|
||||||
subject(:account) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
account.registrar = nil
|
|
||||||
account.validate
|
|
||||||
expect(account.errors).to have_key(:registrar)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,22 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe AdminUser do
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before do
|
|
||||||
@admin_user = create(:admin_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should require password confirmation when changing password' do
|
|
||||||
@admin_user.valid?.should == true
|
|
||||||
@admin_user.password = 'not confirmed'
|
|
||||||
@admin_user.valid?
|
|
||||||
@admin_user.errors.full_messages.should match_array(["Password confirmation doesn't match Password"])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::min_password_length' do
|
|
||||||
it 'returns minimum password length' do
|
|
||||||
expect(described_class.min_password_length).to eq(8)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,114 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe ApiUser do
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before do
|
|
||||||
@api_user = ApiUser.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid' do
|
|
||||||
@api_user.valid?
|
|
||||||
@api_user.errors.full_messages.should match_array([
|
|
||||||
"Password Password is missing",
|
|
||||||
"Password is too short (minimum is #{ApiUser.min_password_length} characters)",
|
|
||||||
"Registrar Registrar is missing",
|
|
||||||
"Username Username is missing",
|
|
||||||
"Roles is missing"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be active by default' do
|
|
||||||
@api_user.active.should == true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before do
|
|
||||||
@api_user = create(:api_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@api_user.valid?
|
|
||||||
@api_user.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@api_user = create(:api_user)
|
|
||||||
@api_user.valid?
|
|
||||||
@api_user.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::min_password_length', db: false do
|
|
||||||
it 'returns minimum password length' do
|
|
||||||
expect(described_class.min_password_length).to eq(6)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#linked_users' do
|
|
||||||
it 'returns users with the same identity code' do
|
|
||||||
api_user = create(:api_user, id: 1, identity_code: 'test')
|
|
||||||
create(:api_user, id: 2, identity_code: 'test')
|
|
||||||
|
|
||||||
expect(api_user.linked_users.ids).to include(2)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not return users with another identity code' do
|
|
||||||
api_user = create(:api_user, id: 1, identity_code: 'test')
|
|
||||||
create(:api_user, id: 2, identity_code: 'another')
|
|
||||||
|
|
||||||
expect(api_user.linked_users.ids).to_not include(2)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not return itself' do
|
|
||||||
api_user = create(:api_user)
|
|
||||||
expect(api_user.linked_users).to be_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns none if identity code is absent' do
|
|
||||||
api_user = create(:api_user, identity_code: nil)
|
|
||||||
create(:api_user, identity_code: nil)
|
|
||||||
|
|
||||||
expect(api_user.linked_users).to be_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns none if identity code is empty' do
|
|
||||||
api_user = create(:api_user, identity_code: '')
|
|
||||||
create(:api_user, identity_code: '')
|
|
||||||
|
|
||||||
expect(api_user.linked_users).to be_empty
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#linked_with?', db: false do
|
|
||||||
it 'returns true if identity codes match' do
|
|
||||||
api_user = described_class.new(identity_code: 'test')
|
|
||||||
another_api_user = described_class.new(identity_code: 'test')
|
|
||||||
|
|
||||||
expect(api_user.linked_with?(another_api_user)).to be true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns false if identity codes do not match' do
|
|
||||||
api_user = described_class.new(identity_code: 'test')
|
|
||||||
another_api_user = described_class.new(identity_code: 'another-test')
|
|
||||||
|
|
||||||
expect(api_user.linked_with?(another_api_user)).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#login', db: false do
|
|
||||||
it 'is alias to #username' do
|
|
||||||
user = described_class.new(username: 'test-username')
|
|
||||||
expect(user.login).to eq('test-username')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#registrar_name', db: false do
|
|
||||||
it 'delegates to registrar' do
|
|
||||||
registrar = Registrar.new(name: 'test name')
|
|
||||||
user = described_class.new(registrar: registrar)
|
|
||||||
|
|
||||||
expect(user.registrar_name).to eq('test name')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,98 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Authorization::RestrictedIP do
|
|
||||||
describe '::enabled?', db: true, settings: false do
|
|
||||||
before do
|
|
||||||
@original_registrar_ip_whitelist_enabled = Setting.registrar_ip_whitelist_enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
Setting.registrar_ip_whitelist_enabled = @original_registrar_ip_whitelist_enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when "registrar_ip_whitelist_enabled" is true' do
|
|
||||||
before do
|
|
||||||
Setting.registrar_ip_whitelist_enabled = true
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(described_class).to be_enabled
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when "registrar_ip_whitelist_enabled" is false' do
|
|
||||||
specify do
|
|
||||||
expect(described_class).to_not be_enabled
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#can_access_registrar_area?', db: true do
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
subject(:allowed) { described_class.new('127.0.0.1').can_access_registrar_area?(registrar) }
|
|
||||||
|
|
||||||
context 'when enabled' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:enabled?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when ip is whitelisted', db: true do
|
|
||||||
let!(:white_ip) { create(:white_ip, registrar: registrar, ipv4: '127.0.0.1', interfaces: [WhiteIp::REGISTRAR]) }
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(allowed).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when ip is not whitelisted' do
|
|
||||||
specify do
|
|
||||||
expect(allowed).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when disabled' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:enabled?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(allowed).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#can_access_registrar_area_sign_in_page?' do
|
|
||||||
subject(:allowed) { described_class.new('127.0.0.1').can_access_registrar_area_sign_in_page? }
|
|
||||||
|
|
||||||
context 'when enabled' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:enabled?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when ip is whitelisted', db: true do
|
|
||||||
let!(:white_ip) { create(:white_ip, ipv4: '127.0.0.1', interfaces: [WhiteIp::REGISTRAR]) }
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(allowed).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when ip is not whitelisted' do
|
|
||||||
specify do
|
|
||||||
expect(allowed).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when disabled' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:enabled?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(allowed).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,180 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Billing::Price do
|
|
||||||
it { is_expected.to monetize(:price) }
|
|
||||||
it { is_expected.to alias_attribute(:effect_time, :valid_from) }
|
|
||||||
it { is_expected.to alias_attribute(:expire_time, :valid_to) }
|
|
||||||
|
|
||||||
describe '::operation_categories', db: false do
|
|
||||||
it 'returns operation categories' do
|
|
||||||
categories = %w[create renew]
|
|
||||||
expect(described_class.operation_categories).to eq(categories)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::durations', db: false do
|
|
||||||
it 'returns durations' do
|
|
||||||
durations = [
|
|
||||||
'3 mons',
|
|
||||||
'6 mons',
|
|
||||||
'9 mons',
|
|
||||||
'1 year',
|
|
||||||
'2 years',
|
|
||||||
'3 years',
|
|
||||||
'4 years',
|
|
||||||
'5 years',
|
|
||||||
'6 years',
|
|
||||||
'7 years',
|
|
||||||
'8 years',
|
|
||||||
'9 years',
|
|
||||||
'10 years',
|
|
||||||
]
|
|
||||||
|
|
||||||
expect(described_class.durations).to eq(durations)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::statuses', db: false do
|
|
||||||
it 'returns statuses' do
|
|
||||||
expect(described_class.statuses).to eq(%w[upcoming effective expired])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::upcoming' do
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
|
|
||||||
create(:price, id: 1, effect_time: Time.zone.parse('05.07.2010 00:00'))
|
|
||||||
create(:price, id: 2, effect_time: Time.zone.parse('05.07.2010 00:01'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns upcoming' do
|
|
||||||
expect(described_class.upcoming.ids).to eq([2])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::effective' do
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
|
|
||||||
create(:price, id: 1, effect_time: '05.07.2010 00:01', expire_time: '05.07.2010 00:02')
|
|
||||||
create(:price, id: 2, effect_time: '05.07.2010 00:00', expire_time: '05.07.2010 00:01')
|
|
||||||
create(:price, id: 3, effect_time: '05.07.2010 00:00', expire_time: nil)
|
|
||||||
create(:price, id: 4, effect_time: '04.07.2010', expire_time: '04.07.2010 23:59')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns effective' do
|
|
||||||
expect(described_class.effective.ids).to eq([2, 3])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'zone validation', db: false do
|
|
||||||
subject(:price) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
price.zone = nil
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:zone)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'price validation', db: false do
|
|
||||||
subject(:price) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
price.price = nil
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:price)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects negative' do
|
|
||||||
price.price = -1
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:price)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts zero' do
|
|
||||||
price.price = 0
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to_not have_key(:price)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts greater than zero' do
|
|
||||||
price.price = 1
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to_not have_key(:price)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts fraction' do
|
|
||||||
price.price = "1#{I18n.t('number.currency.format.separator')}5"
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to_not have_key(:price)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'duration validation', db: false do
|
|
||||||
subject(:price) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
price.duration = nil
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:duration)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
price.duration = 'invalid'
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:duration)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
price.duration = described_class.durations.first
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to_not have_key(:duration)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'operation category validation', db: false do
|
|
||||||
subject(:price) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
price.operation_category = nil
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:operation_category)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
price.operation_category = 'invalid'
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to have_key(:operation_category)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
price.operation_category = described_class.operation_categories.first
|
|
||||||
price.validate
|
|
||||||
expect(price.errors).to_not have_key(:operation_category)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#name', db: false do
|
|
||||||
let(:price) { described_class.new }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
allow(price).to receive(:operation_category).and_return('category')
|
|
||||||
allow(price).to receive(:zone_name).and_return('zone')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns operation_category and zone name' do
|
|
||||||
expect(price.name).to eq('category zone')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#zone_name', db: false do
|
|
||||||
let(:price) { described_class.new(zone: zone) }
|
|
||||||
let(:zone) { build_stubbed(:zone, origin: 'test') }
|
|
||||||
|
|
||||||
it 'returns zone name' do
|
|
||||||
expect(price.zone_name).to eq('test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,55 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Billing::Price do
|
|
||||||
describe '::expired' do
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
|
|
||||||
create(:price, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
|
|
||||||
create(:price, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))
|
|
||||||
create(:price, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns prices with expire time in the past ' do
|
|
||||||
expect(described_class.expired.ids).to eq([1])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#expire', db: false do
|
|
||||||
let(:price) { described_class.new(expire_time: Time.zone.parse('06.07.2010')) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'expires price' do
|
|
||||||
expect { price.expire }.to change { price.expired? }.from(false).to(true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#expired?', db: false do
|
|
||||||
subject(:expired) { domain.expired? }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when expire time is in the past' do
|
|
||||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('04.07.2010 23:59')) }
|
|
||||||
|
|
||||||
specify { expect(expired).to be true }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when expire time is now' do
|
|
||||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:00')) }
|
|
||||||
|
|
||||||
specify { expect(expired).to be false }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when expire time is in the future' do
|
|
||||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:01')) }
|
|
||||||
|
|
||||||
specify { expect(expired).to be false }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,68 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Domain, db: false do
|
|
||||||
describe '#active?' do
|
|
||||||
context 'when :statuses does not contain :inactive' do
|
|
||||||
let(:domain) { described_class.new(statuses: []) }
|
|
||||||
|
|
||||||
it 'returns true' do
|
|
||||||
expect(domain.active?).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when :statuses contains :inactive' do
|
|
||||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
|
||||||
|
|
||||||
it 'returns false' do
|
|
||||||
expect(domain.active?).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#inactive?' do
|
|
||||||
context 'when :statuses contains :inactive' do
|
|
||||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
|
||||||
|
|
||||||
it 'returns true' do
|
|
||||||
expect(domain.inactive?).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when :statuses does not contain :inactive' do
|
|
||||||
let(:domain) { described_class.new(statuses: []) }
|
|
||||||
|
|
||||||
it 'returns false' do
|
|
||||||
expect(domain.inactive?).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#activate' do
|
|
||||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
|
||||||
|
|
||||||
it 'activates domain' do
|
|
||||||
domain.activate
|
|
||||||
expect(domain).to be_active
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#deactivate' do
|
|
||||||
context 'when active' do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
it 'deactivates domain' do
|
|
||||||
domain.deactivate
|
|
||||||
expect(domain).to be_inactive
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when inactive' do
|
|
||||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
|
||||||
|
|
||||||
it 'does not add :inactive status' do
|
|
||||||
domain.deactivate
|
|
||||||
expect(domain.statuses).to eq([DomainStatus::INACTIVE])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,65 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Domain, db: false do
|
|
||||||
it { is_expected.to alias_attribute(:expire_time, :valid_to) }
|
|
||||||
|
|
||||||
describe '::expired', db: true do
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
|
|
||||||
create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59'))
|
|
||||||
create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00'))
|
|
||||||
create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns expired domains' do
|
|
||||||
expect(described_class.expired.ids).to eq([1, 2])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#registered?' do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
context 'when not expired' do
|
|
||||||
before :example do
|
|
||||||
expect(domain).to receive(:expired?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify { expect(domain).to be_registered }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when expired' do
|
|
||||||
before :example do
|
|
||||||
expect(domain).to receive(:expired?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify { expect(domain).to_not be_registered }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#expired?' do
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when :expire_time is in the past' do
|
|
||||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('04.07.2010 23:59')) }
|
|
||||||
|
|
||||||
specify { expect(domain).to be_expired }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when :expire_time is now' do
|
|
||||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:00')) }
|
|
||||||
|
|
||||||
specify { expect(domain).to be_expired }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when :expire_time is in the future' do
|
|
||||||
let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:01')) }
|
|
||||||
|
|
||||||
specify { expect(domain).to_not be_expired }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,33 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require 'lib/validators/e164'
|
|
||||||
|
|
||||||
RSpec.describe Contact do
|
|
||||||
let(:contact) { described_class.new }
|
|
||||||
|
|
||||||
describe 'phone', db: false do
|
|
||||||
it_behaves_like 'e164' do
|
|
||||||
let(:model) { contact }
|
|
||||||
let(:attribute) { :phone }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'phone validation', db: false do
|
|
||||||
it 'rejects absent' do
|
|
||||||
contact.phone = nil
|
|
||||||
contact.validate
|
|
||||||
expect(contact.errors).to be_added(:phone, :blank)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects all zeros in country code' do
|
|
||||||
contact.phone = '+000.1'
|
|
||||||
contact.validate
|
|
||||||
expect(contact.errors).to be_added(:phone, :invalid)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects all zeros in subscriber number' do
|
|
||||||
contact.phone = '+123.0'
|
|
||||||
contact.validate
|
|
||||||
expect(contact.errors).to be_added(:phone, :invalid)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,227 +0,0 @@
|
||||||
require 'active_model'
|
|
||||||
require 'lib/validators/iso31661_alpha2'
|
|
||||||
require 'lib/validators/iso8601'
|
|
||||||
|
|
||||||
RSpec.describe Contact::Ident, db: false do
|
|
||||||
let(:ident) { described_class.new }
|
|
||||||
|
|
||||||
describe 'country code' do
|
|
||||||
it_behaves_like 'iso31661_alpha2' do
|
|
||||||
let(:model) { ident }
|
|
||||||
let(:attribute) { :country_code }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'code validation' do
|
|
||||||
it 'rejects absent' do
|
|
||||||
ident.code = nil
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:code, :blank)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when type is :birthday' do
|
|
||||||
let(:ident) { described_class.new(type: 'birthday') }
|
|
||||||
|
|
||||||
it_behaves_like 'iso8601' do
|
|
||||||
let(:model) { ident }
|
|
||||||
let(:attribute) { :code }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when type is not :birthday' do
|
|
||||||
let(:ident) { described_class.new(type: 'priv') }
|
|
||||||
|
|
||||||
it 'accepts any' do
|
|
||||||
ident.code = '%123456789%'
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to_not include(:code)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when country code is EE' do
|
|
||||||
context 'when type is :priv' do
|
|
||||||
let(:ident) { described_class.new(country_code: 'EE', type: 'priv') }
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
ident.code = 'invalid'
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:code, :invalid_national_id, country: 'Estonia')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
ident.code = '47101010033'
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to_not be_added(:code, :invalid_national_id, country: 'Estonia')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when ident type is :org' do
|
|
||||||
let(:ident) { described_class.new(country_code: 'EE', type: 'org') }
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
ident.code = '1' * 7
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:code, :invalid_reg_no, country: 'Estonia')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid length' do
|
|
||||||
ident.code = '1' * 8
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to_not be_added(:code, :invalid_reg_no, country: 'Estonia')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when ident country code is not EE' do
|
|
||||||
let(:ident) { described_class.new(country_code: 'US') }
|
|
||||||
|
|
||||||
it 'accepts any' do
|
|
||||||
ident.code = 'test-123456789'
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to_not include(:code)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'translates :invalid_national_id error message' do
|
|
||||||
expect(ident.errors.generate_message(:code, :invalid_national_id, country: 'Germany'))
|
|
||||||
.to eq('does not conform to national identification number format of Germany')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'translates :invalid_reg_no error message' do
|
|
||||||
expect(ident.errors.generate_message(:code, :invalid_reg_no, country: 'Germany'))
|
|
||||||
.to eq('does not conform to registration number format of Germany')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'type validation' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:types).and_return(%w(valid))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
ident.type = nil
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:type, :blank)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
ident.type = 'invalid'
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:type, :inclusion)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
ident.type = 'valid'
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to_not be_added(:type, :inclusion)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'country code validation' do
|
|
||||||
it 'rejects absent' do
|
|
||||||
ident.country_code = nil
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:country_code, :blank)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'mismatch validation' do
|
|
||||||
let(:ident) { described_class.new(type: 'test', country_code: 'DE') }
|
|
||||||
|
|
||||||
before do
|
|
||||||
mismatches = [Contact::Ident::MismatchValidator::Mismatch.new('test', Country.new('DE'))]
|
|
||||||
allow(Contact::Ident::MismatchValidator).to receive(:mismatches).and_return(mismatches)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects mismatched' do
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to be_added(:base, :mismatch, type: 'test', country: 'Germany')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts matched' do
|
|
||||||
ident.validate
|
|
||||||
expect(ident.errors).to_not be_added(:base, :mismatch, type: 'another-test', country: 'Germany')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'translates :mismatch error message' do
|
|
||||||
expect(ident.errors.generate_message(:base, :mismatch, type: 'test', country: 'Germany'))
|
|
||||||
.to eq('Ident type "test" is invalid for Germany')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::types' do
|
|
||||||
it 'returns types' do
|
|
||||||
types = %w[
|
|
||||||
org
|
|
||||||
priv
|
|
||||||
birthday
|
|
||||||
]
|
|
||||||
|
|
||||||
expect(described_class.types).to eq(types)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#birthday?' do
|
|
||||||
context 'when type is birthday' do
|
|
||||||
subject(:ident) { described_class.new(type: 'birthday') }
|
|
||||||
it { is_expected.to be_birthday }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when type is not birthday' do
|
|
||||||
subject(:ident) { described_class.new(type: 'priv') }
|
|
||||||
it { is_expected.to_not be_birthday }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#national_id?' do
|
|
||||||
context 'when type is priv' do
|
|
||||||
subject(:ident) { described_class.new(type: 'priv') }
|
|
||||||
it { is_expected.to be_national_id }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when type is not' do
|
|
||||||
subject(:ident) { described_class.new(type: 'org') }
|
|
||||||
it { is_expected.to_not be_national_id }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#reg_no?' do
|
|
||||||
context 'when type is birthday' do
|
|
||||||
subject(:ident) { described_class.new(type: 'org') }
|
|
||||||
it { is_expected.to be_reg_no }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when type is not birthday' do
|
|
||||||
subject(:ident) { described_class.new(type: 'priv') }
|
|
||||||
it { is_expected.to_not be_reg_no }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#country' do
|
|
||||||
let(:ident) { described_class.new(country_code: 'US') }
|
|
||||||
|
|
||||||
it 'returns country' do
|
|
||||||
expect(ident.country).to eq(Country.new('US'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#==' do
|
|
||||||
let(:ident) { described_class.new(code: 'test', type: 'test', country_code: 'US') }
|
|
||||||
|
|
||||||
context 'when code, type and country code are the same' do
|
|
||||||
let(:another_ident) { described_class.new(code: 'test', type: 'test', country_code: 'US') }
|
|
||||||
|
|
||||||
it 'returns true' do
|
|
||||||
expect(ident).to eq(another_ident)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when code, type and country code are not the same' do
|
|
||||||
let(:another_ident) { described_class.new(code: 'another-test', type: 'test', country_code: 'US') }
|
|
||||||
|
|
||||||
it 'returns false' do
|
|
||||||
expect(ident).to_not eq(another_ident)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,414 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Contact do
|
|
||||||
before :example do
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :example do
|
|
||||||
@contact = Contact.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have creator' do
|
|
||||||
@contact.creator.should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have updater' do
|
|
||||||
@contact.updator.should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not accept long code' do
|
|
||||||
@contact.code = 'verylongcode' * 100
|
|
||||||
@contact.valid?
|
|
||||||
@contact.errors[:code].should == ['Contact code is too long, max 100 characters']
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not allow double status' do
|
|
||||||
contact = described_class.new(statuses: %w(ok ok))
|
|
||||||
|
|
||||||
contact.validate
|
|
||||||
|
|
||||||
expect(contact.statuses).to eq(%w(ok))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have no related domain descriptions' do
|
|
||||||
@contact.related_domain_descriptions.should == {}
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should fully validate email syntax for new records' do
|
|
||||||
@contact.email = 'not@correct'
|
|
||||||
@contact.valid?
|
|
||||||
@contact.errors[:email].should == ['Email is invalid']
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have ident updated because the logic itself is dedicated for legacy contacts ' do
|
|
||||||
@contact.ident_updated_at.should_not == nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before :example do
|
|
||||||
@contact = create(:contact)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not overwrite code' do
|
|
||||||
old_code = @contact.code
|
|
||||||
@contact.code = 'CID:REG1:should-not-overwrite-old-code-12345'
|
|
||||||
@contact.save.should == true
|
|
||||||
@contact.code.should == old_code
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have ok status by default' do
|
|
||||||
@contact.statuses.should == %w(ok)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not remove ok status after save' do
|
|
||||||
@contact.statuses.should == %w(ok)
|
|
||||||
@contact.save
|
|
||||||
@contact.statuses.should == %w(ok)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should remove ok status when other non linked status present' do
|
|
||||||
contact = create(:contact)
|
|
||||||
contact.statuses = [Contact::SERVER_UPDATE_PROHIBITED]
|
|
||||||
contact.statuses.should == [Contact::SERVER_UPDATE_PROHIBITED] # temp test
|
|
||||||
contact.save
|
|
||||||
contact.statuses.should == [Contact::SERVER_UPDATE_PROHIBITED]
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have code' do
|
|
||||||
registrar = create(:registrar, code: 'registrarcode')
|
|
||||||
|
|
||||||
contact = build(:contact, registrar: registrar, code: 'contactcode')
|
|
||||||
contact.generate_code
|
|
||||||
contact.save!
|
|
||||||
|
|
||||||
expect(contact.code).to eq('REGISTRARCODE:CONTACTCODE')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should save status notes' do
|
|
||||||
contact = create(:contact)
|
|
||||||
contact.statuses = ['serverDeleteProhibited', 'serverUpdateProhibited']
|
|
||||||
contact.status_notes_array = [nil, 'update manually turned off']
|
|
||||||
contact.status_notes['serverDeleteProhibited'].should == nil
|
|
||||||
contact.status_notes['serverUpdateProhibited'].should == 'update manually turned off'
|
|
||||||
contact.status_notes['someotherstatus'].should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have ident already updated because the logic itself is only for legacy contacts' do
|
|
||||||
@contact.ident_updated_at.should_not == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have not update ident updated at when initializing old contact' do
|
|
||||||
# creating a legacy contact
|
|
||||||
contact = create(:contact)
|
|
||||||
contact.update_column(:ident_updated_at, nil)
|
|
||||||
|
|
||||||
Contact.find(contact.id).ident_updated_at.should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'as birthday' do
|
|
||||||
before do
|
|
||||||
@domain = create(:domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have related domain descriptions hash' do
|
|
||||||
contact = @domain.registrant
|
|
||||||
contact.reload # somehow it registrant_domains are empty?
|
|
||||||
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have related domain descriptions hash when find directly' do
|
|
||||||
contact = @domain.registrant
|
|
||||||
Contact.find(contact.id).related_domain_descriptions.should == { "#{@domain.name}" => [:registrant] }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have related domain descriptions hash' do
|
|
||||||
contact = @domain.contacts.first
|
|
||||||
contact.related_domain_descriptions.should == { "#{@domain.name}" => [:admin] }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should fully validate email syntax for old records' do
|
|
||||||
old = @contact.email
|
|
||||||
@contact.email = 'legacy@support-not-correct'
|
|
||||||
@contact.valid?
|
|
||||||
@contact.errors[:email].should == ['Email is invalid']
|
|
||||||
@contact.email = old
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with callbacks' do
|
|
||||||
context 'after create' do
|
|
||||||
it 'should not allow to use same code' do
|
|
||||||
registrar = create(:registrar, code: 'FIXED')
|
|
||||||
|
|
||||||
create(:contact,
|
|
||||||
registrar: registrar,
|
|
||||||
code: 'FIXED:new-code')
|
|
||||||
@contact = build(:contact,
|
|
||||||
registrar: registrar,
|
|
||||||
code: 'FIXED:new-code')
|
|
||||||
|
|
||||||
@contact.validate
|
|
||||||
|
|
||||||
expect(@contact.errors).to have_key(:code)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should allow supported code format' do
|
|
||||||
@contact = build(:contact, code: 'CID:REG1:12345', registrar: create(:registrar, code: 'FIXED'))
|
|
||||||
@contact.valid?
|
|
||||||
@contact.errors.full_messages.should == []
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not allow unsupported characters in code' do
|
|
||||||
@contact = build(:contact, code: 'unsupported!ÄÖÜ~?', registrar: create(:registrar, code: 'FIXED'))
|
|
||||||
@contact.valid?
|
|
||||||
@contact.errors.full_messages.should == ['Code is invalid']
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should generate code if empty code is given' do
|
|
||||||
@contact = build(:contact, code: '')
|
|
||||||
@contact.generate_code
|
|
||||||
@contact.save!
|
|
||||||
@contact.code.should_not == ''
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not ignore empty spaces as code and generate new one' do
|
|
||||||
@contact = build(:contact, code: ' ', registrar: create(:registrar, code: 'FIXED'))
|
|
||||||
@contact.generate_code
|
|
||||||
@contact.valid?.should == true
|
|
||||||
@contact.code.should =~ /FIXED:..../
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe Contact, '.destroy_orphans' do
|
|
||||||
before do
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
@contact_1 = create(:contact, code: 'asd12')
|
|
||||||
@contact_2 = create(:contact, code: 'asd13')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'destroys orphans' do
|
|
||||||
Contact.find_orphans.count.should == 2
|
|
||||||
Contact.destroy_orphans
|
|
||||||
Contact.find_orphans.count.should == 0
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should find one orphan' do
|
|
||||||
create(:domain, registrant: Registrant.find(@contact_1.id))
|
|
||||||
Contact.find_orphans.count.should == 1
|
|
||||||
Contact.find_orphans.last.should == @contact_2
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should find no orphans' do
|
|
||||||
create(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2])
|
|
||||||
cc = Contact.count
|
|
||||||
Contact.find_orphans.count.should == 0
|
|
||||||
Contact.destroy_orphans
|
|
||||||
Contact.count.should == cc
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.describe Contact do
|
|
||||||
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
describe '::address_processing?' do
|
|
||||||
before do
|
|
||||||
Setting.address_processing = 'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns setting value' do
|
|
||||||
expect(described_class.address_processing?).to eq('test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::address_attribute_names', db: false do
|
|
||||||
it 'returns address attributes' do
|
|
||||||
attributes = %w(
|
|
||||||
city
|
|
||||||
street
|
|
||||||
zip
|
|
||||||
country_code
|
|
||||||
state
|
|
||||||
)
|
|
||||||
expect(described_class.address_attribute_names).to eq(attributes)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'registrar validation', db: false do
|
|
||||||
let(:contact) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
contact.registrar = nil
|
|
||||||
contact.validate
|
|
||||||
expect(contact.errors).to have_key(:registrar)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'address validation', db: false do
|
|
||||||
let(:contact) { described_class.new }
|
|
||||||
subject(:errors) { contact.errors }
|
|
||||||
|
|
||||||
required_attributes = %i(street city zip country_code)
|
|
||||||
|
|
||||||
context 'when address processing is enabled' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:address_processing?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
required_attributes.each do |attr_name|
|
|
||||||
it "rejects absent #{attr_name}" do
|
|
||||||
contact.send("#{attr_name}=", nil)
|
|
||||||
contact.validate
|
|
||||||
expect(errors).to have_key(attr_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when address processing is disabled' do
|
|
||||||
before do
|
|
||||||
allow(described_class).to receive(:address_processing?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
required_attributes.each do |attr_name|
|
|
||||||
it "accepts absent #{attr_name}" do
|
|
||||||
contact.send("#{attr_name}=", nil)
|
|
||||||
contact.validate
|
|
||||||
expect(errors).to_not have_key(attr_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'country code validation', db: false do
|
|
||||||
let(:contact) { described_class.new(country_code: 'test') }
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
contact.country_code = 'invalid'
|
|
||||||
contact.validate
|
|
||||||
expect(contact.errors).to have_key(:country_code)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'identifier validation', db: false do
|
|
||||||
let(:contact) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects invalid' do
|
|
||||||
ident = Contact::Ident.new
|
|
||||||
ident.validate
|
|
||||||
contact.identifier = ident
|
|
||||||
contact.validate
|
|
||||||
|
|
||||||
expect(contact.errors).to be_added(:identifier, :invalid)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts valid' do
|
|
||||||
ident = Contact::Ident.new(code: 'test', type: 'priv', country_code: 'US')
|
|
||||||
ident.validate
|
|
||||||
contact.identifier = ident
|
|
||||||
contact.validate
|
|
||||||
|
|
||||||
expect(contact.errors).to_not be_added(:identifier, :invalid)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#remove_address' do
|
|
||||||
let(:contact) { described_class.new(city: 'test',
|
|
||||||
street: 'test',
|
|
||||||
zip: 'test',
|
|
||||||
country_code: 'test',
|
|
||||||
state: 'test')
|
|
||||||
}
|
|
||||||
subject(:address_removed) { contact.attributes.slice(*described_class.address_attribute_names).compact.empty? }
|
|
||||||
|
|
||||||
it 'removes address attributes' do
|
|
||||||
contact.remove_address
|
|
||||||
expect(address_removed).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#reg_no' do
|
|
||||||
subject(:reg_no) { contact.reg_no }
|
|
||||||
|
|
||||||
context 'when contact is legal entity' do
|
|
||||||
let(:contact) { build_stubbed(:contact_legal_entity, ident: '1234') }
|
|
||||||
|
|
||||||
specify { expect(reg_no).to eq('1234') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when contact is private entity' do
|
|
||||||
let(:contact) { build_stubbed(:contact_private_entity, ident: '1234') }
|
|
||||||
|
|
||||||
specify { expect(reg_no).to be_nil }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#id_code' do
|
|
||||||
context 'when contact is private entity' do
|
|
||||||
let(:contact) { build_stubbed(:contact_private_entity, ident: '1234') }
|
|
||||||
|
|
||||||
specify { expect(contact.id_code).to eq('1234') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when contact is legal entity' do
|
|
||||||
let(:contact) { build_stubbed(:contact_legal_entity, ident: '1234') }
|
|
||||||
|
|
||||||
specify { expect(contact.id_code).to be_nil }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#ident_country' do
|
|
||||||
let(:contact) { described_class.new(ident_country_code: 'US') }
|
|
||||||
|
|
||||||
it 'returns ident country' do
|
|
||||||
expect(contact.ident_country).to eq(Country.new('US'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#domain_names_with_roles' do
|
|
||||||
let(:contact) { create(:registrant) }
|
|
||||||
subject(:domain_names) { contact.domain_names_with_roles }
|
|
||||||
|
|
||||||
it 'returns associated domains with roles' do
|
|
||||||
domain = create(:domain, registrant: contact, name: 'test.com')
|
|
||||||
domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact)
|
|
||||||
domain.tech_domain_contacts << create(:tech_domain_contact, contact: contact)
|
|
||||||
|
|
||||||
contact.reload
|
|
||||||
|
|
||||||
expect(domain_names).to eq({ 'test.com' => %i[registrant admin_domain_contact tech_domain_contact].to_set })
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns unique roles' do
|
|
||||||
domain = create(:domain, name: 'test.com')
|
|
||||||
2.times { domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact) }
|
|
||||||
|
|
||||||
contact.reload
|
|
||||||
|
|
||||||
expect(domain_names).to eq({ 'test.com' => %i[admin_domain_contact].to_set })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'normalizes ident country code', db: false do
|
|
||||||
contact = described_class.new
|
|
||||||
|
|
||||||
contact.ident_country_code = 'ee'
|
|
||||||
contact.validate
|
|
||||||
|
|
||||||
expect(contact.ident_country_code).to eq('EE')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Depp::Domain do
|
|
||||||
describe '::default_period', db: false, settings: false do
|
|
||||||
it 'returns default period' do
|
|
||||||
expect(described_class.default_period).to eq('1y')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,102 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DNS::Zone do
|
|
||||||
describe '::origins' do
|
|
||||||
before :example do
|
|
||||||
expect(described_class).to receive(:pluck).with(:origin).and_return('origins')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns origins' do
|
|
||||||
expect(described_class.origins).to eq('origins')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'validation' do
|
|
||||||
let(:zone) { described_class.new }
|
|
||||||
|
|
||||||
required_attributes = %i[
|
|
||||||
origin
|
|
||||||
ttl
|
|
||||||
refresh
|
|
||||||
retry
|
|
||||||
expire
|
|
||||||
minimum_ttl
|
|
||||||
email
|
|
||||||
master_nameserver
|
|
||||||
]
|
|
||||||
|
|
||||||
required_attributes.each do |attr_name|
|
|
||||||
it "rejects absent #{attr_name}", db: false do
|
|
||||||
zone.send("#{attr_name}=", nil)
|
|
||||||
zone.validate
|
|
||||||
expect(zone.errors).to have_key(attr_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
integer_attributes = %i[
|
|
||||||
ttl
|
|
||||||
refresh
|
|
||||||
retry
|
|
||||||
expire
|
|
||||||
minimum_ttl
|
|
||||||
]
|
|
||||||
|
|
||||||
integer_attributes.each do |attr_name|
|
|
||||||
it "rejects non-integer #{attr_name}", db: false do
|
|
||||||
zone.send("#{attr_name}=", 'test')
|
|
||||||
zone.validate
|
|
||||||
expect(zone.errors).to have_key(attr_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "accepts integer #{attr_name}", db: false do
|
|
||||||
zone.send("#{attr_name}=", '1')
|
|
||||||
zone.validate
|
|
||||||
expect(zone.errors).to_not have_key(attr_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#used?', db: false do
|
|
||||||
let!(:zone) { described_class.new }
|
|
||||||
|
|
||||||
context 'when domain uses zone' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:uses_zone?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify { expect(zone).to be_used }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when domain does not use zone' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:uses_zone?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify { expect(zone).to_not be_used }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'deletion', settings: false do
|
|
||||||
let!(:zone) { create(:zone) }
|
|
||||||
|
|
||||||
context 'when zone is unused' do
|
|
||||||
before :example do
|
|
||||||
allow(zone).to receive(:used?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is allowed' do
|
|
||||||
expect { zone.destroy }.to change { described_class.count }.from(1).to(0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when zone is used' do
|
|
||||||
before :example do
|
|
||||||
allow(zone).to receive(:used?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is disallowed' do
|
|
||||||
expect { zone.destroy }.to_not change { described_class.count }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,102 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe Dnskey 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
|
|
||||||
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :example do
|
|
||||||
@dnskey = Dnskey.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid' do
|
|
||||||
@dnskey.valid?
|
|
||||||
@dnskey.errors.full_messages.should match_array([
|
|
||||||
])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before :example do
|
|
||||||
@dnskey = create(:dnskey,
|
|
||||||
alg: 8,
|
|
||||||
flags: 257,
|
|
||||||
protocol: 3,
|
|
||||||
public_key: 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\
|
|
||||||
'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\
|
|
||||||
'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\
|
|
||||||
'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\
|
|
||||||
'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\
|
|
||||||
'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=',
|
|
||||||
ds_digest_type: 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@dnskey.valid?
|
|
||||||
@dnskey.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@dnskey = create(:dnskey)
|
|
||||||
@dnskey.valid?
|
|
||||||
@dnskey.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'generates correct DS digest and DS key tag for ria.ee' do
|
|
||||||
d = create(:domain, name: 'ria.ee', dnskeys: [@dnskey])
|
|
||||||
dk = d.dnskeys.last
|
|
||||||
|
|
||||||
dk.generate_digest
|
|
||||||
dk.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92'
|
|
||||||
dk.ds_key_tag.should == '30607'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'generates correct DS digest and DS key tag for emta.ee' do
|
|
||||||
d = create(:domain, name: 'emta.ee', dnskeys: [@dnskey])
|
|
||||||
|
|
||||||
dk = d.dnskeys.last
|
|
||||||
|
|
||||||
pk = 'AwEAAfB9jK8rj/FAdE3t9bYXiTLpelwlgUyxbHEtvMvhdxs+yHv0h9fE '\
|
|
||||||
'710u94LPAeVmXumT6SZPsoo+ALKdmTexkcU9DGQvb2+sPfModBKM/num '\
|
|
||||||
'rScUw1FBe3HwRa9SqQpgpnCjIt0kEVKHAQdLOP86YznSA9uHAg9TTJuT '\
|
|
||||||
'LkUtgtmwNAVFr6/mG+smE1v5NbxPccsFwVTA/T1IyaI4Z48VGCP2WNro '\
|
|
||||||
'R7P6vet1gWhssirnnVYnur8DwWuMJ89o/HjzXeiEGUB8k5SOX+//67FN '\
|
|
||||||
'm8Zs+1ObuAfY8xAHe0L5bxluEbh1T1ARp41QX77EMKVbkcSj7nuBeY8H '\
|
|
||||||
'KiN8HsTvmZyDbRAQQaAJi68qOXsUIoQcpn89PoNoc60F7WlueA6ExSGX '\
|
|
||||||
'KMWIH6nfLXFgidoZ6HxteyUUnZbHEdULjpAoCRuUDjjUnUgFS7eRANfw '\
|
|
||||||
'RCcu9aLziMDp4UU61zVjtmQ7xn3G2W2+2ycqn/vEl/yFyBmHZ+7stpoC '\
|
|
||||||
'd6NTZUn4/ellYSm9lx/vaXdPSinARpYMWtU79Hu/VRifaCQjYkBGAMwK '\
|
|
||||||
'DshX4yJPjza/bqo0XV4WHj1szDFHe0tLN7g1Ojwtf5FR0zyHU3FN9uUa '\
|
|
||||||
'y8a+dowd/fqOQA1jXR04g2PIfFYe0VudCEpmxSV9YDoqjghHeIKUX7Jn '\
|
|
||||||
'KiHL5gk404S5a/Bv'
|
|
||||||
|
|
||||||
dk.public_key = pk
|
|
||||||
|
|
||||||
dk.save
|
|
||||||
dk.ds_digest.should == 'D7045D3C2EF7332409A132D935C8E2834A2AAB769B35BC370FA68C9445398288'
|
|
||||||
dk.ds_key_tag.should == '31051'
|
|
||||||
|
|
||||||
dk.public_key.should == pk
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,95 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe DomainContact do
|
|
||||||
before :example do
|
|
||||||
@api_user = create(:domain_contact)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :example do
|
|
||||||
@domain_contact = DomainContact.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid' do
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([
|
|
||||||
"Contact Contact was not found"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have creator' do
|
|
||||||
@domain_contact.creator.should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have updater' do
|
|
||||||
@domain_contact.updator.should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have any name' do
|
|
||||||
@domain_contact.name.should == ''
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before :example do
|
|
||||||
@domain_contact = create(:domain_contact, type: 'TechDomainContact')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@domain_contact = create(:domain_contact)
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have Tech name' do
|
|
||||||
@domain_contact.name.should == 'Tech'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes with tech domain contact' do
|
|
||||||
before :example do
|
|
||||||
@domain_contact = create(:tech_domain_contact)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@domain_contact = create(:tech_domain_contact)
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have Tech name' do
|
|
||||||
@domain_contact.name.should == 'Tech'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes with admin domain contact' do
|
|
||||||
before :example do
|
|
||||||
@domain_contact = create(:admin_domain_contact)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@domain_contact = create(:admin_domain_contact)
|
|
||||||
@domain_contact.valid?
|
|
||||||
@domain_contact.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have Tech name' do
|
|
||||||
@domain_contact.name.should == 'Admin'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,41 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DomainCron do
|
|
||||||
it 'should expire domains' do
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
@domain = create(:domain)
|
|
||||||
|
|
||||||
Setting.expire_warning_period = 1
|
|
||||||
Setting.redemption_grace_period = 1
|
|
||||||
|
|
||||||
described_class.start_expire_period
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == false
|
|
||||||
|
|
||||||
old_valid_to = Time.zone.now - 10.days
|
|
||||||
@domain.valid_to = old_valid_to
|
|
||||||
@domain.save
|
|
||||||
|
|
||||||
described_class.start_expire_period
|
|
||||||
@domain.reload
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
|
||||||
|
|
||||||
described_class.start_expire_period
|
|
||||||
@domain.reload
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should start redemption grace period' do
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
@domain = create(:domain)
|
|
||||||
|
|
||||||
old_valid_to = Time.zone.now - 10.days
|
|
||||||
@domain.valid_to = old_valid_to
|
|
||||||
@domain.statuses = [DomainStatus::EXPIRED]
|
|
||||||
@domain.outzone_at, @domain.delete_date = nil, nil
|
|
||||||
@domain.save
|
|
||||||
|
|
||||||
described_class.start_expire_period
|
|
||||||
@domain.reload
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,744 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Domain 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
|
|
||||||
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
create(:zone, origin: 'pri.ee')
|
|
||||||
create(:zone, origin: 'med.ee')
|
|
||||||
create(:zone, origin: 'fie.ee')
|
|
||||||
create(:zone, origin: 'com.ee')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :example do
|
|
||||||
@domain = Domain.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have whois body' do
|
|
||||||
@domain.whois_record.should == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be registrant update confirm ready' do
|
|
||||||
@domain.registrant_update_confirmable?('123').should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have pending update' do
|
|
||||||
@domain.pending_update?.should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should allow pending update' do
|
|
||||||
@domain.pending_update_prohibited?.should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have pending delete' do
|
|
||||||
@domain.pending_delete?.should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should allow pending delete' do
|
|
||||||
@domain.pending_delete_prohibited?.should == false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before :example do
|
|
||||||
@domain = create(:domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@domain.valid?
|
|
||||||
@domain.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@domain = create(:domain)
|
|
||||||
@domain.valid?
|
|
||||||
@domain.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should validate uniqueness of tech contacts' do
|
|
||||||
same_contact = create(:contact, code: 'same_contact')
|
|
||||||
domain = create(:domain)
|
|
||||||
domain.tech_contacts << same_contact
|
|
||||||
domain.tech_contacts << same_contact
|
|
||||||
domain.valid?
|
|
||||||
domain.errors.full_messages.should match_array(["Tech domain contacts is invalid"])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should validate uniqueness of tech contacts' do
|
|
||||||
same_contact = create(:contact, code: 'same_contact')
|
|
||||||
domain = create(:domain)
|
|
||||||
domain.admin_contacts << same_contact
|
|
||||||
domain.admin_contacts << same_contact
|
|
||||||
domain.valid?
|
|
||||||
domain.errors.full_messages.should match_array(["Admin domain contacts is invalid"])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have whois body by default' do
|
|
||||||
@domain.whois_record.present?.should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have whois json by default' do
|
|
||||||
@domain.whois_record.json.present?.should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be registrant update confirm ready' do
|
|
||||||
@domain.registrant_update_confirmable?('123').should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should expire domains' do
|
|
||||||
Setting.expire_warning_period = 1
|
|
||||||
Setting.redemption_grace_period = 1
|
|
||||||
|
|
||||||
DomainCron.start_expire_period
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == false
|
|
||||||
|
|
||||||
old_valid_to = Time.zone.now - 10.days
|
|
||||||
@domain.valid_to = old_valid_to
|
|
||||||
@domain.save
|
|
||||||
|
|
||||||
DomainCron.start_expire_period
|
|
||||||
@domain.reload
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
|
||||||
|
|
||||||
DomainCron.start_expire_period
|
|
||||||
@domain.reload
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should start redemption grace period' do
|
|
||||||
old_valid_to = Time.zone.now - 10.days
|
|
||||||
@domain.valid_to = old_valid_to
|
|
||||||
@domain.statuses = [DomainStatus::EXPIRED]
|
|
||||||
@domain.outzone_at, @domain.delete_date = nil, nil
|
|
||||||
@domain.save
|
|
||||||
|
|
||||||
DomainCron.start_expire_period
|
|
||||||
@domain.reload
|
|
||||||
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with time period settings' do
|
|
||||||
before :example do
|
|
||||||
@save_days_to_renew = Setting.days_to_renew_domain_before_expire
|
|
||||||
@save_warning_period = Setting.expire_warning_period
|
|
||||||
@save_grace_period = Setting.redemption_grace_period
|
|
||||||
end
|
|
||||||
|
|
||||||
after :all do
|
|
||||||
Setting.days_to_renew_domain_before_expire = @save_days_to_renew
|
|
||||||
Setting.expire_warning_period = @save_warning_period
|
|
||||||
Setting.redemption_grace_period = @save_grace_period
|
|
||||||
end
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
@domain.valid?
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with no renewal limit, renew anytime' do
|
|
||||||
before do
|
|
||||||
Setting.days_to_renew_domain_before_expire = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should always renew with no policy' do
|
|
||||||
@domain.renewable?.should be true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not allow to renew after force delete' do
|
|
||||||
Setting.redemption_grace_period = 1
|
|
||||||
@domain.schedule_force_delete
|
|
||||||
@domain.renewable?.should be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with renew policy' do
|
|
||||||
before :example do
|
|
||||||
@policy = 30
|
|
||||||
Setting.days_to_renew_domain_before_expire = @policy
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not allow renew before policy' do
|
|
||||||
@domain.valid_to = Time.zone.now.beginning_of_day + @policy.days * 2
|
|
||||||
@domain.renewable?.should be false
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'ready to renew' do
|
|
||||||
before { @domain.valid_to = Time.zone.now + (@policy - 2).days }
|
|
||||||
|
|
||||||
it 'should allow renew' do
|
|
||||||
@domain.renewable?.should be true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not allow to renew after force delete' do
|
|
||||||
Setting.redemption_grace_period = 1
|
|
||||||
@domain.schedule_force_delete
|
|
||||||
@domain.renewable?.should be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should set pending update' do
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
@domain.save
|
|
||||||
@domain.pending_update?.should == false
|
|
||||||
|
|
||||||
@domain.set_pending_update
|
|
||||||
@domain.pending_update?.should == true
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not set pending update' do
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
@domain.statuses << DomainStatus::CLIENT_UPDATE_PROHIBITED
|
|
||||||
@domain.save
|
|
||||||
|
|
||||||
@domain.set_pending_update.should == nil # not updated
|
|
||||||
@domain.pending_update?.should == false
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should set pending delete' do
|
|
||||||
@domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
@domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
@domain.save
|
|
||||||
@domain.pending_delete?.should == false
|
|
||||||
|
|
||||||
@domain.set_pending_delete
|
|
||||||
@domain.save
|
|
||||||
@domain.statuses.should == ['pendingDelete', 'serverHold']
|
|
||||||
@domain.pending_delete?.should == true
|
|
||||||
@domain.statuses = ['serverManualInzone']
|
|
||||||
@domain.save
|
|
||||||
@domain.set_pending_delete
|
|
||||||
@domain.statuses.sort.should == ['pendingDelete', 'serverManualInzone'].sort
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not set pending delele' do
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
@domain.pending_delete?.should == false
|
|
||||||
@domain.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
|
|
||||||
@domain.save
|
|
||||||
|
|
||||||
@domain.set_pending_delete.should == nil
|
|
||||||
|
|
||||||
@domain.pending_delete?.should == false
|
|
||||||
@domain.statuses = DomainStatus::OK # restore
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should notify registrar' do
|
|
||||||
text = 'Registrant confirmed domain update: testpollmessage123.ee'
|
|
||||||
domain = create(:domain, name: 'testpollmessage123.ee')
|
|
||||||
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
|
|
||||||
domain.registrar.notifications.first.text.should == text
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'about registrant update confirm' do
|
|
||||||
before :example do
|
|
||||||
@domain.registrant_verification_token = 123
|
|
||||||
@domain.registrant_verification_asked_at = Time.zone.now
|
|
||||||
@domain.statuses << DomainStatus::PENDING_UPDATE
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be registrant update confirm ready' do
|
|
||||||
@domain.registrant_update_confirmable?('123').should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be registrant update confirm ready when token does not match' do
|
|
||||||
@domain.registrant_update_confirmable?('wrong-token').should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be registrant update confirm ready when no correct status' do
|
|
||||||
@domain.statuses = []
|
|
||||||
@domain.registrant_update_confirmable?('123').should == false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'about registrant update confirm when domain is invalid' do
|
|
||||||
before :example do
|
|
||||||
@domain.registrant_verification_token = 123
|
|
||||||
@domain.registrant_verification_asked_at = Time.zone.now
|
|
||||||
@domain.statuses << DomainStatus::PENDING_UPDATE
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be registrant update confirm ready' do
|
|
||||||
@domain.registrant_update_confirmable?('123').should == true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be registrant update confirm ready when token does not match' do
|
|
||||||
@domain.registrant_update_confirmable?('wrong-token').should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be registrant update confirm ready when no correct status' do
|
|
||||||
@domain.statuses = []
|
|
||||||
@domain.registrant_update_confirmable?('123').should == false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'validates domain name' do
|
|
||||||
d = create(:domain)
|
|
||||||
expect(d.name).to_not be_nil
|
|
||||||
|
|
||||||
invalid = [
|
|
||||||
'a.ee', "#{'a' * 64}.ee", 'ab.eu', 'test.ab.ee', '-test.ee', '-test-.ee',
|
|
||||||
'test-.ee', 'te--st.ee', 'õ.pri.ee', 'www.ab.ee', 'test.eu', ' .ee', 'a b.ee',
|
|
||||||
'Ž .ee', 'test.edu.ee'
|
|
||||||
]
|
|
||||||
|
|
||||||
invalid.each do |x|
|
|
||||||
expect(build(:domain, name: x).valid?).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
valid = [
|
|
||||||
'ab.ee', "#{'a' * 63}.ee", 'te-s-t.ee', 'jäääär.ee', 'päike.pri.ee',
|
|
||||||
'õigus.com.ee', 'õäöü.fie.ee', 'test.med.ee', 'žä.ee', ' ŽŠ.ee '
|
|
||||||
]
|
|
||||||
|
|
||||||
valid.each do |x|
|
|
||||||
expect(build(:domain, name: x).valid?).to be true
|
|
||||||
end
|
|
||||||
|
|
||||||
invalid_punycode = ['xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-4we.pri.ee']
|
|
||||||
|
|
||||||
invalid_punycode.each do |x|
|
|
||||||
expect(build(:domain, name: x).valid?).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
valid_punycode = ['xn--ge-uia.pri.ee', 'xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-9te.pri.ee']
|
|
||||||
|
|
||||||
valid_punycode.each do |x|
|
|
||||||
expect(build(:domain, name: x).valid?).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not create zone origin domain' do
|
|
||||||
d = build(:domain, name: 'ee')
|
|
||||||
d.save.should == false
|
|
||||||
expect(d.errors.full_messages).to include('Data management policy violation: Domain name is blocked [name]')
|
|
||||||
|
|
||||||
d = build(:domain, name: 'bla')
|
|
||||||
d.save.should == false
|
|
||||||
expect(d.errors.full_messages).to include('Domain name Domain name is invalid')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'downcases domain' do
|
|
||||||
d = Domain.new(name: 'TesT.Ee')
|
|
||||||
expect(d.name).to eq('test.ee')
|
|
||||||
expect(d.name_puny).to eq('test.ee')
|
|
||||||
expect(d.name_dirty).to eq('test.ee')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid when name length is exatly 63 in characters' do
|
|
||||||
d = create(:domain, name: "#{'a' * 63}.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == []
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 characters' do
|
|
||||||
d = build(:domain, name: "#{'a' * 64}.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should match_array([
|
|
||||||
"Domain name Domain name is invalid",
|
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 characters' do
|
|
||||||
d = build(:domain,
|
|
||||||
name: "xn--4caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should match_array([
|
|
||||||
"Domain name Domain name is invalid",
|
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid when name length is 63 characters' do
|
|
||||||
d = build(:domain,
|
|
||||||
name: "õäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžab123.pri.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should match_array([
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 punycode characters' do
|
|
||||||
d = build(:domain, name: "#{'ä' * 63}.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == [
|
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 punycode characters' do
|
|
||||||
d = build(:domain, name: "#{'ä' * 64}.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should match_array([
|
|
||||||
"Domain name Domain name is invalid",
|
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid when name length is longer than 63 punycode characters' do
|
|
||||||
d = build(:domain, name: "#{'ä' * 63}.pri.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should match_array([
|
|
||||||
"Puny label Domain name is too long (maximum is 63 characters)"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid when punycode name length is not longer than 63' do
|
|
||||||
d = build(:domain, name: "#{'ä' * 53}.pri.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == []
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid when punycode name length is not longer than 63' do
|
|
||||||
d = build(:domain, name: "#{'ä' * 57}.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == []
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid when name length is one pynicode' do
|
|
||||||
d = build(:domain, name: "xn--4ca.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid with at character' do
|
|
||||||
d = build(:domain, name: 'dass@sf.ee')
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid with invalid characters' do
|
|
||||||
d = build(:domain, name: '@ba)s(?ä_:-df.ee')
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == ["Domain name Domain name is invalid"]
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid when name length is two pynicodes' do
|
|
||||||
d = build(:domain, name: "xn--4caa.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == []
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid when name length is two pynicodes' do
|
|
||||||
d = build(:domain, name: "xn--4ca0b.ee")
|
|
||||||
d.valid?
|
|
||||||
d.errors.full_messages.should == []
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create a reserved domain' do
|
|
||||||
create(:reserved_domain, name: 'test.ee')
|
|
||||||
|
|
||||||
domain = build(:domain, name: 'test.ee')
|
|
||||||
domain.validate
|
|
||||||
|
|
||||||
expect(domain.errors[:base]).to include('Required parameter missing; reserved>pw element required for reserved domains')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'manages statuses automatically' do
|
|
||||||
d = build(:domain)
|
|
||||||
|
|
||||||
d.nameservers.build(attributes_for(:nameserver))
|
|
||||||
d.nameservers.build(attributes_for(:nameserver))
|
|
||||||
|
|
||||||
d.save!
|
|
||||||
|
|
||||||
expect(d.statuses.count).to eq(1)
|
|
||||||
expect(d.statuses.first).to eq(DomainStatus::OK)
|
|
||||||
|
|
||||||
d.period = 2
|
|
||||||
d.save
|
|
||||||
|
|
||||||
d.reload
|
|
||||||
expect(d.statuses.count).to eq(1)
|
|
||||||
expect(d.statuses.first).to eq(DomainStatus::OK)
|
|
||||||
|
|
||||||
d.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
|
|
||||||
d.save
|
|
||||||
|
|
||||||
d.reload
|
|
||||||
|
|
||||||
expect(d.statuses.count).to eq(1)
|
|
||||||
expect(d.statuses.first).to eq(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec.describe Domain do
|
|
||||||
it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) }
|
|
||||||
it { is_expected.to alias_attribute(:outzone_time, :outzone_at) }
|
|
||||||
|
|
||||||
describe 'registrar validation', db: false do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
domain.registrar = nil
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:registrar)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'registrant validation', db: false do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
domain.registrant = nil
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:registrant)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'period validation', db: false do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
domain.period = nil
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:period)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects fractional' do
|
|
||||||
domain.period = 1.1
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:period)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts integer' do
|
|
||||||
domain.period = 1
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to_not have_key(:period)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'admin contact count validation' do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
Setting.admin_contacts_min_count = 1
|
|
||||||
Setting.admin_contacts_max_count = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects less than min' do
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:admin_domain_contacts)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects more than max' do
|
|
||||||
(Setting.admin_contacts_max_count + 1).times { domain.admin_domain_contacts << build(:admin_domain_contact) }
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:admin_domain_contacts)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts min' do
|
|
||||||
Setting.admin_contacts_min_count.times { domain.admin_domain_contacts << build(:admin_domain_contact) }
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to_not have_key(:admin_domain_contacts)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts max' do
|
|
||||||
Setting.admin_contacts_max_count.times { domain.admin_domain_contacts << build(:admin_domain_contact) }
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to_not have_key(:admin_domain_contacts)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'nameserver validation', db: true do
|
|
||||||
let(:domain) { described_class.new(name: 'whatever.test') }
|
|
||||||
|
|
||||||
it 'rejects less than min' do
|
|
||||||
Setting.ns_min_count = 2
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects more than max' do
|
|
||||||
Setting.ns_min_count = 1
|
|
||||||
Setting.ns_max_count = 1
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts min' do
|
|
||||||
Setting.ns_min_count = 1
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to_not have_key(:nameservers)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts max' do
|
|
||||||
Setting.ns_min_count = 1
|
|
||||||
Setting.ns_max_count = 2
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to_not have_key(:nameservers)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is optional' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects less than min' do
|
|
||||||
Setting.ns_min_count = 2
|
|
||||||
domain.nameservers.build(attributes_for(:nameserver))
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts absent' do
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to_not have_key(:nameservers)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is required' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'rejects absent' do
|
|
||||||
domain.validate
|
|
||||||
expect(domain.errors).to have_key(:nameservers)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::nameserver_required?' do
|
|
||||||
before do
|
|
||||||
Setting.nameserver_required = 'test'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns setting value' do
|
|
||||||
expect(described_class.nameserver_required?).to eq('test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::expire_warning_period', db: true do
|
|
||||||
before :example do
|
|
||||||
Setting.expire_warning_period = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns expire warning period' do
|
|
||||||
expect(described_class.expire_warning_period).to eq(1.day)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::redemption_grace_period', db: true do
|
|
||||||
before :example do
|
|
||||||
Setting.redemption_grace_period = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns redemption grace period' do
|
|
||||||
expect(described_class.redemption_grace_period).to eq(1.day)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#set_server_hold' do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
|
||||||
domain.set_server_hold
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets corresponding status' do
|
|
||||||
expect(domain.statuses).to include(DomainStatus::SERVER_HOLD)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets :outzone_at to now' do
|
|
||||||
expect(domain.outzone_at).to eq(Time.zone.parse('05.07.2010'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#set_graceful_expired' do
|
|
||||||
let(:domain) { described_class.new }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
expect(described_class).to receive(:expire_warning_period).and_return(1.day)
|
|
||||||
expect(described_class).to receive(:redemption_grace_period).and_return(2.days)
|
|
||||||
expect(domain).to receive(:valid_to).and_return(Time.zone.parse('05.07.2010 10:30'))
|
|
||||||
|
|
||||||
domain.set_graceful_expired
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets :outzone_at to :valid_to + expire warning period' do
|
|
||||||
expect(domain.outzone_at).to eq(Time.zone.parse('06.07.2010 10:30'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets :delete_date to :outzone_at + redemption grace period' do
|
|
||||||
expect(domain.delete_date).to eq(Date.parse('08.07.2010'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::outzone_candidates', db: true do
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 00:00')
|
|
||||||
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
|
|
||||||
create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59'))
|
|
||||||
create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00'))
|
|
||||||
create(:domain, id: 3, outzone_time: Time.zone.parse('05.07.2010 00:01'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns domains with outzone time in the past' do
|
|
||||||
expect(described_class.outzone_candidates.ids).to eq([1])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::uses_zone?', db: true do
|
|
||||||
let!(:zone) { create(:zone, origin: 'domain.tld') }
|
|
||||||
|
|
||||||
context 'when zone is used' do
|
|
||||||
let!(:domain) { create(:domain, name: 'test.domain.tld') }
|
|
||||||
specify { expect(described_class.uses_zone?(zone)).to be true }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when zone is unused' do
|
|
||||||
specify { expect(described_class.uses_zone?(zone)).to be false }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#new_registrant_email' do
|
|
||||||
let(:domain) { described_class.new(pending_json: { new_registrant_email: 'test@test.com' }) }
|
|
||||||
|
|
||||||
it 'returns new registrant\'s email' do
|
|
||||||
expect(domain.new_registrant_email).to eq('test@test.com')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#new_registrant_id' do
|
|
||||||
let(:domain) { described_class.new(pending_json: { new_registrant_id: 1 }) }
|
|
||||||
|
|
||||||
it 'returns new registrant\'s id' do
|
|
||||||
expect(domain.new_registrant_id).to eq(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,29 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Epp::Domain, db: false do
|
|
||||||
describe '::new_from_epp' do
|
|
||||||
let(:domain_blueprint) { described_class.new }
|
|
||||||
subject(:domain) { described_class.new_from_epp(nil, nil) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
|
||||||
|
|
||||||
domain_blueprint.period = 1
|
|
||||||
domain_blueprint.period_unit = 'y'
|
|
||||||
|
|
||||||
expect(described_class).to receive(:new).and_return(domain_blueprint)
|
|
||||||
expect(domain_blueprint).to receive(:attrs_from).and_return({})
|
|
||||||
expect(domain_blueprint).to receive(:attach_default_contacts)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'domain' do
|
|
||||||
it 'has :registered_at set to now' do
|
|
||||||
expect(domain.registered_at).to eq(Time.zone.parse('05.07.2010'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has :valid_to set to the beginning of next day after :registered_at' do
|
|
||||||
expect(domain.valid_to).to eq(Time.zone.parse('06.07.2011 00:00'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,32 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe Epp::Contact, '.check_availability' do
|
|
||||||
before do
|
|
||||||
create(:contact, code: 'asd12')
|
|
||||||
create(:contact, code: 'asd13')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should return array if argument is string' do
|
|
||||||
response = Epp::Contact.check_availability('asd12')
|
|
||||||
response.class.should == Array
|
|
||||||
response.length.should == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should return in_use and available codes' do
|
|
||||||
code = Contact.first.code
|
|
||||||
code_ = Contact.last.code
|
|
||||||
|
|
||||||
response = Epp::Contact.check_availability([code, code_, 'asd14'])
|
|
||||||
response.class.should == Array
|
|
||||||
response.length.should == 3
|
|
||||||
|
|
||||||
response[0][:avail].should == 0
|
|
||||||
response[0][:code].should == code
|
|
||||||
|
|
||||||
response[1][:avail].should == 0
|
|
||||||
response[1][:code].should == code_
|
|
||||||
|
|
||||||
response[2][:avail].should == 1
|
|
||||||
response[2][:code].should == 'asd14'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,77 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe Keyrelay 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
|
|
||||||
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :example do
|
|
||||||
@keyrelay = Keyrelay.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid' do
|
|
||||||
@keyrelay.valid?
|
|
||||||
@keyrelay.errors.full_messages.should match_array([
|
|
||||||
"Auth info pw Password is missing",
|
|
||||||
"Domain is missing",
|
|
||||||
"Key data alg Algorithm is missing",
|
|
||||||
"Key data flags Flag is missing",
|
|
||||||
"Key data protocol Protocol is missing",
|
|
||||||
"Key data public key Public key is missing",
|
|
||||||
"Only one parameter allowed: relative or absolute"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before :example do
|
|
||||||
@keyrelay = create(:keyrelay)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@keyrelay.valid?
|
|
||||||
@keyrelay.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@keyrelay = create(:keyrelay)
|
|
||||||
@keyrelay.valid?
|
|
||||||
@keyrelay.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is in pending status' do
|
|
||||||
@keyrelay.status.should == 'pending'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is in expired status' do
|
|
||||||
kr = create(:keyrelay, pa_date: Time.zone.now - 2.weeks)
|
|
||||||
expect(kr.status).to eq('expired')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not accept invalid relative expiry' do
|
|
||||||
kr = build(:keyrelay, expiry_relative: 'adf')
|
|
||||||
expect(kr.save).to eq(false)
|
|
||||||
expect(kr.errors[:expiry_relative].first).to eq('Expiry relative must be compatible to ISO 8601')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,68 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe LegalDocument do
|
|
||||||
context 'tasks' do
|
|
||||||
it 'make files uniq' do
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
create(:zone, origin: 'pri.ee')
|
|
||||||
create(:zone, origin: 'med.ee')
|
|
||||||
create(:zone, origin: 'fie.ee')
|
|
||||||
create(:zone, origin: 'com.ee')
|
|
||||||
LegalDocument.explicitly_write_file = true
|
|
||||||
PaperTrail.enabled = true
|
|
||||||
|
|
||||||
domain = create(:domain)
|
|
||||||
domain2 = create(:domain)
|
|
||||||
legals = []
|
|
||||||
legals << original = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << copy = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << skipping_as_different_domain = domain2.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << skipping_as_different = domain.legal_documents.create!(body: Base64.encode64('D' * 4.kilobytes))
|
|
||||||
legals << skipping_as_no_checksum = domain.legal_documents.create!(checksum: nil, body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << skipping_as_no_checksum2 = domain.legal_documents.create!(checksum: "", body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << registrant_copy = domain.registrant.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << registrant_skipping_as_different = domain.registrant.legal_documents.create!(body: Base64.encode64('Q' * 4.kilobytes))
|
|
||||||
legals << tech_copy = domain.tech_contacts.first.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << tech_skipping_as_different = domain.tech_contacts.first.legal_documents.create!(body: Base64.encode64('W' * 4.kilobytes))
|
|
||||||
legals << admin_copy = domain.admin_contacts.first.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
legals << admin_skipping_as_different = domain.admin_contacts.first.legal_documents.create!(body: Base64.encode64('E' * 4.kilobytes))
|
|
||||||
legals << new_second_tech_contact = domain2.tech_contacts.first.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
|
||||||
domain.tech_contacts << domain2.tech_contacts.first
|
|
||||||
|
|
||||||
|
|
||||||
# writing nesting to history
|
|
||||||
domain.update(updated_at: Time.now)
|
|
||||||
domain2.update(updated_at: Time.now)
|
|
||||||
domain.reload
|
|
||||||
|
|
||||||
skipping_as_no_checksum.update_columns(checksum: nil)
|
|
||||||
skipping_as_no_checksum2.update_columns(checksum: "")
|
|
||||||
skipping_as_no_checksum.reload
|
|
||||||
skipping_as_no_checksum2.reload
|
|
||||||
skipping_as_no_checksum.path.should_not == skipping_as_no_checksum2.path
|
|
||||||
|
|
||||||
skipping_as_no_checksum.checksum.should == nil
|
|
||||||
skipping_as_no_checksum2.checksum.should == ""
|
|
||||||
original.checksum.should == copy.checksum
|
|
||||||
original.checksum.should_not == skipping_as_different.checksum
|
|
||||||
domain.tech_contacts.count.should == 2
|
|
||||||
|
|
||||||
LegalDocument.remove_duplicates
|
|
||||||
LegalDocument.remove_duplicates
|
|
||||||
LegalDocument.remove_duplicates
|
|
||||||
legals.each(&:reload)
|
|
||||||
|
|
||||||
skipping_as_no_checksum.path.should_not be(skipping_as_no_checksum2.path)
|
|
||||||
original.path.should_not == skipping_as_different.path
|
|
||||||
original.path.should_not == skipping_as_different_domain.path
|
|
||||||
original.path.should_not == registrant_skipping_as_different.path
|
|
||||||
original.path.should_not == tech_skipping_as_different.path
|
|
||||||
original.path.should_not == admin_skipping_as_different.path
|
|
||||||
original.path.should == copy.path
|
|
||||||
original.path.should == registrant_copy.path
|
|
||||||
|
|
||||||
skipping_as_different_domain.path.should_not == new_second_tech_contact.path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,59 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe RegistrantVerification 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
|
|
||||||
|
|
||||||
create(:zone, origin: 'ee')
|
|
||||||
end
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :example do
|
|
||||||
@registrant_verification = RegistrantVerification.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not be valid' do
|
|
||||||
@registrant_verification.valid?
|
|
||||||
@registrant_verification.errors.full_messages.should match_array([
|
|
||||||
"Domain name is missing",
|
|
||||||
"Verification token is missing",
|
|
||||||
"Action is missing",
|
|
||||||
"Action type is missing",
|
|
||||||
"Domain is missing"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with valid attributes' do
|
|
||||||
before :example do
|
|
||||||
@registrant_verification = create(:registrant_verification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid' do
|
|
||||||
@registrant_verification.valid?
|
|
||||||
@registrant_verification.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be valid twice' do
|
|
||||||
@registrant_verification = create(:registrant_verification)
|
|
||||||
@registrant_verification.valid?
|
|
||||||
@registrant_verification.errors.full_messages.should match_array([])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,60 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Setting do
|
|
||||||
describe 'integer_settings', db: false do
|
|
||||||
it 'returns integer settings' do
|
|
||||||
settings = %i[
|
|
||||||
admin_contacts_min_count
|
|
||||||
admin_contacts_max_count
|
|
||||||
tech_contacts_min_count
|
|
||||||
tech_contacts_max_count
|
|
||||||
orphans_contacts_in_months
|
|
||||||
ds_digest_type
|
|
||||||
dnskeys_min_count
|
|
||||||
dnskeys_max_count
|
|
||||||
ns_min_count
|
|
||||||
ns_max_count
|
|
||||||
transfer_wait_time
|
|
||||||
invoice_number_min
|
|
||||||
invoice_number_max
|
|
||||||
days_to_keep_invoices_active
|
|
||||||
days_to_keep_overdue_invoices_active
|
|
||||||
days_to_renew_domain_before_expire
|
|
||||||
expire_warning_period
|
|
||||||
redemption_grace_period
|
|
||||||
expire_pending_confirmation
|
|
||||||
]
|
|
||||||
|
|
||||||
expect(described_class.integer_settings).to eq(settings)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'float_settings', db: false do
|
|
||||||
it 'returns float settings' do
|
|
||||||
settings = %i[
|
|
||||||
registry_vat_prc
|
|
||||||
minimum_deposit
|
|
||||||
]
|
|
||||||
|
|
||||||
expect(described_class.float_settings).to eq(settings)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'boolean_settings', db: false do
|
|
||||||
it 'returns boolean settings' do
|
|
||||||
settings = %i[
|
|
||||||
ds_data_allowed
|
|
||||||
key_data_allowed
|
|
||||||
client_side_status_editing_enabled
|
|
||||||
registrar_ip_whitelist_enabled
|
|
||||||
api_ip_whitelist_enabled
|
|
||||||
request_confrimation_on_registrant_change_enabled
|
|
||||||
request_confirmation_on_domain_deletion_enabled
|
|
||||||
nameserver_required
|
|
||||||
address_processing
|
|
||||||
]
|
|
||||||
|
|
||||||
expect(described_class.boolean_settings).to eq(settings)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,53 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe WhiteIp do
|
|
||||||
context 'with invalid attribute' do
|
|
||||||
before :all do
|
|
||||||
@white_ip = WhiteIp.new
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'is not valid' do
|
|
||||||
@white_ip.valid?
|
|
||||||
@white_ip.errors.full_messages.should match_array([
|
|
||||||
'IPv4 or IPv6 must be present'
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns an error with invalid ips' do
|
|
||||||
@white_ip.ipv4 = 'bla'
|
|
||||||
@white_ip.ipv6 = 'bla'
|
|
||||||
|
|
||||||
@white_ip.valid?
|
|
||||||
@white_ip.errors[:ipv4].should == ['is invalid']
|
|
||||||
@white_ip.errors[:ipv6].should == ['is invalid']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#include_ip?' do
|
|
||||||
context 'when given ip v4 exists' do
|
|
||||||
before do
|
|
||||||
create(:white_ip, ipv4: '127.0.0.1')
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(described_class.include_ip?('127.0.0.1')).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when given ip v6 exists' do
|
|
||||||
before do
|
|
||||||
create(:white_ip, ipv6: '::1')
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
expect(described_class.include_ip?('::1')).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when given ip does not exists', db: false do
|
|
||||||
specify do
|
|
||||||
expect(described_class.include_ip?('127.0.0.1')).to be false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,98 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DomainPresenter do
|
|
||||||
let(:presenter) { described_class.new(domain: domain, view: view) }
|
|
||||||
|
|
||||||
describe '#expire_time' do
|
|
||||||
let(:domain) { instance_double(Domain, expire_time: Time.zone.parse('05.07.2010')) }
|
|
||||||
|
|
||||||
it 'returns localized time' do
|
|
||||||
expect(view).to receive(:l).with(Time.zone.parse('05.07.2010')).and_return('expire time')
|
|
||||||
expect(presenter.expire_time).to eq('expire time')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#expire_date' do
|
|
||||||
let(:domain) { instance_double(Domain, expire_time: Time.zone.parse('05.07.2010')) }
|
|
||||||
|
|
||||||
it 'returns localized date' do
|
|
||||||
expect(view).to receive(:l).with(Time.zone.parse('05.07.2010'), format: :date).and_return('expire date')
|
|
||||||
expect(presenter.expire_date).to eq('expire date')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#on_hold_date' do
|
|
||||||
subject(:on_hold_date) { presenter.on_hold_date }
|
|
||||||
|
|
||||||
context 'when present' do
|
|
||||||
let(:domain) { instance_double(Domain, on_hold_time: '05.07.2010') }
|
|
||||||
|
|
||||||
it 'returns localized date' do
|
|
||||||
expect(view).to receive(:l).with('05.07.2010', format: :date).and_return('on hold date')
|
|
||||||
expect(on_hold_date).to eq('on hold date')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when absent' do
|
|
||||||
let(:domain) { instance_double(Domain, on_hold_time: nil) }
|
|
||||||
|
|
||||||
specify { expect(on_hold_date).to be_nil }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#delete_date' do
|
|
||||||
subject(:delete_date) { presenter.delete_date }
|
|
||||||
|
|
||||||
context 'when present' do
|
|
||||||
let(:domain) { instance_double(Domain, delete_date: '05.07.2010') }
|
|
||||||
|
|
||||||
it 'returns localized date' do
|
|
||||||
expect(view).to receive(:l).with('05.07.2010').and_return('delete date')
|
|
||||||
expect(delete_date).to eq('delete date')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when absent' do
|
|
||||||
let(:domain) { instance_double(Domain, delete_date: nil) }
|
|
||||||
|
|
||||||
specify { expect(delete_date).to be_nil }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#force_delete_date' do
|
|
||||||
subject(:force_delete_date) { presenter.force_delete_date }
|
|
||||||
|
|
||||||
context 'when present' do
|
|
||||||
let(:domain) { instance_double(Domain, force_delete_date: '05.07.2010', force_delete_scheduled?: true) }
|
|
||||||
|
|
||||||
it 'returns localized date' do
|
|
||||||
expect(view).to receive(:l).with('05.07.2010').and_return('delete date')
|
|
||||||
expect(force_delete_date).to eq('delete date')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when absent' do
|
|
||||||
let(:domain) { instance_double(Domain, force_delete_date: nil, force_delete_scheduled?: false) }
|
|
||||||
|
|
||||||
specify { expect(force_delete_date).to be_nil }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
domain_delegatable_attributes = %i(
|
|
||||||
name
|
|
||||||
transfer_code
|
|
||||||
registrant
|
|
||||||
registrant_id
|
|
||||||
)
|
|
||||||
|
|
||||||
domain_delegatable_attributes.each do |attribute_name|
|
|
||||||
describe "##{attribute_name}" do
|
|
||||||
let(:domain) { instance_spy(Domain) }
|
|
||||||
|
|
||||||
it 'delegates to domain' do
|
|
||||||
presenter.send(attribute_name)
|
|
||||||
expect(domain).to have_received(attribute_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,81 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe RegistrantPresenter do
|
|
||||||
let(:registrant) { instance_double(Registrant) }
|
|
||||||
let(:presenter) { described_class.new(registrant: registrant, view: view) }
|
|
||||||
|
|
||||||
describe '#country' do
|
|
||||||
let(:country) { instance_double(Country) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
allow(registrant).to receive(:country).and_return(country)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns country name in current locale by default' do
|
|
||||||
expect(country).to receive(:translation).with(I18n.locale).and_return('test country')
|
|
||||||
expect(presenter.country).to eq('test country')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns country name in given locale' do
|
|
||||||
expect(country).to receive(:translation).with(:de).and_return('test country')
|
|
||||||
expect(presenter.country(locale: :de)).to eq('test country')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#ident_country' do
|
|
||||||
let(:ident_country) { instance_double(Country) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
allow(registrant).to receive(:ident_country).and_return(ident_country)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns country name in current locale by default' do
|
|
||||||
expect(ident_country).to receive(:translation).with(I18n.locale).and_return('test country')
|
|
||||||
expect(presenter.ident_country).to eq('test country')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns country name in given locale' do
|
|
||||||
expect(ident_country).to receive(:translation).with(:de).and_return('test country')
|
|
||||||
expect(presenter.ident_country(locale: :de)).to eq('test country')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#domain_names_with_roles' do
|
|
||||||
before :example do
|
|
||||||
roles = %i[registrant admin_domain_contact tech_domain_contact]
|
|
||||||
allow(registrant).to receive(:domain_names_with_roles)
|
|
||||||
.and_return({ 'test.com' => roles,
|
|
||||||
'test.org' => %i[registrant] })
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns domain names with unique roles in current locale by default' do
|
|
||||||
text = "test.com (Registrant, Administrative contact, Technical contact)" \
|
|
||||||
"\ntest.org (Registrant)"
|
|
||||||
expect(presenter.domain_names_with_roles).to eq(text)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
registrant_delegatable_attributes = %i(
|
|
||||||
name
|
|
||||||
ident
|
|
||||||
phone
|
|
||||||
email
|
|
||||||
priv?
|
|
||||||
street
|
|
||||||
city
|
|
||||||
state
|
|
||||||
zip
|
|
||||||
id_code
|
|
||||||
reg_no
|
|
||||||
linked?
|
|
||||||
)
|
|
||||||
|
|
||||||
registrant_delegatable_attributes.each do |attr_name|
|
|
||||||
describe "##{attr_name}" do
|
|
||||||
it 'delegates to registrant' do
|
|
||||||
expect(registrant).to receive(attr_name).and_return('test')
|
|
||||||
expect(presenter.send(attr_name)).to eq('test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,34 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe RegistrarPresenter do
|
|
||||||
let(:registrar) { instance_double(Registrar) }
|
|
||||||
let(:presenter) { described_class.new(registrar: registrar, view: view) }
|
|
||||||
|
|
||||||
describe '#name' do
|
|
||||||
it 'returns name' do
|
|
||||||
expect(registrar).to receive(:name).and_return('test name')
|
|
||||||
expect(presenter.name).to eq('test name')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#email' do
|
|
||||||
it 'returns email' do
|
|
||||||
expect(registrar).to receive(:email).and_return('test email')
|
|
||||||
expect(presenter.email).to eq('test email')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#phone' do
|
|
||||||
it 'returns phone' do
|
|
||||||
expect(registrar).to receive(:phone).and_return('test phone')
|
|
||||||
expect(presenter.phone).to eq('test phone')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#website' do
|
|
||||||
it 'returns website' do
|
|
||||||
expect(registrar).to receive(:website).and_return('test')
|
|
||||||
expect(presenter.website).to eq('test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,16 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe UserPresenter do
|
|
||||||
let(:presenter) { described_class.new(user: user, view: view) }
|
|
||||||
|
|
||||||
describe '#login_with_role' do
|
|
||||||
let(:user) { instance_double(ApiUser,
|
|
||||||
login: 'login',
|
|
||||||
roles: %w[role],
|
|
||||||
registrar_name: 'registrar') }
|
|
||||||
|
|
||||||
it 'returns username with role and registrar' do
|
|
||||||
expect(presenter.login_with_role).to eq('login (role) - registrar')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,64 +0,0 @@
|
||||||
ENV['RAILS_ENV'] ||= 'test'
|
|
||||||
require 'spec_helper'
|
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
|
||||||
require 'rspec/rails'
|
|
||||||
require 'paper_trail/frameworks/rspec'
|
|
||||||
require 'money-rails/test_helpers'
|
|
||||||
require 'support/requests/session_helpers'
|
|
||||||
require 'support/requests/epp_helpers'
|
|
||||||
require 'support/features/session_helpers'
|
|
||||||
require 'support/matchers/alias_attribute'
|
|
||||||
|
|
||||||
require 'support/capybara'
|
|
||||||
require 'support/devise'
|
|
||||||
require 'support/factory_bot'
|
|
||||||
require 'support/database_cleaner'
|
|
||||||
require 'support/paper_trail'
|
|
||||||
require 'support/settings'
|
|
||||||
|
|
||||||
ActiveRecord::Migration.maintain_test_schema!
|
|
||||||
Setting.registry_country_code = 'US'
|
|
||||||
|
|
||||||
RSpec.configure do |config|
|
|
||||||
config.include ActionView::TestCase::Behavior, type: :presenter
|
|
||||||
config.include ActiveSupport::Testing::TimeHelpers
|
|
||||||
config.include Requests::SessionHelpers, type: :request
|
|
||||||
config.include Features::SessionHelpers, type: :feature
|
|
||||||
config.include AbstractController::Translation, type: :request
|
|
||||||
config.include AbstractController::Translation, type: :feature
|
|
||||||
config.include AbstractController::Translation, type: :mailer
|
|
||||||
config.include Requests::EPPHelpers, epp: true
|
|
||||||
config.include Devise::Test::IntegrationHelpers, type: :feature
|
|
||||||
config.include Devise::Test::IntegrationHelpers, type: :request
|
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata|
|
|
||||||
metadata[:db] = true if metadata[:db].nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/models/]) do |metadata|
|
|
||||||
metadata[:db] = true if metadata[:db].nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/presenters/]) do |metadata|
|
|
||||||
metadata[:type] = :presenter
|
|
||||||
end
|
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/requests/]) do |metadata|
|
|
||||||
metadata[:db] = true if metadata[:db].nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/requests/epp/]) do |metadata|
|
|
||||||
metadata[:epp] = true if metadata[:epp].nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
config.define_derived_metadata(file_path: %r[/spec/api/]) do |metadata|
|
|
||||||
metadata[:type] = :request
|
|
||||||
end
|
|
||||||
|
|
||||||
config.use_transactional_fixtures = false
|
|
||||||
config.infer_spec_type_from_file_location!
|
|
||||||
|
|
||||||
config.expect_with :rspec do |c|
|
|
||||||
c.syntax = [:should, :expect]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,51 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'admin price create', settings: false do
|
|
||||||
let!(:zone) { create(:zone, id: 1, origin: 'test') }
|
|
||||||
subject(:price) { Billing::Price.first }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates new price' do
|
|
||||||
expect { post admin_prices_path, price: attributes_for(:price, zone_id: '1') }
|
|
||||||
.to change { Billing::Price.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves zone' do
|
|
||||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1')
|
|
||||||
expect(price.zone_id).to eq(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves operation category' do
|
|
||||||
post admin_prices_path, price:
|
|
||||||
attributes_for(:price, zone_id: '1', operation_category: Billing::Price.operation_categories.first)
|
|
||||||
expect(price.operation_category).to eq(Billing::Price.operation_categories.first)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves duration in months' do
|
|
||||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', duration: '3 mons')
|
|
||||||
expect(price.duration).to eq('3 mons')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves duration in years' do
|
|
||||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', duration: '1 year')
|
|
||||||
expect(price.duration).to eq('1 year')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves valid_from' do
|
|
||||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', valid_from: '2010-07-06')
|
|
||||||
expect(price.valid_from).to eq(Time.zone.parse('06.07.2010'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves valid_to' do
|
|
||||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1', valid_to: '2010-07-06')
|
|
||||||
expect(price.valid_to).to eq(Time.zone.parse('06.07.2010'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to :index' do
|
|
||||||
post admin_prices_path, price: attributes_for(:price, zone_id: '1')
|
|
||||||
expect(response).to redirect_to admin_prices_url
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,22 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'admin price expire', settings: false do
|
|
||||||
before :example do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'expires price' do
|
|
||||||
price = create(:effective_price)
|
|
||||||
|
|
||||||
expect { patch expire_admin_price_path(price); price.reload }
|
|
||||||
.to change { price.expired? }.from(false).to(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to :index' do
|
|
||||||
price = create(:effective_price)
|
|
||||||
|
|
||||||
patch expire_admin_price_path(price)
|
|
||||||
|
|
||||||
expect(response).to redirect_to admin_prices_url
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,71 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'admin price update', settings: false do
|
|
||||||
before :example do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates zone' do
|
|
||||||
price = create(:price)
|
|
||||||
create(:zone, id: 2)
|
|
||||||
|
|
||||||
patch admin_price_path(price), price: attributes_for(:price, zone_id: '2')
|
|
||||||
price.reload
|
|
||||||
|
|
||||||
expect(price.zone_id).to eq(2)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates operation category' do
|
|
||||||
price = create(:price, operation_category: Billing::Price.operation_categories.first)
|
|
||||||
|
|
||||||
patch admin_price_path(price),
|
|
||||||
price: attributes_for(:price, operation_category: Billing::Price.operation_categories.second)
|
|
||||||
price.reload
|
|
||||||
|
|
||||||
expect(price.operation_category).to eq(Billing::Price.operation_categories.second)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates duration in months' do
|
|
||||||
price = create(:price, duration: '3 mons')
|
|
||||||
|
|
||||||
patch admin_price_path(price), price: attributes_for(:price, duration: '6 mons')
|
|
||||||
price.reload
|
|
||||||
|
|
||||||
expect(price.duration).to eq('6 mons')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates duration in years' do
|
|
||||||
price = create(:price, duration: '1 year')
|
|
||||||
|
|
||||||
patch admin_price_path(price), price: attributes_for(:price, duration: '2 years')
|
|
||||||
price.reload
|
|
||||||
|
|
||||||
expect(price.duration).to eq('2 years')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates valid_from' do
|
|
||||||
price = create(:price, valid_from: '2010-07-05')
|
|
||||||
|
|
||||||
patch admin_price_path(price), price: attributes_for(:price, valid_from: '2010-07-06')
|
|
||||||
price.reload
|
|
||||||
|
|
||||||
expect(price.valid_from).to eq(Time.zone.parse('06.07.2010'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates valid_to' do
|
|
||||||
price = create(:price, valid_to: '2010-07-05')
|
|
||||||
|
|
||||||
patch admin_price_path(price), price: attributes_for(:price, valid_to: '2010-07-06')
|
|
||||||
price.reload
|
|
||||||
|
|
||||||
expect(price.valid_to).to eq(Time.zone.parse('06.07.2010'))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to :index' do
|
|
||||||
price = create(:price)
|
|
||||||
|
|
||||||
patch admin_price_path(price), price: attributes_for(:price)
|
|
||||||
|
|
||||||
expect(response).to redirect_to admin_prices_url
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,36 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'admin zone create', settings: false do
|
|
||||||
subject(:zone) { DNS::Zone.first }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates new zone' do
|
|
||||||
expect { post admin_zones_path, zone: attributes_for(:zone) }
|
|
||||||
.to change { DNS::Zone.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
text_attributes = %i[origin email master_nameserver ns_records a_records a4_records]
|
|
||||||
integer_attributes = %i[ttl refresh retry expire minimum_ttl]
|
|
||||||
|
|
||||||
text_attributes.each do |attr_name|
|
|
||||||
it "saves #{attr_name}" do
|
|
||||||
post admin_zones_path, zone: attributes_for(:zone, attr_name => 'test')
|
|
||||||
expect(zone.send(attr_name)).to eq('test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
integer_attributes.each do |attr_name|
|
|
||||||
it "saves #{attr_name}" do
|
|
||||||
post admin_zones_path, zone: attributes_for(:zone, attr_name => '1')
|
|
||||||
expect(zone.send(attr_name)).to eq(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to :index' do
|
|
||||||
post admin_zones_path, zone: attributes_for(:zone)
|
|
||||||
expect(response).to redirect_to admin_zones_url
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,40 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'admin zone update', settings: false do
|
|
||||||
before :example do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
text_attributes = %i[origin email master_nameserver ns_records a_records a4_records]
|
|
||||||
integer_attributes = %i[ttl refresh retry expire minimum_ttl]
|
|
||||||
|
|
||||||
text_attributes.each do |attr_name|
|
|
||||||
it "updates #{attr_name}" do
|
|
||||||
zone = create(:zone, attr_name => 'test')
|
|
||||||
|
|
||||||
patch admin_zone_path(zone), zone: attributes_for(:zone, attr_name => 'new-test')
|
|
||||||
zone.reload
|
|
||||||
|
|
||||||
expect(zone.send(attr_name)).to eq('new-test')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
integer_attributes.each do |attr_name|
|
|
||||||
it "updates #{attr_name}" do
|
|
||||||
zone = create(:zone, attr_name => '1')
|
|
||||||
|
|
||||||
patch admin_zone_path(zone), zone: attributes_for(:zone, attr_name => '2')
|
|
||||||
zone.reload
|
|
||||||
|
|
||||||
expect(zone.send(attr_name)).to eq(2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to :index' do
|
|
||||||
zone = create(:zone)
|
|
||||||
|
|
||||||
patch admin_zone_path(zone), zone: attributes_for(:zone)
|
|
||||||
|
|
||||||
expect(response).to redirect_to admin_zones_url
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,35 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'Admin settings saving' do
|
|
||||||
before do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves integer setting' do
|
|
||||||
allow(Setting).to receive(:integer_settings) { %i[test_setting] }
|
|
||||||
post admin_settings_path, settings: { test_setting: '1' }
|
|
||||||
expect(Setting.test_setting).to eq(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves float setting' do
|
|
||||||
allow(Setting).to receive(:float_settings) { %i[test_setting] }
|
|
||||||
post admin_settings_path, settings: { test_setting: '1.2' }
|
|
||||||
expect(Setting.test_setting).to eq(1.2)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves boolean setting' do
|
|
||||||
allow(Setting).to receive(:boolean_settings) { %i[test_setting] }
|
|
||||||
post admin_settings_path, settings: { test_setting: 'true' }
|
|
||||||
expect(Setting.test_setting).to be true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves string setting' do
|
|
||||||
post admin_settings_path, settings: { test_setting: 'test' }
|
|
||||||
expect(Setting.test_setting).to eq('test')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to :index' do
|
|
||||||
post admin_settings_path, settings: { test: 'test' }
|
|
||||||
expect(response).to redirect_to admin_settings_path
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'Admin area zone file generation', settings: false do
|
|
||||||
let!(:zone) { create(:zone, origin: 'com') }
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'generates new' do
|
|
||||||
post admin_zonefiles_path(origin: 'com')
|
|
||||||
expect(response).to be_success
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,286 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP contact:create' do
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
|
|
||||||
before do
|
|
||||||
Setting.address_processing = false
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when all ident params are valid' do
|
|
||||||
let(:ident) { Contact.first.identifier }
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="priv" cc="US">test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'creates a contact' do
|
|
||||||
expect { request }.to change { Contact.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves ident type' do
|
|
||||||
request
|
|
||||||
expect(ident.type).to eq('priv')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'saves ident country code' do
|
|
||||||
request
|
|
||||||
expect(ident.country_code).to eq('US')
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when code is blank' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="priv" cc="US"></eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'does not create a contact' do
|
|
||||||
expect { request }.to_not change { Contact.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:required_parameter_missing))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when code is not valid national id' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="priv" cc="DE">invalid</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
country_specific_validations = {
|
|
||||||
Country.new('DE') => proc { false },
|
|
||||||
}
|
|
||||||
|
|
||||||
allow(Contact::Ident::NationalIdValidator).to receive(:country_specific_validations)
|
|
||||||
.and_return(country_specific_validations)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create a contact' do
|
|
||||||
expect { request }.to_not change { Contact.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when code is not valid registration number' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="org" cc="DE">invalid</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
country_specific_formats = {
|
|
||||||
Country.new('DE') => /\Avalid\z/,
|
|
||||||
}
|
|
||||||
|
|
||||||
allow(Contact::Ident::RegNoValidator).to receive(:country_specific_formats).and_return(country_specific_formats)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create a contact' do
|
|
||||||
expect { request }.to_not change { Contact.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when country code is absent' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="priv">test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'does not create a contact' do
|
|
||||||
expect { request }.to_not change { Contact.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:required_parameter_missing))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when country code is blank' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="priv" cc="">test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'does not create a contact' do
|
|
||||||
expect { request }.to_not change { Contact.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:syntax_error))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when mismatches' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>+1.2</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="priv" cc="DE">test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
mismatches = [
|
|
||||||
Contact::Ident::MismatchValidator::Mismatch.new('priv', Country.new('DE'))
|
|
||||||
]
|
|
||||||
allow(Contact::Ident::MismatchValidator).to receive(:mismatches).and_return(mismatches)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create a contact' do
|
|
||||||
expect { request }.to_not change { Contact.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,38 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require_relative '../shared/phone'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP contact:create' do
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
<contact:voice>#{phone}</contact:voice>
|
|
||||||
<contact:email>test@test.com</contact:email>
|
|
||||||
</contact:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident type="org" cc="US">123456</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
include_examples 'EPP contact phone'
|
|
||||||
end
|
|
File diff suppressed because one or more lines are too long
|
@ -1,60 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP contact:update' do
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request_xml) { '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<info>
|
|
||||||
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:id>test</contact:id>
|
|
||||||
</contact:info>
|
|
||||||
</info>
|
|
||||||
</command>
|
|
||||||
</epp>'
|
|
||||||
}
|
|
||||||
subject(:response_xml) { Nokogiri::XML(response.body) }
|
|
||||||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
|
||||||
subject(:address_count) { response_xml
|
|
||||||
.xpath('//contact:addr', contact: 'https://epp.tld.ee/schema/contact-ee-1.1.xsd')
|
|
||||||
.count }
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
create(:contact, code: 'TEST')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when address processing is enabled' do
|
|
||||||
before do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
|
||||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
|
||||||
expect(response_code).to eq('1000')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns address' do
|
|
||||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
|
||||||
expect(address_count).to_not be_zero
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when address processing is disabled' do
|
|
||||||
before do
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns epp code of 1000' do
|
|
||||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
|
||||||
expect(response_code).to eq('1000')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not return address' do
|
|
||||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
|
||||||
expect(address_count).to be_zero
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,28 +0,0 @@
|
||||||
RSpec.shared_examples 'EPP contact phone' do
|
|
||||||
context 'when phone is valid' do
|
|
||||||
let(:phone) { '+123.4' }
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when phone has invalid format' do
|
|
||||||
let(:phone) { '1234' }
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when phone has only zeros' do
|
|
||||||
let(:phone) { '+000.0' }
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,195 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
# https://github.com/internetee/registry/issues/576
|
|
||||||
|
|
||||||
RSpec.describe 'EPP contact:update' do
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:ident) { contact.identifier }
|
|
||||||
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:id>TEST</contact:id>
|
|
||||||
<contact:chg>
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
</contact:chg>
|
|
||||||
</contact:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident cc="US" type="priv">test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when contact ident is valid' do
|
|
||||||
context 'when submitted ident matches current one' do
|
|
||||||
let!(:contact) { create(:contact, code: 'TEST',
|
|
||||||
ident: 'test',
|
|
||||||
ident_type: 'priv',
|
|
||||||
ident_country_code: 'US') }
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when submitted ident does not match current one' do
|
|
||||||
let!(:contact) { create(:contact, code: 'TEST',
|
|
||||||
ident: 'another-test',
|
|
||||||
ident_type: 'priv',
|
|
||||||
ident_country_code: 'US') }
|
|
||||||
|
|
||||||
it 'does not update code' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.code }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not update type' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.type }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not update country code' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.country_code }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:data_management_policy_violation))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when contact ident is invalid' do
|
|
||||||
let(:contact) { build(:contact, code: 'TEST', ident: 'test', ident_type: nil, ident_country_code: nil) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
contact.save(validate: false)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when submitted ident is the same as current one' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:id>TEST</contact:id>
|
|
||||||
<contact:chg>
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
</contact:chg>
|
|
||||||
</contact:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident cc="US" type="priv">test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'does not update code' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.code }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates type' do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
expect(ident.type).to eq('priv')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'updates country code' do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
expect(ident.country_code).to eq('US')
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when submitted ident is different from current one' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:id>TEST</contact:id>
|
|
||||||
<contact:chg>
|
|
||||||
<contact:postalInfo>
|
|
||||||
<contact:name>test</contact:name>
|
|
||||||
</contact:postalInfo>
|
|
||||||
</contact:chg>
|
|
||||||
</contact:update>
|
|
||||||
</update>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:ident cc="US" type="priv">another-test</eis:ident>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'does not update code' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.code }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not update type' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.type }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not update country code' do
|
|
||||||
expect do
|
|
||||||
request
|
|
||||||
contact.reload
|
|
||||||
end.to_not change { ident.country_code }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:data_management_policy_violation))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,33 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require_relative '../shared/phone'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP contact:update' do
|
|
||||||
let(:registrar) { create(:registrar) }
|
|
||||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let!(:contact) { create(:contact, code: 'TEST') }
|
|
||||||
let(:request) { post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<update>
|
|
||||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
|
||||||
<contact:id>TEST</contact:id>
|
|
||||||
<contact:chg>
|
|
||||||
<contact:voice>#{phone}</contact:voice>
|
|
||||||
</contact:chg>
|
|
||||||
</contact:update>
|
|
||||||
</update>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in user
|
|
||||||
allow(Contact).to receive(:address_processing?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
include_examples 'EPP contact phone'
|
|
||||||
end
|
|
File diff suppressed because one or more lines are too long
|
@ -1,68 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:create', settings: false do
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let!(:contact) { create(:contact, code: 'test') }
|
|
||||||
let!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '1 year',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
|
||||||
Setting.days_to_renew_domain_before_expire = 0
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when account balance is sufficient' do
|
|
||||||
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
|
||||||
|
|
||||||
it 'creates domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when account balance is not sufficient' do
|
|
||||||
let!(:registrar) { create(:registrar_with_zero_balance) }
|
|
||||||
|
|
||||||
it 'does not create domain' do
|
|
||||||
expect { request }.to_not change { Domain.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:billing_failure))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,60 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:create', settings: false do
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let!(:contact) { create(:contact, code: 'test') }
|
|
||||||
let!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '1 year',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 10:30')
|
|
||||||
Setting.days_to_renew_domain_before_expire = 0
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when period is absent' do
|
|
||||||
it 'creates domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'uses default duration of 1 year' do
|
|
||||||
request
|
|
||||||
expire_time = (Time.zone.parse('05.07.2010') + 1.year + 1.day).beginning_of_day
|
|
||||||
expect(Domain.first.expire_time).to eq(expire_time)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,110 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:create', settings: false do
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
|
||||||
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let!(:contact) { create(:contact, code: 'test') }
|
|
||||||
let!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '1 year',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is optional' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when minimum nameserver count requirement is not satisfied' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns.test.com</domain:hostName>
|
|
||||||
<domain:hostAddr ip="v4">192.168.1.1</domain:hostAddr>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
Setting.ns_min_count = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not create domain' do
|
|
||||||
expect { request }.to_not change { Domain.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:data_management_policy_violation))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is absent' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'creates new domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'new domain' do
|
|
||||||
it 'has status of inactive' do
|
|
||||||
request
|
|
||||||
expect(Domain.first.statuses).to include(DomainStatus::INACTIVE)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,109 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:create', settings: false do
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let!(:contact) { create(:contact, code: 'test') }
|
|
||||||
let!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010 10:30')
|
|
||||||
Setting.days_to_renew_domain_before_expire = 0
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when period is 3 months' do
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '3 mons',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="m">3</domain:period>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
it 'creates domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify 'expire_time' do
|
|
||||||
request
|
|
||||||
expire_time = (Time.zone.parse('05.07.2010 10:30') + 3.months + 1.day).beginning_of_day
|
|
||||||
expect(Domain.first.expire_time).to eq(expire_time)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when period is 10 years' do
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '10 years',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="y">10</domain:period>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'creates domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify 'expire_time' do
|
|
||||||
request
|
|
||||||
expire_time = (Time.zone.parse('05.07.2010 10:30') + 10.years + 1.day).beginning_of_day
|
|
||||||
expect(Domain.first.expire_time).to eq(expire_time)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,67 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:create', settings: false do
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let!(:contact) { create(:contact, code: 'test') }
|
|
||||||
let!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
|
||||||
Setting.days_to_renew_domain_before_expire = 0
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when price is present' do
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '1 year',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'creates domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when price is absent' do
|
|
||||||
it 'does not create domain' do
|
|
||||||
expect { request }.to_not change { Domain.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:billing_failure))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,100 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'EPP domain:create', settings: false do
|
|
||||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
|
||||||
let(:request) { post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}" }
|
|
||||||
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
|
||||||
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
|
||||||
let!(:contact) { create(:contact, code: 'test') }
|
|
||||||
let!(:zone) { create(:zone, origin: 'test') }
|
|
||||||
let!(:price) { create(:price,
|
|
||||||
duration: '1 year',
|
|
||||||
price: Money.from_amount(1),
|
|
||||||
operation_category: 'create',
|
|
||||||
valid_from: Time.zone.parse('05.07.2010'),
|
|
||||||
valid_to: Time.zone.parse('05.07.2010'),
|
|
||||||
zone: zone)
|
|
||||||
}
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
|
||||||
sign_in user
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameserver is required' do
|
|
||||||
before :example do
|
|
||||||
allow(Domain).to receive(:nameserver_required?).and_return(true)
|
|
||||||
Setting.ns_min_count = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when minimum nameserver count requirement is satisfied' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:ns>
|
|
||||||
<domain:hostAttr>
|
|
||||||
<domain:hostName>ns.test.com</domain:hostName>
|
|
||||||
<domain:hostAddr ip="v4">192.168.1.1</domain:hostAddr>
|
|
||||||
</domain:hostAttr>
|
|
||||||
</domain:ns>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'creates new domain' do
|
|
||||||
expect { request }.to change { Domain.count }.from(0).to(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when nameservers are absent' do
|
|
||||||
let(:request_xml) { <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
|
||||||
<command>
|
|
||||||
<create>
|
|
||||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
|
||||||
<domain:name>test.test</domain:name>
|
|
||||||
<domain:period unit="y">1</domain:period>
|
|
||||||
<domain:registrant>test</domain:registrant>
|
|
||||||
</domain:create>
|
|
||||||
</create>
|
|
||||||
<extension>
|
|
||||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
|
||||||
<eis:legalDocument type="pdf">#{valid_legal_document}</eis:legalDocument>
|
|
||||||
</eis:extdata>
|
|
||||||
</extension>
|
|
||||||
</command>
|
|
||||||
</epp>
|
|
||||||
XML
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'does not create domain' do
|
|
||||||
expect { request }.to_not change { Domain.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
specify do
|
|
||||||
request
|
|
||||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:required_parameter_missing))).to be_truthy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue