mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Converted to use Rails Time.zone only to honor app time zone
This commit is contained in:
parent
a42136268f
commit
e1041da50f
16 changed files with 34 additions and 31 deletions
|
@ -29,7 +29,7 @@ class Certificate < ActiveRecord::Base
|
||||||
|
|
||||||
@cached_status = SIGNED
|
@cached_status = SIGNED
|
||||||
|
|
||||||
if parsed_crt.not_before > Time.now.utc && parsed_crt.not_after < Time.now.utc
|
if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc
|
||||||
@cached_status = EXPIRED
|
@cached_status = EXPIRED
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,9 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_orphans
|
def destroy_orphans
|
||||||
logger.info "#{Time.now.utc} - Destroying orphaned contacts\n"
|
logger.info "#{Time.zone.now.utc} - Destroying orphaned contacts\n"
|
||||||
count = find_orphans.destroy_all.count
|
count = find_orphans.destroy_all.count
|
||||||
logger.info "#{Time.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
|
logger.info "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Domain < ActiveRecord::Base
|
||||||
before_create :set_validity_dates
|
before_create :set_validity_dates
|
||||||
before_save :touch_always_version
|
before_save :touch_always_version
|
||||||
def touch_always_version
|
def touch_always_version
|
||||||
self.updated_at = Time.now
|
self.updated_at = Time.zone.now
|
||||||
end
|
end
|
||||||
after_save :manage_automatic_statuses
|
after_save :manage_automatic_statuses
|
||||||
after_save :update_whois_body
|
after_save :update_whois_body
|
||||||
|
@ -205,7 +205,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def set_validity_dates
|
def set_validity_dates
|
||||||
self.registered_at = Time.zone.now
|
self.registered_at = Time.zone.now
|
||||||
self.valid_from = Date.today
|
self.valid_from = Time.zone.now.to_date
|
||||||
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
at[:name] = frame.css('name').text if new_record?
|
at[:name] = frame.css('name').text if new_record?
|
||||||
at[:registrar_id] = current_user.registrar.try(:id)
|
at[:registrar_id] = current_user.registrar.try(:id)
|
||||||
at[:registered_at] = Time.now if new_record?
|
at[:registered_at] = Time.zone.now if new_record?
|
||||||
|
|
||||||
period = frame.css('period').text
|
period = frame.css('period').text
|
||||||
at[:period] = (period.to_i == 0) ? 1 : period.to_i
|
at[:period] = (period.to_i == 0) ? 1 : period.to_i
|
||||||
|
@ -593,7 +593,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
kr = keyrelays.build(
|
kr = keyrelays.build(
|
||||||
pa_date: Time.now,
|
pa_date: Time.zone.now,
|
||||||
key_data_flags: parsed_frame.css('flags').text,
|
key_data_flags: parsed_frame.css('flags').text,
|
||||||
key_data_protocol: parsed_frame.css('protocol').text,
|
key_data_protocol: parsed_frame.css('protocol').text,
|
||||||
key_data_alg: parsed_frame.css('alg').text,
|
key_data_alg: parsed_frame.css('alg').text,
|
||||||
|
@ -632,7 +632,7 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
def validate_exp_dates(cur_exp_date)
|
def validate_exp_dates(cur_exp_date)
|
||||||
begin
|
begin
|
||||||
return if cur_exp_date.to_date == valid_to
|
return if cur_exp_date.to_date == valid_to.to_date
|
||||||
rescue
|
rescue
|
||||||
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
|
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
|
||||||
return
|
return
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Keyrelay < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def status
|
def status
|
||||||
if Time.now > expiry
|
if Time.zone.now > expiry
|
||||||
return 'expired'
|
return 'expired'
|
||||||
else
|
else
|
||||||
return 'pending'
|
return 'pending'
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ZonefileSetting < ActiveRecord::Base
|
||||||
def self.generate_zonefile(origin)
|
def self.generate_zonefile(origin)
|
||||||
filename = "#{origin}.zone"
|
filename = "#{origin}.zone"
|
||||||
|
|
||||||
STDOUT << "#{Time.now.utc} - Generating zonefile #{filename}\n"
|
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
|
||||||
|
|
||||||
zf = ActiveRecord::Base.connection.execute(
|
zf = ActiveRecord::Base.connection.execute(
|
||||||
"select generate_zonefile('#{origin}')"
|
"select generate_zonefile('#{origin}')"
|
||||||
|
@ -20,7 +20,7 @@ class ZonefileSetting < ActiveRecord::Base
|
||||||
|
|
||||||
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
|
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
|
||||||
|
|
||||||
STDOUT << "#{Time.now.utc} - Successfully generated zonefile #{filename}\n"
|
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
xml.epp_head do
|
xml.epp_head do
|
||||||
xml.greeting do
|
xml.greeting do
|
||||||
xml.svID 'EPP server (EIS)'
|
xml.svID 'EPP server (EIS)'
|
||||||
xml.svDate Time.now.utc.iso8601
|
xml.svDate Time.zone.now.utc.iso8601
|
||||||
xml.svcMenu do
|
xml.svcMenu do
|
||||||
xml.version '1.0'
|
xml.version '1.0'
|
||||||
xml.lang 'en'
|
xml.lang 'en'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Be sure to restart your server when you modify settings.
|
# Be sure to restart your server when you modify settings.
|
||||||
|
|
||||||
app_name: .EE Registry
|
app_name: '.EE Registry'
|
||||||
zonefile_export_dir: 'export/zonefiles'
|
zonefile_export_dir: 'export/zonefiles'
|
||||||
|
|
||||||
# Contact epp will not accept org value by default
|
# Contact epp will not accept org value by default
|
||||||
|
@ -10,8 +10,8 @@ contact_org_enabled: 'false'
|
||||||
# You can use `rake secret` to generate a secure secret key.
|
# You can use `rake secret` to generate a secure secret key.
|
||||||
# Your secret key is used for verifying the integrity of signed cookies.
|
# Your secret key is used for verifying the integrity of signed cookies.
|
||||||
# If you change this key, all old signed cookies will become invalid!
|
# If you change this key, all old signed cookies will become invalid!
|
||||||
secret_key_base: please-change-it-you-can-generate-it-with-rake-secret
|
secret_key_base: 'please-change-it-you-can-generate-it-with-rake-secret'
|
||||||
devise_secret: please-change-it-you-can-generate-it-with-rake-secret
|
devise_secret: 'please-change-it-you-can-generate-it-with-rake-secret'
|
||||||
|
|
||||||
# Used by admin server, you can leave those empty for when running EPP server:
|
# Used by admin server, you can leave those empty for when running EPP server:
|
||||||
openssl_config_path: '/etc/ssl/openssl.cnf'
|
openssl_config_path: '/etc/ssl/openssl.cnf'
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Registry
|
||||||
|
|
||||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||||
# config.time_zone = 'Central Time (US & Canada)'
|
config.time_zone = 'UTC' # NB! It should be defined, otherwise ActiveRecord usese other class.
|
||||||
|
|
||||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||||
|
|
|
@ -17,7 +17,7 @@ class PaperSession
|
||||||
class << self
|
class << self
|
||||||
attr_writer :session
|
attr_writer :session
|
||||||
def session
|
def session
|
||||||
@session ||= Time.now.to_s(:db)
|
@session ||= Time.zone.now.to_s(:db)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace :import do
|
||||||
|
|
||||||
desc 'Import registrars'
|
desc 'Import registrars'
|
||||||
task registrars: :environment do
|
task registrars: :environment do
|
||||||
start = Time.now.to_f
|
start = Time.zone.now.to_f
|
||||||
puts '-----> Importing registrars...'
|
puts '-----> Importing registrars...'
|
||||||
|
|
||||||
registrars = []
|
registrars = []
|
||||||
|
@ -92,12 +92,12 @@ namespace :import do
|
||||||
|
|
||||||
Registrar.import registrars, validate: false
|
Registrar.import registrars, validate: false
|
||||||
|
|
||||||
puts "-----> Imported #{count} new registrars in #{(Time.now.to_f - start).round(2)} seconds"
|
puts "-----> Imported #{count} new registrars in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Import contacts'
|
desc 'Import contacts'
|
||||||
task contacts: :environment do
|
task contacts: :environment do
|
||||||
start = Time.now.to_f
|
start = Time.zone.now.to_f
|
||||||
puts '-----> Importing contacts...'
|
puts '-----> Importing contacts...'
|
||||||
|
|
||||||
# 1;"RC";"born number" # not used
|
# 1;"RC";"born number" # not used
|
||||||
|
@ -183,12 +183,12 @@ namespace :import do
|
||||||
end
|
end
|
||||||
|
|
||||||
Contact.import contact_columns, contacts, validate: false
|
Contact.import contact_columns, contacts, validate: false
|
||||||
puts "-----> Imported #{count} new contacts in #{(Time.now.to_f - start).round(2)} seconds"
|
puts "-----> Imported #{count} new contacts in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Import domains'
|
desc 'Import domains'
|
||||||
task domains: :environment do
|
task domains: :environment do
|
||||||
start = Time.now.to_f
|
start = Time.zone.now.to_f
|
||||||
puts '-----> Importing domains...'
|
puts '-----> Importing domains...'
|
||||||
|
|
||||||
domain_columns = %w(
|
domain_columns = %w(
|
||||||
|
@ -449,6 +449,6 @@ namespace :import do
|
||||||
x.save(validate: false)
|
x.save(validate: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "-----> Imported #{count} new domains in #{(Time.now.to_f - start).round(2)} seconds"
|
puts "-----> Imported #{count} new domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -140,7 +140,7 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
id.text.length.should == 8
|
id.text.length.should == 8
|
||||||
# 5 seconds for what-ever weird lag reasons might happen
|
# 5 seconds for what-ever weird lag reasons might happen
|
||||||
cr_date.text.to_time.should be_within(5).of(Time.now)
|
cr_date.text.to_time.should be_within(5).of(Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully saves custom code' do
|
it 'successfully saves custom code' do
|
||||||
|
|
|
@ -308,7 +308,7 @@ describe 'EPP Domain', epp: true do
|
||||||
response = epp_plain_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
response[:msg].should == 'Command completed successfully'
|
response[:msg].should == 'Command completed successfully'
|
||||||
response[:result_code].should == '1000'
|
response[:result_code].should == '1000'
|
||||||
Domain.first.valid_to.should == Date.today + 1.year
|
Domain.first.valid_to.should == 1.year.since.to_date
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a domain with invalid period' do
|
it 'does not create a domain with invalid period' do
|
||||||
|
@ -1682,7 +1682,7 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
### RENEW ###
|
### RENEW ###
|
||||||
it 'renews a domain' do
|
it 'renews a domain' do
|
||||||
exp_date = (Date.today + 1.year)
|
exp_date = 1.year.since.to_date
|
||||||
xml = @epp_xml.domain.renew(
|
xml = @epp_xml.domain.renew(
|
||||||
name: { value: domain.name },
|
name: { value: domain.name },
|
||||||
curExpDate: { value: exp_date.to_s },
|
curExpDate: { value: exp_date.to_s },
|
||||||
|
@ -1690,6 +1690,9 @@ describe 'EPP Domain', epp: true do
|
||||||
)
|
)
|
||||||
|
|
||||||
response = epp_plain_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
|
response[:results][0][:msg].should == 'Command completed successfully'
|
||||||
|
response[:results][0][:result_code].should == '1000'
|
||||||
|
|
||||||
ex_date = response[:parsed].css('renData exDate').text
|
ex_date = response[:parsed].css('renData exDate').text
|
||||||
name = response[:parsed].css('renData name').text
|
name = response[:parsed].css('renData name').text
|
||||||
ex_date.should == "#{(exp_date + 1.year)} 00:00:00 UTC"
|
ex_date.should == "#{(exp_date + 1.year)} 00:00:00 UTC"
|
||||||
|
@ -1709,7 +1712,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an error when period is invalid' do
|
it 'returns an error when period is invalid' do
|
||||||
exp_date = (Date.today + 1.year)
|
exp_date = (1.year.since.to_date)
|
||||||
|
|
||||||
xml = @epp_xml.domain.renew(
|
xml = @epp_xml.domain.renew(
|
||||||
name: { value: domain.name },
|
name: { value: domain.name },
|
||||||
|
@ -1718,8 +1721,8 @@ describe 'EPP Domain', epp: true do
|
||||||
)
|
)
|
||||||
|
|
||||||
response = epp_plain_request(xml, :xml)
|
response = epp_plain_request(xml, :xml)
|
||||||
response[:results][0][:result_code].should == '2004'
|
|
||||||
response[:results][0][:msg].should == 'Period must add up to 1, 2 or 3 years [period]'
|
response[:results][0][:msg].should == 'Period must add up to 1, 2 or 3 years [period]'
|
||||||
|
response[:results][0][:result_code].should == '2004'
|
||||||
response[:results][0][:value].should == '4'
|
response[:results][0][:value].should == '4'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:keyrelay) do
|
Fabricator(:keyrelay) do
|
||||||
pa_date { DateTime.now }
|
pa_date { Time.zone.now }
|
||||||
expiry_relative 'P1W'
|
expiry_relative 'P1W'
|
||||||
key_data_public_key 'abc'
|
key_data_public_key 'abc'
|
||||||
key_data_flags 0
|
key_data_flags 0
|
||||||
|
|
|
@ -62,7 +62,7 @@ describe Keyrelay do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is in expired status' do
|
it 'is in expired status' do
|
||||||
kr = Fabricate(:keyrelay, pa_date: DateTime.now - 2.weeks)
|
kr = Fabricate(:keyrelay, pa_date: Time.zone.now - 2.weeks)
|
||||||
expect(kr.status).to eq('expired')
|
expect(kr.status).to eq('expired')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class EppDoc
|
||||||
|
|
||||||
def start(example_count)
|
def start(example_count)
|
||||||
@output.puts '# EPP REQUEST - RESPONSE EXAMPLES'
|
@output.puts '# EPP REQUEST - RESPONSE EXAMPLES'
|
||||||
@output.puts "GENERATED AT: #{Time.now} "
|
@output.puts "GENERATED AT: #{Time.zone.now} "
|
||||||
@output.puts "EXAMPLE COUNT: #{example_count.count} "
|
@output.puts "EXAMPLE COUNT: #{example_count.count} "
|
||||||
@output.puts "\n---\n\n"
|
@output.puts "\n---\n\n"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue