mirror of
https://github.com/internetee/registry.git
synced 2025-05-22 12:19:39 +02:00
commit
589afdbe07
7 changed files with 189 additions and 35 deletions
|
@ -45,6 +45,7 @@ Manual demo install and database setup:
|
||||||
cp config/application-example.yml config/application.yml # and edit it
|
cp config/application-example.yml config/application.yml # and edit it
|
||||||
cp config/database-example.yml config/database.yml # and edit it
|
cp config/database-example.yml config/database.yml # and edit it
|
||||||
bundle exec rake db:setup:all # for production, please follow deployment howto
|
bundle exec rake db:setup:all # for production, please follow deployment howto
|
||||||
|
bundle exec rake:bootstrap
|
||||||
bundle exec rake assets:precompile
|
bundle exec rake assets:precompile
|
||||||
|
|
||||||
### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS)
|
### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS)
|
||||||
|
|
|
@ -135,6 +135,16 @@ class EppController < ApplicationController
|
||||||
@errors += obj.errors[:epp_errors]
|
@errors += obj.errors[:epp_errors]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:parsed_frame].at_css('update')
|
||||||
|
@errors.each_with_index do |errors, index|
|
||||||
|
if errors[:code] == '2304' &&
|
||||||
|
errors[:value][:val] == DomainStatus::SERVER_DELETE_PROHIBITED &&
|
||||||
|
errors[:value][:obj] == 'status'
|
||||||
|
@errors[index][:value][:val] = DomainStatus::PENDING_UPDATE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# for debugging
|
# for debugging
|
||||||
if @errors.blank?
|
if @errors.blank?
|
||||||
@errors << {
|
@errors << {
|
||||||
|
|
34
db/seeds.rb
34
db/seeds.rb
|
@ -1,36 +1,2 @@
|
||||||
# This file should contain all the record creation needed to seed the database with its default values.
|
# This file should contain all the record creation needed to seed the database with its default values.
|
||||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
|
||||||
registrar = Registrar.create!(
|
|
||||||
name: 'Test',
|
|
||||||
reg_no: '1234',
|
|
||||||
street: 'test',
|
|
||||||
city: 'test',
|
|
||||||
state: 'test',
|
|
||||||
zip: '1234',
|
|
||||||
email: 'test@domain.tld',
|
|
||||||
country_code: 'US',
|
|
||||||
code: 'US1'
|
|
||||||
)
|
|
||||||
|
|
||||||
registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
|
|
||||||
|
|
||||||
ApiUser.create!(
|
|
||||||
username: 'test',
|
|
||||||
password: 'testtest',
|
|
||||||
identity_code: '51001091072',
|
|
||||||
active: true,
|
|
||||||
registrar: registrar,
|
|
||||||
roles: ['super']
|
|
||||||
)
|
|
||||||
|
|
||||||
AdminUser.create!(
|
|
||||||
username: 'test',
|
|
||||||
email: 'test@domain.tld',
|
|
||||||
password: 'testtest',
|
|
||||||
password_confirmation: 'testtest',
|
|
||||||
country_code: 'US',
|
|
||||||
roles: ['admin']
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
11
lib/tasks/bootstrap.rake
Normal file
11
lib/tasks/bootstrap.rake
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
desc 'Bootstraps production-like environment'
|
||||||
|
task :bootstrap do
|
||||||
|
AdminUser.create!(
|
||||||
|
username: 'admin',
|
||||||
|
email: 'admin@domain.tld',
|
||||||
|
password: 'adminadmin',
|
||||||
|
password_confirmation: 'adminadmin',
|
||||||
|
country_code: 'US',
|
||||||
|
roles: ['admin']
|
||||||
|
)
|
||||||
|
end
|
129
lib/tasks/dev.rake
Normal file
129
lib/tasks/dev.rake
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
namespace :dev do
|
||||||
|
desc 'Generates dummy data in development environment' \
|
||||||
|
' (options: [random] for random data generation - slowest)'
|
||||||
|
|
||||||
|
task :prime, [:random] => :environment do |t, args|
|
||||||
|
abort 'Production environment is not supported' if Rails.env.production?
|
||||||
|
|
||||||
|
require 'factory_girl'
|
||||||
|
include FactoryGirl::Syntax::Methods
|
||||||
|
FactoryGirl.find_definitions
|
||||||
|
|
||||||
|
PaperTrail.enabled = false
|
||||||
|
with_random_data = args[:random].present?
|
||||||
|
|
||||||
|
def generate_default_data
|
||||||
|
create(:admin_user, username: 'test', password: 'testtest', password_confirmation: 'testtest')
|
||||||
|
|
||||||
|
zone = create(:zone, origin: 'test')
|
||||||
|
registrar = create(:registrar, name: 'test')
|
||||||
|
registrant = create(:registrant, name: 'test', registrar: registrar)
|
||||||
|
|
||||||
|
create(:account, registrar: registrar, balance: 1_000_000)
|
||||||
|
create(:api_user, username: 'test', password: 'testtest', registrar: registrar)
|
||||||
|
create(:domain,
|
||||||
|
name: 'test.test',
|
||||||
|
period: 1,
|
||||||
|
period_unit: 'y',
|
||||||
|
registered_at: Time.zone.now,
|
||||||
|
valid_from: Time.zone.now,
|
||||||
|
expire_time: Time.zone.now + 10.years,
|
||||||
|
registrar: registrar,
|
||||||
|
registrant: registrant)
|
||||||
|
|
||||||
|
Billing::Price.durations.each do |duration|
|
||||||
|
Billing::Price.operation_categories.each do |operation_category|
|
||||||
|
create(:price,
|
||||||
|
price: Money.from_amount(1),
|
||||||
|
valid_from: Time.zone.now.beginning_of_day,
|
||||||
|
valid_to: Time.zone.now + 10.years,
|
||||||
|
duration: duration,
|
||||||
|
operation_category: operation_category,
|
||||||
|
zone: zone)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_random_data
|
||||||
|
zone_count = 10
|
||||||
|
admin_user_count = 5
|
||||||
|
registrar_count = 50
|
||||||
|
api_user_count = 10
|
||||||
|
registrant_count = 50
|
||||||
|
domain_count = 50
|
||||||
|
registrars = []
|
||||||
|
registrants = []
|
||||||
|
zones = []
|
||||||
|
registrant_names = [
|
||||||
|
'John Doe',
|
||||||
|
'John Roe',
|
||||||
|
'Jane Doe',
|
||||||
|
'Jane Roe',
|
||||||
|
'John Smith',
|
||||||
|
]
|
||||||
|
|
||||||
|
zone_count.times do
|
||||||
|
origin = SecureRandom.hex[0..(rand(5) + 1)]
|
||||||
|
zones << create(:zone, origin: origin)
|
||||||
|
end
|
||||||
|
|
||||||
|
zone_origins = zones.collect { |zone| zone.origin }
|
||||||
|
|
||||||
|
admin_user_count.times do
|
||||||
|
uid = SecureRandom.hex[0..(rand(5) + 1)]
|
||||||
|
create(:admin_user, username: "test#{uid}", password: 'testtest', password_confirmation: 'testtest')
|
||||||
|
end
|
||||||
|
|
||||||
|
registrar_count.times do
|
||||||
|
uid = SecureRandom.hex[0..(rand(5) + 1)]
|
||||||
|
registrars << create(:registrar, name: "Acme Ltd. #{uid}")
|
||||||
|
end
|
||||||
|
|
||||||
|
registrars.each do |registrar|
|
||||||
|
create(:account, registrar: registrar, balance: rand(99999))
|
||||||
|
|
||||||
|
api_user_count.times do |i|
|
||||||
|
create(:api_user, username: "test#{registrar.id}#{i}", password: 'testtest', registrar: registrar)
|
||||||
|
end
|
||||||
|
|
||||||
|
registrant_count.times do |i|
|
||||||
|
registrants << create(:registrant, name: registrant_names.sample, registrar: registrar)
|
||||||
|
end
|
||||||
|
|
||||||
|
domain_count.times do |i|
|
||||||
|
name = "test#{registrar.id}#{i}#{rand(99999)}.#{zone_origins.sample}"
|
||||||
|
period = rand(3) + 1
|
||||||
|
|
||||||
|
create(:domain,
|
||||||
|
name: name,
|
||||||
|
period: period,
|
||||||
|
period_unit: 'y',
|
||||||
|
registered_at: Time.zone.now,
|
||||||
|
valid_from: Time.zone.now,
|
||||||
|
expire_time: Time.zone.now + period.years,
|
||||||
|
registrar: registrar,
|
||||||
|
registrant: registrants.sample)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
zones.each do |zone|
|
||||||
|
Billing::Price.durations.each do |duration|
|
||||||
|
Billing::Price.operation_categories.each do |operation_category|
|
||||||
|
create(:price,
|
||||||
|
price: Money.from_amount(rand(10) + 1),
|
||||||
|
valid_from: Time.zone.now.beginning_of_day,
|
||||||
|
valid_to: Time.zone.now + (rand(10) + 1).years,
|
||||||
|
duration: duration,
|
||||||
|
operation_category: operation_category,
|
||||||
|
zone: zone)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
generate_default_data
|
||||||
|
generate_random_data if with_random_data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :admin_user do
|
factory :admin_user do
|
||||||
username 'test'
|
username 'test'
|
||||||
email 'test@test.com'
|
sequence(:email) { |n| "test#{n}@test.com" }
|
||||||
password 'a' * AdminUser.min_password_length
|
password 'a' * AdminUser.min_password_length
|
||||||
password_confirmation { password }
|
password_confirmation { password }
|
||||||
country_code 'de'
|
country_code 'de'
|
||||||
|
|
37
spec/requests/epp/domain/update/status_spec.rb
Normal file
37
spec/requests/epp/domain/update/status_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:update' do
|
||||||
|
let(:request) { post '/epp/command/update', frame: request_xml }
|
||||||
|
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>
|
||||||
|
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
sign_in_to_epp_area
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when domain has both SERVER_DELETE_PROHIBITED and PENDING_UPDATE statuses' do
|
||||||
|
let!(:domain) { create(:domain,
|
||||||
|
name: 'test.com',
|
||||||
|
statuses: [DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||||
|
DomainStatus::PENDING_UPDATE])
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns PENDING_UPDATE as domain status' do
|
||||||
|
request
|
||||||
|
status = Nokogiri::XML(response.body).at_xpath('//domain:status',
|
||||||
|
domain: 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').content
|
||||||
|
expect(status).to eq(DomainStatus::PENDING_UPDATE)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue