Rubocop autocorrect

This commit is contained in:
Martin Lensment 2014-08-25 14:14:25 +03:00
parent f8c48a7456
commit 6c5c0b38c8
59 changed files with 533 additions and 546 deletions

View file

@ -1,11 +1,20 @@
Style/LineLength: AllCops:
RunRailsCops: true
Metrics/LineLength:
Max: 120 Max: 120
Documentation: Documentation:
Enabled: false Enabled: false
Style/CyclomaticComplexity:
Severity: warning
Style/Semicolon: Style/Semicolon:
AllowAsExpressionSeparator: true AllowAsExpressionSeparator: true
Style/AndOr:
Enabled: false
Style/BracesAroundHashParameters:
Enabled: false
Style/IndentHash:
Enabled: false

View file

@ -61,7 +61,7 @@ module Epp::Common
end end
def has_attribute(ph, path) def has_attribute(ph, path)
path.inject(ph) do |location, key| path.reduce(ph) do |location, key|
location.respond_to?(:keys) ? location[key] : nil location.respond_to?(:keys) ? location[key] : nil
end end
end end

View file

@ -1,7 +1,7 @@
module Shared::UserStamper module Shared::UserStamper
extend ActiveSupport::Concern extend ActiveSupport::Concern
def stamp obj def stamp(obj)
return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id) return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id)
if obj.new_record? if obj.new_record?
@ -10,6 +10,6 @@ module Shared::UserStamper
obj.updated_by_id = current_epp_user.id obj.updated_by_id = current_epp_user.id
end end
return true true
end end
end end

View file

@ -5,6 +5,7 @@ class Epp::CommandsController < ApplicationController
include Shared::UserStamper include Shared::UserStamper
private private
def create def create
send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}") send("create_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
end end

View file

@ -2,6 +2,7 @@ class Epp::SessionsController < ApplicationController
include Epp::Common include Epp::Common
private private
def hello def hello
render 'greeting' render 'greeting'
end end

View file

@ -16,6 +16,7 @@ class SettingGroupsController < ApplicationController
end end
private private
def set_setting_group def set_setting_group
@setting_group = SettingGroup.find(params[:id]) @setting_group = SettingGroup.find(params[:id])
end end

View file

@ -41,16 +41,17 @@ module Epp::ContactsHelper
end end
## HELPER METHODS ## HELPER METHODS
private private
## CREATE ## CREATE
def validate_contact_create_request def validate_contact_create_request
@ph = params_hash['epp']['command']['create']['create'] @ph = params_hash['epp']['command']['create']['create']
xml_attrs_present?(@ph, [['id'], xml_attrs_present?(@ph, [['id'],
['authInfo', 'pw'], %w(authInfo pw),
['postalInfo', 'name'], %w(postalInfo name),
['postalInfo', 'addr', 'city'], %w(postalInfo addr city),
['postalInfo', 'addr', 'cc']]) %w(postalInfo addr cc)])
end end
## UPDATE ## UPDATE
@ -91,10 +92,10 @@ module Epp::ContactsHelper
pw = @ph.try(:[], :authInfo).try(:[], :pw) || @ph.try(:[], :chg).try(:[], :authInfo).try(:[], :pw) || [] pw = @ph.try(:[], :authInfo).try(:[], :pw) || @ph.try(:[], :chg).try(:[], :authInfo).try(:[], :pw) || []
id = @ph[:id] id = @ph[:id]
return true if ( !find_contact.nil? && find_contact.auth_info_matches(pw) ) return true if !find_contact.nil? && find_contact.auth_info_matches(pw)
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error'), value: { obj: 'pw', val: pw } } epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error'), value: { obj: 'pw', val: pw } }
return false false
end end
def contact_and_address_attributes(type = :create) def contact_and_address_attributes(type = :create)
@ -118,6 +119,6 @@ module Epp::ContactsHelper
return nil unless result return nil unless result
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) } Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }
return nil nil
end end
end end

View file

@ -48,6 +48,7 @@ module Epp::DomainsHelper
end end
### HELPER METHODS ### ### HELPER METHODS ###
private private
## CREATE ## CREATE

View file

@ -3,7 +3,7 @@ class Address < ActiveRecord::Base
belongs_to :country belongs_to :country
class << self class << self
def extract_attributes ah, type=:create def extract_attributes(ah, _type = :create)
address_hash = {} address_hash = {}
address_hash = ({ address_hash = ({
country_id: Country.find_by(iso: ah[:cc]).try(:id), country_id: Country.find_by(iso: ah[:cc]).try(:id),
@ -14,7 +14,7 @@ class Address < ActiveRecord::Base
zip: ah[:pc] zip: ah[:pc]
}) if ah.is_a?(Hash) }) if ah.is_a?(Hash)
address_hash.delete_if { |k, v| v.nil? } address_hash.delete_if { |_k, v| v.nil? }
end end
end end
end end

View file

@ -27,15 +27,15 @@ class Contact < ActiveRecord::Base
IDENT_TYPE_ICO = 'ico' IDENT_TYPE_ICO = 'ico'
IDENT_TYPES = [ IDENT_TYPES = [
IDENT_TYPE_ICO, # Company registry code (or similar) IDENT_TYPE_ICO, # Company registry code (or similar)
"op", #Estonian ID 'op', # Estonian ID
"passport", #Passport number 'passport', # Passport number
"birthday" #Birthday date 'birthday' # Birthday date
] ]
def ident_must_be_valid def ident_must_be_valid
# TODO Ident can also be passport number or company registry code. # TODO Ident can also be passport number or company registry code.
# so have to make changes to validations (and doc/schema) accordingly # so have to make changes to validations (and doc/schema) accordingly
return true unless ident.present? && ident_type.present? && ident_type == "op" return true unless ident.present? && ident_type.present? && ident_type == 'op'
code = Isikukood.new(ident) code = Isikukood.new(ident)
errors.add(:ident, 'bad format') unless code.valid? errors.add(:ident, 'bad format') unless code.valid?
end end
@ -56,9 +56,9 @@ class Contact < ActiveRecord::Base
updated_by ? updated_by.username : nil updated_by ? updated_by.username : nil
end end
def auth_info_matches pw def auth_info_matches(pw)
return true if auth_info == pw return true if auth_info == pw
return false false
end end
# Find a way to use self.domains with contact # Find a way to use self.domains with contact
@ -68,7 +68,7 @@ class Contact < ActiveRecord::Base
def relations_with_domain? def relations_with_domain?
return true if domain_contacts.present? || domains_owned.present? return true if domain_contacts.present? || domains_owned.present?
return false false
end end
# should use only in transaction # should use only in transaction
@ -100,10 +100,7 @@ class Contact < ActiveRecord::Base
end end
class << self class << self
def extract_attributes(ph, type = :create)
def extract_attributes ph, type=:create
contact_hash = { contact_hash = {
phone: ph[:voice], phone: ph[:voice],
ident: ph[:ident], ident: ph[:ident],
@ -117,7 +114,7 @@ class Contact < ActiveRecord::Base
contact_hash[:code] = ph[:id] if type == :create contact_hash[:code] = ph[:id] if type == :create
contact_hash.delete_if { |k, v| v.nil? } contact_hash.delete_if { |_k, v| v.nil? }
end end
def check_availability(codes) def check_availability(codes)
@ -141,6 +138,4 @@ class Contact < ActiveRecord::Base
def clean_up_address def clean_up_address
address.destroy if address address.destroy if address
end end
end end

View file

@ -1,3 +1,2 @@
class Country < ActiveRecord::Base class Country < ActiveRecord::Base
end end

View file

@ -15,13 +15,13 @@ class Domain < ActiveRecord::Base
has_many :domain_contacts has_many :domain_contacts
has_many :tech_contacts, -> { has_many :tech_contacts, -> do
where(domain_contacts: { contact_type: DomainContact::TECH }) where(domain_contacts: { contact_type: DomainContact::TECH })
}, through: :domain_contacts, source: :contact end, through: :domain_contacts, source: :contact
has_many :admin_contacts, -> { has_many :admin_contacts, -> do
where(domain_contacts: { contact_type: DomainContact::ADMIN }) where(domain_contacts: { contact_type: DomainContact::ADMIN })
}, through: :domain_contacts, source: :contact end, through: :domain_contacts, source: :contact
has_and_belongs_to_many :nameservers has_and_belongs_to_many :nameservers
@ -123,14 +123,14 @@ class Domain < ActiveRecord::Base
def attach_nameservers(ns_list) def attach_nameservers(ns_list)
ns_list.each do |ns_attrs| ns_list.each do |ns_attrs|
self.nameservers.build(ns_attrs) nameservers.build(ns_attrs)
end end
end end
def attach_statuses(status_list) def attach_statuses(status_list)
status_list.each do |x| status_list.each do |x|
setting = SettingGroup.domain_statuses.settings.find_by(value: x[:value]) setting = SettingGroup.domain_statuses.settings.find_by(value: x[:value])
self.domain_statuses.build( domain_statuses.build(
setting: setting, setting: setting,
description: x[:description] description: x[:description]
) )
@ -139,7 +139,7 @@ class Domain < ActiveRecord::Base
def detach_contacts(contact_list) def detach_contacts(contact_list)
to_delete = [] to_delete = []
contact_list.each do |k, v| contact_list.each do |_k, v|
v.each do |x| v.each do |x|
contact = domain_contacts.joins(:contact).where(contacts: { code: x[:contact] }) contact = domain_contacts.joins(:contact).where(contacts: { code: x[:contact] })
if contact.blank? if contact.blank?
@ -154,13 +154,13 @@ class Domain < ActiveRecord::Base
end end
end end
self.domain_contacts.delete(to_delete) domain_contacts.delete(to_delete)
end end
def detach_nameservers(ns_list) def detach_nameservers(ns_list)
to_delete = [] to_delete = []
ns_list.each do |ns_attrs| ns_list.each do |ns_attrs|
nameserver = self.nameservers.where(ns_attrs) nameserver = nameservers.where(ns_attrs)
if nameserver.blank? if nameserver.blank?
errors.add(:nameservers, { errors.add(:nameservers, {
obj: 'hostObj', obj: 'hostObj',
@ -172,7 +172,7 @@ class Domain < ActiveRecord::Base
end end
end end
self.nameservers.delete(to_delete) nameservers.delete(to_delete)
end end
def detach_statuses(status_list) def detach_statuses(status_list)
@ -190,7 +190,7 @@ class Domain < ActiveRecord::Base
end end
end end
self.domain_statuses.delete(to_delete) domain_statuses.delete(to_delete)
end end
### RENEW ### ### RENEW ###
@ -202,7 +202,7 @@ class Domain < ActiveRecord::Base
p = self.class.convert_period_to_time(period, unit) p = self.class.convert_period_to_time(period, unit)
self.valid_to = self.valid_to + p self.valid_to = valid_to + p
self.period = period self.period = period
self.period_unit = unit self.period_unit = unit
save save
@ -226,11 +226,11 @@ class Domain < ActiveRecord::Base
def validate_period def validate_period
return unless period.present? return unless period.present?
if period_unit == 'd' if period_unit == 'd'
valid_values = ['365', '366', '710', '712', '1065', '1068'] valid_values = %w(365 366 710 712 1065 1068)
elsif period_unit == 'm' elsif period_unit == 'm'
valid_values = ['12', '24', '36'] valid_values = %w(12 24 36)
else else
valid_values = ['1', '2', '3'] valid_values = %w(1 2 3)
end end
errors.add(:period, :out_of_range) unless valid_values.include?(period.to_s) errors.add(:period, :out_of_range) unless valid_values.include?(period.to_s)
@ -351,12 +351,12 @@ class Domain < ActiveRecord::Base
res = [] res = []
domains.each do |x| domains.each do |x|
if !DomainNameValidator.validate_format(x) unless DomainNameValidator.validate_format(x)
res << { name: x, avail: 0, reason: 'invalid format' } res << { name: x, avail: 0, reason: 'invalid format' }
next next
end end
if !DomainNameValidator.validate_reservation(x) unless DomainNameValidator.validate_reservation(x)
res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') } res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') }
next next
end end

View file

@ -1,3 +1,2 @@
class ReservedDomain < ActiveRecord::Base class ReservedDomain < ActiveRecord::Base
end end

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
load File.expand_path("../spring", __FILE__) load File.expand_path('../spring', __FILE__)
rescue LoadError rescue LoadError
end end
APP_PATH = File.expand_path('../../config/application', __FILE__) APP_PATH = File.expand_path('../../config/application', __FILE__)

View file

@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
load File.expand_path("../spring", __FILE__) load File.expand_path('../spring', __FILE__)
rescue LoadError rescue LoadError
end end
require_relative '../config/boot' require_relative '../config/boot'

View file

@ -7,7 +7,7 @@
# #
require 'pathname' require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath) Pathname.new(__FILE__).realpath)
require 'rubygems' require 'rubygems'

View file

@ -4,15 +4,15 @@
# It gets overwritten when you run the `spring binstub` command # It gets overwritten when you run the `spring binstub` command
unless defined?(Spring) unless defined?(Spring)
require "rubygems" require 'rubygems'
require "bundler" require 'bundler'
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) ENV['GEM_PATH'] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
ENV["GEM_HOME"] = "" ENV['GEM_HOME'] = ''
Gem.paths = ENV Gem.paths = ENV
gem "spring", match[1] gem 'spring', match[1]
require "spring/binstub" require 'spring/binstub'
end end
end end

View file

@ -1,12 +1,12 @@
require File.expand_path('../boot', __FILE__) require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want: # Pick the frameworks you want:
require "active_model/railtie" require 'active_model/railtie'
require "active_record/railtie" require 'active_record/railtie'
require "action_controller/railtie" require 'action_controller/railtie'
require "action_mailer/railtie" require 'action_mailer/railtie'
require "action_view/railtie" require 'action_view/railtie'
require "sprockets/railtie" require 'sprockets/railtie'
# require "rails/test_unit/railtie" # require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems

View file

@ -1 +1 @@
Dir[File.join(Rails.root, "lib", "ext", "*.rb")].each {|x| require x } Dir[File.join(Rails.root, 'lib', 'ext', '*.rb')].each { |x| require x }

View file

@ -6,7 +6,7 @@ class CreateEppSessions < ActiveRecord::Migration
t.timestamps t.timestamps
end end
add_index :epp_sessions, :session_id, :unique => true add_index :epp_sessions, :session_id, unique: true
add_index :epp_sessions, :updated_at add_index :epp_sessions, :updated_at
end end
end end

View file

@ -4,7 +4,7 @@ class PopulateSettings < ActiveRecord::Migration
code: 'domain_validation', code: 'domain_validation',
settings: [ settings: [
Setting.create(code: 'ns_min_count', value: 1), Setting.create(code: 'ns_min_count', value: 1),
Setting.create(code: 'ns_max_count', value: 13), Setting.create(code: 'ns_max_count', value: 13)
] ]
) )
end end

View file

@ -11,181 +11,181 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140819103517) do ActiveRecord::Schema.define(version: 20_140_819_103_517) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension 'plpgsql'
create_table "addresses", force: true do |t| create_table 'addresses', force: true do |t|
t.integer "contact_id" t.integer 'contact_id'
t.integer "country_id" t.integer 'country_id'
t.string "city" t.string 'city'
t.string "street" t.string 'street'
t.string "zip" t.string 'zip'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.string "street2" t.string 'street2'
t.string "street3" t.string 'street3'
end end
create_table "contacts", force: true do |t| create_table 'contacts', force: true do |t|
t.string "code" t.string 'code'
t.string "name" t.string 'name'
t.string "type" t.string 'type'
t.string "reg_no" t.string 'reg_no'
t.string "phone" t.string 'phone'
t.string "email" t.string 'email'
t.string "fax" t.string 'fax'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.string "ident" t.string 'ident'
t.string "ident_type" t.string 'ident_type'
t.string "org_name" t.string 'org_name'
t.integer "created_by_id" t.integer 'created_by_id'
t.integer "updated_by_id" t.integer 'updated_by_id'
t.string "auth_info" t.string 'auth_info'
end end
create_table "countries", force: true do |t| create_table 'countries', force: true do |t|
t.string "iso" t.string 'iso'
t.string "name" t.string 'name'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "domain_contacts", force: true do |t| create_table 'domain_contacts', force: true do |t|
t.integer "contact_id" t.integer 'contact_id'
t.integer "domain_id" t.integer 'domain_id'
t.string "contact_type" t.string 'contact_type'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "domain_statuses", force: true do |t| create_table 'domain_statuses', force: true do |t|
t.integer "domain_id" t.integer 'domain_id'
t.integer "setting_id" t.integer 'setting_id'
t.string "description" t.string 'description'
end end
create_table "domains", force: true do |t| create_table 'domains', force: true do |t|
t.string "name" t.string 'name'
t.integer "registrar_id" t.integer 'registrar_id'
t.datetime "registered_at" t.datetime 'registered_at'
t.string "status" t.string 'status'
t.datetime "valid_from" t.datetime 'valid_from'
t.datetime "valid_to" t.datetime 'valid_to'
t.integer "owner_contact_id" t.integer 'owner_contact_id'
t.integer "admin_contact_id" t.integer 'admin_contact_id'
t.integer "technical_contact_id" t.integer 'technical_contact_id'
t.integer "ns_set_id" t.integer 'ns_set_id'
t.string "auth_info" t.string 'auth_info'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.string "name_dirty" t.string 'name_dirty'
t.string "name_puny" t.string 'name_puny'
t.integer "period" t.integer 'period'
t.string "period_unit", limit: 1 t.string 'period_unit', limit: 1
end end
create_table "domains_nameservers", force: true do |t| create_table 'domains_nameservers', force: true do |t|
t.integer "domain_id" t.integer 'domain_id'
t.integer "nameserver_id" t.integer 'nameserver_id'
end end
create_table "epp_sessions", force: true do |t| create_table 'epp_sessions', force: true do |t|
t.string "session_id" t.string 'session_id'
t.text "data" t.text 'data'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
add_index "epp_sessions", ["session_id"], name: "index_epp_sessions_on_session_id", unique: true, using: :btree add_index 'epp_sessions', ['session_id'], name: 'index_epp_sessions_on_session_id', unique: true, using: :btree
add_index "epp_sessions", ["updated_at"], name: "index_epp_sessions_on_updated_at", using: :btree add_index 'epp_sessions', ['updated_at'], name: 'index_epp_sessions_on_updated_at', using: :btree
create_table "epp_users", force: true do |t| create_table 'epp_users', force: true do |t|
t.integer "registrar_id" t.integer 'registrar_id'
t.string "username" t.string 'username'
t.string "password" t.string 'password'
t.boolean "active", default: false t.boolean 'active', default: false
t.text "csr" t.text 'csr'
t.text "crt" t.text 'crt'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "nameservers", force: true do |t| create_table 'nameservers', force: true do |t|
t.string "hostname" t.string 'hostname'
t.string "ipv4" t.string 'ipv4'
t.integer "ns_set_id" t.integer 'ns_set_id'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.string "ipv6" t.string 'ipv6'
end end
create_table "nameservers_ns_sets", force: true do |t| create_table 'nameservers_ns_sets', force: true do |t|
t.integer "nameserver_id" t.integer 'nameserver_id'
t.integer "ns_set_id" t.integer 'ns_set_id'
end end
create_table "ns_sets", force: true do |t| create_table 'ns_sets', force: true do |t|
t.string "code" t.string 'code'
t.integer "registrar_id" t.integer 'registrar_id'
t.string "auth_info" t.string 'auth_info'
t.string "report_level" t.string 'report_level'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "registrars", force: true do |t| create_table 'registrars', force: true do |t|
t.string "name" t.string 'name'
t.string "reg_no" t.string 'reg_no'
t.string "vat_no" t.string 'vat_no'
t.string "address" t.string 'address'
t.integer "country_id" t.integer 'country_id'
t.string "billing_address" t.string 'billing_address'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "reserved_domains", force: true do |t| create_table 'reserved_domains', force: true do |t|
t.string "name" t.string 'name'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "rights", force: true do |t| create_table 'rights', force: true do |t|
t.string "code" t.string 'code'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "rights_roles", force: true do |t| create_table 'rights_roles', force: true do |t|
t.integer "right_id" t.integer 'right_id'
t.integer "role_id" t.integer 'role_id'
end end
create_table "roles", force: true do |t| create_table 'roles', force: true do |t|
t.string "name" t.string 'name'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
create_table "setting_groups", force: true do |t| create_table 'setting_groups', force: true do |t|
t.string "code" t.string 'code'
end end
create_table "settings", force: true do |t| create_table 'settings', force: true do |t|
t.integer "setting_group_id" t.integer 'setting_group_id'
t.string "code" t.string 'code'
t.string "value" t.string 'value'
end end
create_table "users", force: true do |t| create_table 'users', force: true do |t|
t.string "username" t.string 'username'
t.string "password" t.string 'password'
t.integer "role_id" t.integer 'role_id'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
end end

View file

@ -3,7 +3,7 @@ require 'builder'
class Builder::XmlMarkup class Builder::XmlMarkup
def epp_head def epp_head
self.instruct! self.instruct!
self.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
yield yield
end end
end end

View file

@ -13,7 +13,7 @@ end
desc 'Run all but EPP specs' desc 'Run all but EPP specs'
RSpec::Core::RakeTask.new('test:other') do |t| RSpec::Core::RakeTask.new('test:other') do |t|
t.rspec_opts = "--tag ~epp" t.rspec_opts = '--tag ~epp'
end end
Rake::Task[:default].prerequisites.clear Rake::Task[:default].prerequisites.clear

View file

@ -4,13 +4,13 @@ describe 'EPP Contact', epp: true do
let(:server) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) } let(:server) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
context 'with valid user' do context 'with valid user' do
before(:each) { before(:each) do
Fabricate(:epp_user) Fabricate(:epp_user)
Fabricate(:domain_validation_setting_group) Fabricate(:domain_validation_setting_group)
} end
context 'create command' do context 'create command' do
it "fails if request is invalid" do it 'fails if request is invalid' do
response = epp_request(contact_create_xml({ authInfo: [false], addr: { cc: false, city: false } }), :xml) response = epp_request(contact_create_xml({ authInfo: [false], addr: { cc: false, city: false } }), :xml)
expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:result_code]).to eq('2003')
@ -69,9 +69,8 @@ describe 'EPP Contact', epp: true do
end end
end end
context 'update command' do context 'update command' do
it "fails if request is invalid" do it 'fails if request is invalid' do
response = epp_request('contacts/update_missing_attr.xml') response = epp_request('contacts/update_missing_attr.xml')
# response = epp_request(contact_update_xml( {id: false} ), :xml) # response = epp_request(contact_update_xml( {id: false} ), :xml)
@ -80,7 +79,6 @@ describe 'EPP Contact', epp: true do
expect(response[:results].count).to eq 1 expect(response[:results].count).to eq 1
end end
it 'fails with wrong authentication info' do it 'fails with wrong authentication info' do
Fabricate(:contact, code: 'sh8013', auth_info: 'secure_password') Fabricate(:contact, code: 'sh8013', auth_info: 'secure_password')
@ -126,7 +124,7 @@ describe 'EPP Contact', epp: true do
end end
context 'delete command' do context 'delete command' do
it "fails if request is invalid" do it 'fails if request is invalid' do
response = epp_request('contacts/delete_missing_attr.xml') response = epp_request('contacts/delete_missing_attr.xml')
expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:result_code]).to eq('2003')
@ -135,7 +133,7 @@ describe 'EPP Contact', epp: true do
end end
it 'deletes contact' do it 'deletes contact' do
Fabricate(:contact, code: "dwa1234") Fabricate(:contact, code: 'dwa1234')
response = epp_request('contacts/delete.xml') response = epp_request('contacts/delete.xml')
expect(response[:result_code]).to eq('1000') expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully') expect(response[:msg]).to eq('Command completed successfully')
@ -163,9 +161,8 @@ describe 'EPP Contact', epp: true do
end end
end end
context 'check command' do context 'check command' do
it "fails if request is invalid" do it 'fails if request is invalid' do
response = epp_request(contact_check_xml(ids: [false]), :xml) response = epp_request(contact_check_xml(ids: [false]), :xml)
expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:result_code]).to eq('2003')
@ -191,7 +188,7 @@ describe 'EPP Contact', epp: true do
end end
context 'info command' do context 'info command' do
it "fails if request invalid" do it 'fails if request invalid' do
response = epp_request('contacts/delete_missing_attr.xml') response = epp_request('contacts/delete_missing_attr.xml')
expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:result_code]).to eq('2003')
@ -207,7 +204,7 @@ describe 'EPP Contact', epp: true do
end end
it 'returns info about contact' do it 'returns info about contact' do
Fabricate(:contact, name: "Johnny Awesome", created_by_id: '1', code: 'info-4444', auth_info: '2fooBAR') Fabricate(:contact, name: 'Johnny Awesome', created_by_id: '1', code: 'info-4444', auth_info: '2fooBAR')
Fabricate(:address) Fabricate(:address)
response = epp_request('contacts/info.xml') response = epp_request('contacts/info.xml')
@ -220,7 +217,7 @@ describe 'EPP Contact', epp: true do
end end
it 'doesn\'t display unassociated object' do it 'doesn\'t display unassociated object' do
Fabricate(:contact, name:"Johnny Awesome", code: 'info-4444') Fabricate(:contact, name: 'Johnny Awesome', code: 'info-4444')
response = epp_request('contacts/info.xml') response = epp_request('contacts/info.xml')
expect(response[:result_code]).to eq('2201') expect(response[:result_code]).to eq('2201')

View file

@ -30,11 +30,11 @@ describe 'EPP Domain', epp: true do
end end
context 'with citizen as an owner' do context 'with citizen as an owner' do
before(:each) { before(:each) do
Fabricate(:contact, code: 'jd1234') Fabricate(:contact, code: 'jd1234')
Fabricate(:contact, code: 'sh8013') Fabricate(:contact, code: 'sh8013')
Fabricate(:contact, code: 'sh801333') Fabricate(:contact, code: 'sh801333')
} end
it 'creates a domain' do it 'creates a domain' do
response = epp_request(domain_create_xml, :xml) response = epp_request(domain_create_xml, :xml)
@ -144,11 +144,11 @@ describe 'EPP Domain', epp: true do
end end
context 'with juridical persion as an owner' do context 'with juridical persion as an owner' do
before(:each) { before(:each) do
Fabricate(:contact, code: 'jd1234', ident_type: 'ico') Fabricate(:contact, code: 'jd1234', ident_type: 'ico')
Fabricate(:contact, code: 'sh8013') Fabricate(:contact, code: 'sh8013')
Fabricate(:contact, code: 'sh801333') Fabricate(:contact, code: 'sh801333')
} end
it 'creates a domain with contacts' do it 'creates a domain with contacts' do
xml = domain_create_xml(contacts: [{ contact_value: 'sh8013', contact_type: 'admin' }]) xml = domain_create_xml(contacts: [{ contact_value: 'sh8013', contact_type: 'admin' }])
@ -217,12 +217,12 @@ describe 'EPP Domain', epp: true do
expect(inf_data.css('name').text).to eq('example.ee') expect(inf_data.css('name').text).to eq('example.ee')
expect(inf_data.css('registrant').text).to eq(d.owner_contact_code) expect(inf_data.css('registrant').text).to eq(d.owner_contact_code)
admin_contacts_from_request = inf_data.css('contact[type="admin"]').collect{|x| x.text } admin_contacts_from_request = inf_data.css('contact[type="admin"]').map { |x| x.text }
admin_contacts_existing = d.admin_contacts.pluck(:code) admin_contacts_existing = d.admin_contacts.pluck(:code)
expect(admin_contacts_from_request).to eq(admin_contacts_existing) expect(admin_contacts_from_request).to eq(admin_contacts_existing)
hosts_from_request = inf_data.css('hostObj').collect{|x| x.text } hosts_from_request = inf_data.css('hostObj').map { |x| x.text }
hosts_existing = d.nameservers.pluck(:hostname) hosts_existing = d.nameservers.pluck(:hostname)
expect(hosts_from_request).to eq(hosts_existing) expect(hosts_from_request).to eq(hosts_existing)

View file

@ -124,7 +124,6 @@ describe 'EPP Helper', epp: true do
</epp> </epp>
').to_s.squish ').to_s.squish
generated = Nokogiri::XML(domain_info_xml).to_s.squish generated = Nokogiri::XML(domain_info_xml).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
@ -145,7 +144,6 @@ describe 'EPP Helper', epp: true do
</epp> </epp>
').to_s.squish ').to_s.squish
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub', pw: 'b3rafsla')).to_s.squish generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub', pw: 'b3rafsla')).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
end end
@ -165,7 +163,6 @@ describe 'EPP Helper', epp: true do
</epp> </epp>
').to_s.squish ').to_s.squish
generated = Nokogiri::XML(domain_check_xml).to_s.squish generated = Nokogiri::XML(domain_check_xml).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
@ -185,7 +182,6 @@ describe 'EPP Helper', epp: true do
</epp> </epp>
').to_s.squish ').to_s.squish
generated = Nokogiri::XML(domain_check_xml(names: ['example.ee', 'example2.ee', 'example3.ee'])).to_s.squish generated = Nokogiri::XML(domain_check_xml(names: ['example.ee', 'example2.ee', 'example3.ee'])).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
end end
@ -207,7 +203,6 @@ describe 'EPP Helper', epp: true do
</epp> </epp>
').to_s.squish ').to_s.squish
generated = Nokogiri::XML(domain_renew_xml).to_s.squish generated = Nokogiri::XML(domain_renew_xml).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
@ -227,7 +222,6 @@ describe 'EPP Helper', epp: true do
</epp> </epp>
').to_s.squish ').to_s.squish
generated = Nokogiri::XML(domain_renew_xml(name: 'one.ee', curExpDate: '2009-11-15', period_value: '365', period_unit: 'd')).to_s.squish generated = Nokogiri::XML(domain_renew_xml(name: 'one.ee', curExpDate: '2009-11-15', period_value: '365', period_unit: 'd')).to_s.squish
expect(generated).to eq(expected) expect(generated).to eq(expected)
end end

View file

@ -1,23 +1,29 @@
Fabricator(:setting_group) do Fabricator(:setting_group) do
code 'domain_validation' code 'domain_validation'
settings { [ settings do
[
Fabricate(:setting, code: 'ns_min_count', value: 1), Fabricate(:setting, code: 'ns_min_count', value: 1),
Fabricate(:setting, code: 'ns_max_count', value: 13) Fabricate(:setting, code: 'ns_max_count', value: 13)
]} ]
end
end end
Fabricator(:domain_validation_setting_group, from: :setting_group) do Fabricator(:domain_validation_setting_group, from: :setting_group) do
code 'domain_validation' code 'domain_validation'
settings { [ settings do
[
Fabricate(:setting, code: 'ns_min_count', value: 1), Fabricate(:setting, code: 'ns_min_count', value: 1),
Fabricate(:setting, code: 'ns_max_count', value: 13) Fabricate(:setting, code: 'ns_max_count', value: 13)
]} ]
end
end end
Fabricator(:domain_statuses_setting_group, from: :setting_group) do Fabricator(:domain_statuses_setting_group, from: :setting_group) do
code 'domain_statuses' code 'domain_statuses'
settings { [ settings do
[
Fabricate(:setting, code: 'client_hold', value: 'clientHold'), Fabricate(:setting, code: 'client_hold', value: 'clientHold'),
Fabricate(:setting, code: 'client_update_prohibited', value: 'clientUpdateProhibited') Fabricate(:setting, code: 'client_update_prohibited', value: 'clientUpdateProhibited')
]} ]
end
end end

View file

@ -1,15 +1,14 @@
require "rails_helper" require 'rails_helper'
describe Address do describe Address do
it { should belong_to(:contact) } it { should belong_to(:contact) }
it { should belong_to(:country) } it { should belong_to(:country) }
end end
describe Address, '.extract_params' do describe Address, '.extract_params' do
it 'returns params hash'do it 'returns params hash'do
Fabricate(:country, iso: 'EE') Fabricate(:country, iso: 'EE')
ph = { postalInfo: { name: "fred", addr: { cc: 'EE', city: 'Village', street: [ 'street1', 'street2' ] } } } ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
expect(Address.extract_attributes(ph[:postalInfo][:addr])).to eq({ expect(Address.extract_attributes(ph[:postalInfo][:addr])).to eq({
city: 'Village', city: 'Village',
country_id: 1, country_id: 1,
@ -18,5 +17,3 @@ describe Address, '.extract_params' do
}) })
end end
end end

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Contact do describe Contact do
it { should have_one(:address) } it { should have_one(:address) }
@ -7,12 +7,12 @@ describe Contact do
before(:each) { @contact = Fabricate(:contact) } before(:each) { @contact = Fabricate(:contact) }
it 'phone should return false' do it 'phone should return false' do
@contact.phone = "32341" @contact.phone = '32341'
expect(@contact.valid?).to be false expect(@contact.valid?).to be false
end end
it 'ident should return false' do it 'ident should return false' do
@contact.ident = "123abc" @contact.ident = '123abc'
expect(@contact.valid?).to be false expect(@contact.valid?).to be false
end end
@ -21,11 +21,11 @@ describe Contact do
expect(@contact.valid?).to eq false expect(@contact.valid?).to eq false
expect(@contact.errors.messages).to match_array({ expect(@contact.errors.messages).to match_array({
:code=>["Required parameter missing - code"], code: ['Required parameter missing - code'],
:name=>["Required parameter missing - name"], name: ['Required parameter missing - name'],
:phone=>["Required parameter missing - phone", "Phone nr is invalid"], phone: ['Required parameter missing - phone', 'Phone nr is invalid'],
:email=>["Required parameter missing - email", "Email is invalid"], email: ['Required parameter missing - email', 'Email is invalid'],
:ident=>["Required parameter missing - ident"] ident: ['Required parameter missing - ident']
}) })
end end
end end
@ -60,7 +60,7 @@ describe Contact, '#relations_with_domain?' do
end end
describe Contact, '#crID' do describe Contact, '#crID' do
before(:each) { Fabricate(:contact, code: "asd12", created_by: Fabricate(:epp_user)) } before(:each) { Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user)) }
it 'should return username of creator' do it 'should return username of creator' do
expect(Contact.first.crID).to eq('gitlab') expect(Contact.first.crID).to eq('gitlab')
@ -71,9 +71,8 @@ describe Contact, '#crID' do
end end
end end
describe Contact, '#upID' do describe Contact, '#upID' do
before(:each) { Fabricate(:contact, code: "asd12", created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user)) } before(:each) { Fabricate(:contact, code: 'asd12', created_by: Fabricate(:epp_user), updated_by: Fabricate(:epp_user)) }
it 'should return username of updater' do it 'should return username of updater' do
expect(Contact.first.upID).to eq('gitlab') expect(Contact.first.upID).to eq('gitlab')
@ -84,10 +83,9 @@ describe Contact, '#upID' do
end end
end end
describe Contact, '.extract_params' do describe Contact, '.extract_params' do
it 'returns params hash'do it 'returns params hash'do
ph = { id: '123123', email: 'jdoe@example.com', postalInfo: { name: "fred", addr: { cc: 'EE' } } } ph = { id: '123123', email: 'jdoe@example.com', postalInfo: { name: 'fred', addr: { cc: 'EE' } } }
expect(Contact.extract_attributes(ph)).to eq({ expect(Contact.extract_attributes(ph)).to eq({
code: '123123', code: '123123',
email: 'jdoe@example.com', email: 'jdoe@example.com',
@ -96,33 +94,31 @@ describe Contact, '.extract_params' do
end end
end end
describe Contact, '.check_availability' do describe Contact, '.check_availability' do
before(:each) { before(:each) do
Fabricate(:contact, code: "asd12") Fabricate(:contact, code: 'asd12')
Fabricate(:contact, code: "asd13") Fabricate(:contact, code: 'asd13')
} end
it 'should return array if argument is string' do it 'should return array if argument is string' do
response = Contact.check_availability("asd12") response = Contact.check_availability('asd12')
expect(response.class).to be Array expect(response.class).to be Array
expect(response.length).to eq(1) expect(response.length).to eq(1)
end end
it 'should return in_use and available codes' do it 'should return in_use and available codes' do
response = Contact.check_availability(["asd12","asd13","asd14"]) response = Contact.check_availability(%w(asd12 asd13 asd14))
expect(response.class).to be Array expect(response.class).to be Array
expect(response.length).to eq(3) expect(response.length).to eq(3)
expect(response[0][:avail]).to eq(0) expect(response[0][:avail]).to eq(0)
expect(response[0][:code]).to eq("asd12") expect(response[0][:code]).to eq('asd12')
expect(response[1][:avail]).to eq(0) expect(response[1][:avail]).to eq(0)
expect(response[1][:code]).to eq("asd13") expect(response[1][:code]).to eq('asd13')
expect(response[2][:avail]).to eq(1) expect(response[2][:avail]).to eq(1)
expect(response[2][:code]).to eq("asd14") expect(response[2][:code]).to eq('asd14')
end end
end end

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Domain do describe Domain do
it { should belong_to(:registrar) } it { should belong_to(:registrar) }
@ -44,9 +44,9 @@ describe Domain do
expect(d.errors.messages).to match_array({ expect(d.errors.messages).to match_array({
name: ['is missing'], name: ['is missing'],
period: ['is not a number'], period: ['is not a number'],
owner_contact: ["Registrant is missing"], owner_contact: ['Registrant is missing'],
admin_contacts: ["Admin contact is missing"], admin_contacts: ['Admin contact is missing'],
nameservers: ["Nameservers count must be between 1-13"] nameservers: ['Nameservers count must be between 1-13']
}) })
sg = SettingGroup.domain_validation sg = SettingGroup.domain_validation

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe EppSession do describe EppSession do
let(:epp_session) { Fabricate(:epp_session) } let(:epp_session) { Fabricate(:epp_session) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe EppUser do describe EppUser do
it { should belong_to(:registrar) } it { should belong_to(:registrar) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Nameserver do describe Nameserver do
it { should have_and_belong_to_many(:domains) } it { should have_and_belong_to_many(:domains) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe NsSet do describe NsSet do
it { should belong_to(:registrar) } it { should belong_to(:registrar) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Registrar do describe Registrar do
it { should belong_to(:country) } it { should belong_to(:country) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Right do describe Right do
it { should have_and_belong_to_many(:roles) } it { should have_and_belong_to_many(:roles) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Role do describe Role do
it { should have_and_belong_to_many(:rights) } it { should have_and_belong_to_many(:rights) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe SettingGroup do describe SettingGroup do
it { should have_many(:settings) } it { should have_many(:settings) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe Setting do describe Setting do
it { should belong_to(:setting_group) } it { should belong_to(:setting_group) }

View file

@ -1,4 +1,4 @@
require "rails_helper" require 'rails_helper'
describe User do describe User do
it { should belong_to(:role) } it { should belong_to(:role) }

View file

@ -1,7 +1,7 @@
# This file is copied to spec/ when you run 'rails generate rspec:install' # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test' ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper' require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__) require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'shoulda/matchers' require 'shoulda/matchers'
require 'capybara/poltergeist' require 'capybara/poltergeist'
@ -13,7 +13,7 @@ require 'capybara/poltergeist'
# run twice. It is recommended that you do not name files matching this glob to # run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with with the --pattern # end with _spec.rb. You can configure this pattern with with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migrations before tests are run. # Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line. # If you are not using ActiveRecord, you can remove this line.

View file

@ -14,65 +14,63 @@
# users commonly want. # users commonly want.
# #
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config| RSpec.configure do |_config|
# The settings below are suggested to provide a good initial experience # The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content. # with RSpec, but feel free to customize to your heart's content.
=begin # # These two settings work together to allow you to limit a spec run
# These two settings work together to allow you to limit a spec run # # to individual examples or groups you care about by tagging them with
# to individual examples or groups you care about by tagging them with # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
# `:focus` metadata. When nothing is tagged with `:focus`, all examples # # get run.
# get run. # config.filter_run :focus
config.filter_run :focus # config.run_all_when_everything_filtered = true
config.run_all_when_everything_filtered = true #
# # Many RSpec users commonly either run the entire suite or an individual
# Many RSpec users commonly either run the entire suite or an individual # # file, and it's useful to allow more verbose output when running an
# file, and it's useful to allow more verbose output when running an # # individual spec file.
# individual spec file. # if config.files_to_run.one?
if config.files_to_run.one? # # Use the documentation formatter for detailed output,
# Use the documentation formatter for detailed output, # # unless a formatter has already been configured
# unless a formatter has already been configured # # (e.g. via a command-line flag).
# (e.g. via a command-line flag). # config.default_formatter = 'doc'
config.default_formatter = 'doc' # end
end #
# # Print the 10 slowest examples and example groups at the
# Print the 10 slowest examples and example groups at the # # end of the spec run, to help surface which specs are running
# end of the spec run, to help surface which specs are running # # particularly slow.
# particularly slow. # config.profile_examples = 10
config.profile_examples = 10 #
# # Run specs in random order to surface order dependencies. If you find an
# Run specs in random order to surface order dependencies. If you find an # # order dependency and want to debug it, you can fix the order by providing
# order dependency and want to debug it, you can fix the order by providing # # the seed, which is printed after each run.
# the seed, which is printed after each run. # # --seed 1234
# --seed 1234 # config.order = :random
config.order = :random #
# # Seed global randomization in this process using the `--seed` CLI option.
# Seed global randomization in this process using the `--seed` CLI option. # # Setting this allows you to use `--seed` to deterministically reproduce
# Setting this allows you to use `--seed` to deterministically reproduce # # test failures related to randomization by passing the same `--seed` value
# test failures related to randomization by passing the same `--seed` value # # as the one that triggered the failure.
# as the one that triggered the failure. # Kernel.srand config.seed
Kernel.srand config.seed #
# # rspec-expectations config goes here. You can use an alternate
# rspec-expectations config goes here. You can use an alternate # # assertion/expectation library such as wrong or the stdlib/minitest
# assertion/expectation library such as wrong or the stdlib/minitest # # assertions if you prefer.
# assertions if you prefer. # config.expect_with :rspec do |expectations|
config.expect_with :rspec do |expectations| # # Enable only the newer, non-monkey-patching expect syntax.
# Enable only the newer, non-monkey-patching expect syntax. # # For more details, see:
# For more details, see: # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax # expectations.syntax = :expect
expectations.syntax = :expect # end
end #
# # rspec-mocks config goes here. You can use an alternate test double
# rspec-mocks config goes here. You can use an alternate test double # # library (such as bogus or mocha) by changing the `mock_with` option here.
# library (such as bogus or mocha) by changing the `mock_with` option here. # config.mock_with :rspec do |mocks|
config.mock_with :rspec do |mocks| # # Enable only the newer, non-monkey-patching expect syntax.
# Enable only the newer, non-monkey-patching expect syntax. # # For more details, see:
# For more details, see: # # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ # mocks.syntax = :expect
mocks.syntax = :expect #
# # Prevents you from mocking or stubbing a method that does not exist on
# Prevents you from mocking or stubbing a method that does not exist on # # a real object. This is generally recommended.
# a real object. This is generally recommended. # mocks.verify_partial_doubles = true
mocks.verify_partial_doubles = true # end
end
=end
end end

View file

@ -1,28 +1,24 @@
module Epp module Epp
def read_body filename def read_body(filename)
File.read("spec/epp/requests/#{filename}") File.read("spec/epp/requests/#{filename}")
end end
# handles connection and login automatically # handles connection and login automatically
def epp_request(data, type = :filename) def epp_request(data, type = :filename)
begin
return parse_response(server.request(read_body(data))) if type == :filename return parse_response(server.request(read_body(data))) if type == :filename
return parse_response(server.request(data)) return parse_response(server.request(data))
rescue Exception => e rescue => e
e e
end end
end
def epp_plain_request(data, type = :filename) def epp_plain_request(data, type = :filename)
begin
return parse_response(server.send_request(read_body(data))) if type == :filename return parse_response(server.send_request(read_body(data))) if type == :filename
return parse_response(server.send_request(data)) return parse_response(server.send_request(data))
rescue Exception => e rescue => e
e e
end end
end
def parse_response raw def parse_response(raw)
res = Nokogiri::XML(raw) res = Nokogiri::XML(raw)
obj = { obj = {
@ -61,7 +57,7 @@ module Epp
xml = Builder::XmlMarkup.new xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no') xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do xml.command do
xml.create do xml.create do
@ -96,7 +92,7 @@ module Epp
def domain_renew_xml(xml_params = {}) def domain_renew_xml(xml_params = {})
xml = Builder::XmlMarkup.new xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no') xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do xml.command do
xml.renew do xml.renew do
@ -115,7 +111,7 @@ module Epp
xml_params[:names] = xml_params[:names] || ['example.ee'] xml_params[:names] = xml_params[:names] || ['example.ee']
xml = Builder::XmlMarkup.new xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no') xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do xml.command do
xml.check do xml.check do
@ -137,7 +133,7 @@ module Epp
xml = Builder::XmlMarkup.new xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :standalone => 'no') xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do xml.command do
xml.info do xml.info do

View file

@ -1,7 +1,5 @@
module EppContactXmlBuilder module EppContactXmlBuilder
def contact_check_xml(xml_params = {}) def contact_check_xml(xml_params = {})
xml_params[:ids] = xml_params[:ids] || [{ id: 'check-1234' }, { id: 'check-4321' }] xml_params[:ids] = xml_params[:ids] || [{ id: 'check-1234' }, { id: 'check-4321' }]
xml = Builder::XmlMarkup.new xml = Builder::XmlMarkup.new
@ -31,7 +29,6 @@ module EppContactXmlBuilder
city: 'Megaton', sp: 'F3 ', pc: '201-33', cc: 'EE' } city: 'Megaton', sp: 'F3 ', pc: '201-33', cc: 'EE' }
xml_params[:authInfo] = xml_params[:authInfo] || { pw: 'Aas34fq' } xml_params[:authInfo] = xml_params[:authInfo] || { pw: 'Aas34fq' }
xml.instruct!(:xml, standalone: 'no') xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do xml.command do
@ -81,11 +78,11 @@ module EppContactXmlBuilder
postalInfo = xml_params[:chg][:postalInfo] rescue nil postalInfo = xml_params[:chg][:postalInfo] rescue nil
addr = postalInfo[:addr] rescue nil addr = postalInfo[:addr] rescue nil
if !addr unless addr
addr = { street: 'Downtown', city: 'Stockholm', cc: 'SE' } addr = { street: 'Downtown', city: 'Stockholm', cc: 'SE' }
end end
if !postalInfo unless postalInfo
postalInfo = { name: 'Jane Doe', org: 'Fake Inc.', voice: '+321.12345', fax: '12312312', addr: addr } postalInfo = { name: 'Jane Doe', org: 'Fake Inc.', voice: '+321.12345', fax: '12312312', addr: addr }
end end
@ -96,7 +93,6 @@ module EppContactXmlBuilder
xml_params[:chg][:authInfo] = xml_params[:chg][:authInfo] || { pw: 'ccds4324pok' } xml_params[:chg][:authInfo] = xml_params[:chg][:authInfo] || { pw: 'ccds4324pok' }
xml.instruct!(:xml, standalone: 'no') xml.instruct!(:xml, standalone: 'no')
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do
xml.command do xml.command do