mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Allow invalid ident update #2859
This commit is contained in:
parent
0944bd2077
commit
4a32c7641c
18 changed files with 101 additions and 32 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
21.09.2015
|
||||||
|
* eis-1.0.xsd schema file updated without a new version, please publish a new updated schema file to public.
|
||||||
|
|
||||||
17.09.2015
|
17.09.2015
|
||||||
* deploy-example.rb has been updated with `@cron_group`.
|
* deploy-example.rb has been updated with `@cron_group`.
|
||||||
|
|
||||||
|
|
|
@ -126,9 +126,6 @@ class Epp::ContactsController < EppController
|
||||||
contact_org_disabled
|
contact_org_disabled
|
||||||
fax_disabled
|
fax_disabled
|
||||||
status_editing_disabled
|
status_editing_disabled
|
||||||
if params[:parsed_frame].css('ident').present?
|
|
||||||
epp_errors << { code: '2306', msg: "#{I18n.t(:ident_update_error)} [ident]" }
|
|
||||||
end
|
|
||||||
requires 'id'
|
requires 'id'
|
||||||
@prefix = nil
|
@prefix = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Contact < ActiveRecord::Base
|
||||||
after_initialize do
|
after_initialize do
|
||||||
self.statuses = [] if statuses.nil?
|
self.statuses = [] if statuses.nil?
|
||||||
self.status_notes = {} if status_notes.nil?
|
self.status_notes = {} if status_notes.nil?
|
||||||
|
self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
before_validation :set_ident_country_code
|
before_validation :set_ident_country_code
|
||||||
|
|
|
@ -10,9 +10,9 @@ module Depp
|
||||||
|
|
||||||
DISABLED = 'Disabled'
|
DISABLED = 'Disabled'
|
||||||
DISCLOSURE_TYPES = [DISABLED, '1', '0']
|
DISCLOSURE_TYPES = [DISABLED, '1', '0']
|
||||||
TYPES = %w( bic priv birthday )
|
TYPES = %w( org priv birthday )
|
||||||
SELECTION_TYPES = [
|
SELECTION_TYPES = [
|
||||||
['Business code', 'bic'],
|
['Business code', 'org'],
|
||||||
['Personal identification code', 'priv'],
|
['Personal identification code', 'priv'],
|
||||||
['Birthday', 'birthday']
|
['Birthday', 'birthday']
|
||||||
]
|
]
|
||||||
|
@ -163,7 +163,7 @@ module Depp
|
||||||
}
|
}
|
||||||
|
|
||||||
hash[:id] = nil if code.blank?
|
hash[:id] = nil if code.blank?
|
||||||
create_xml = Depp::Contact.epp_xml.create(hash, extension_xml)
|
create_xml = Depp::Contact.epp_xml.create(hash, extension_xml(:create))
|
||||||
|
|
||||||
data = Depp::Contact.user.request(create_xml)
|
data = Depp::Contact.user.request(create_xml)
|
||||||
self.id = data.css('id').text
|
self.id = data.css('id').text
|
||||||
|
@ -210,7 +210,7 @@ module Depp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extension_xml
|
extension_xml(:update)
|
||||||
)
|
)
|
||||||
data = Depp::Contact.user.request(update_xml)
|
data = Depp::Contact.user.request(update_xml)
|
||||||
handle_errors(data)
|
handle_errors(data)
|
||||||
|
@ -224,15 +224,25 @@ module Depp
|
||||||
id: { value: id },
|
id: { value: id },
|
||||||
authInfo: { pw: { value: password } }
|
authInfo: { pw: { value: password } }
|
||||||
},
|
},
|
||||||
extension_xml
|
extension_xml(:delete)
|
||||||
)
|
)
|
||||||
data = Depp::Contact.user.request(delete_xml)
|
data = Depp::Contact.user.request(delete_xml)
|
||||||
handle_errors(data)
|
handle_errors(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def extension_xml
|
def extension_xml(action)
|
||||||
xml = { _anonymus: [] }
|
xml = { _anonymus: [] }
|
||||||
ident = ident_xml[:_anonymus].try(:first) unless persisted?
|
|
||||||
|
case action
|
||||||
|
when :create
|
||||||
|
ident = ident_xml[:_anonymus].try(:first)
|
||||||
|
when :update
|
||||||
|
# detect if any ident has changed
|
||||||
|
if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code)
|
||||||
|
ident = ident_xml[:_anonymus].try(:first)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
legal = legal_document_xml[:_anonymus].try(:first)
|
legal = legal_document_xml[:_anonymus].try(:first)
|
||||||
xml[:_anonymus] << ident if ident.present?
|
xml[:_anonymus] << ident if ident.present?
|
||||||
xml[:_anonymus] << legal if legal.present?
|
xml[:_anonymus] << legal if legal.present?
|
||||||
|
|
|
@ -118,6 +118,7 @@ class Epp::Contact < Contact
|
||||||
[:ident, :invalid_EE_identity_format],
|
[:ident, :invalid_EE_identity_format],
|
||||||
[:ident, :invalid_birthday_format],
|
[:ident, :invalid_birthday_format],
|
||||||
[:ident, :invalid_country_code],
|
[:ident, :invalid_country_code],
|
||||||
|
[:ident_type, :missing],
|
||||||
[:code, :invalid],
|
[:code, :invalid],
|
||||||
[:code, :too_long_contact_code]
|
[:code, :too_long_contact_code]
|
||||||
],
|
],
|
||||||
|
@ -144,6 +145,20 @@ class Epp::Contact < Contact
|
||||||
legal_frame = frame.css('legalDocument').first
|
legal_frame = frame.css('legalDocument').first
|
||||||
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
||||||
self.deliver_emails = true # turn on email delivery for epp
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
|
|
||||||
|
# allow to update ident code for legacy contacts
|
||||||
|
if frame.css('ident').first.present?
|
||||||
|
if ident_updated_at.present?
|
||||||
|
throw :epp_error, {
|
||||||
|
code: '2306',
|
||||||
|
msg: I18n.t(:ident_update_error)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
at.merge!(self.class.ident_attrs(frame.css('ident').first))
|
||||||
|
self.ident_updated_at = Time.zone.now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
super(at)
|
super(at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
- ident_complete = f.object.ident_country_code.present? && f.object.ident_type.present? && f.object.ident.present?
|
||||||
|
- if @contact.persisted?
|
||||||
|
- country_selected = f.object.ident_country_code || (params[:depp_contact].try(:[], :ident_country_code))
|
||||||
|
- type_selected = f.object.ident_type || (params[:depp_contact].try(:[], :ident_type))
|
||||||
|
- else
|
||||||
|
- country_selected = (params[:depp_contact].try(:[], :ident_country_code) || 'EE')
|
||||||
|
- type_selected = (params[:depp_contact].try(:[], :ident_type) || 'org')
|
||||||
|
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading.clearfix
|
.panel-heading.clearfix
|
||||||
.pull-left= t(:ident)
|
.pull-left= t(:ident)
|
||||||
|
@ -6,12 +14,11 @@
|
||||||
.col-md-3.control-label
|
.col-md-3.control-label
|
||||||
= f.label :ident_country_code, t(:country) + '*'
|
= f.label :ident_country_code, t(:country) + '*'
|
||||||
.col-md-7
|
.col-md-7
|
||||||
- if @contact.persisted? && f.object.ident_country_code.present?
|
- if ident_complete && @contact.persisted? && f.object.ident_country_code.present?
|
||||||
.disabled-value
|
.disabled-value
|
||||||
= Country.new(f.object.ident_country_code).try(:to_s)
|
= Country.new(f.object.ident_country_code).try(:to_s)
|
||||||
= " [#{f.object.ident_country_code}]"
|
= " [#{f.object.ident_country_code}]"
|
||||||
- else
|
- else
|
||||||
- country_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_country_code) || 'EE')
|
|
||||||
= f.select(:ident_country_code, SortedCountry.all_options(country_selected), {},
|
= f.select(:ident_country_code, SortedCountry.all_options(country_selected), {},
|
||||||
class: 'js-ident-country-code', required: true)
|
class: 'js-ident-country-code', required: true)
|
||||||
|
|
||||||
|
@ -19,25 +26,23 @@
|
||||||
.col-md-3.control-label
|
.col-md-3.control-label
|
||||||
= f.label :ident_type, t(:type) + '*'
|
= f.label :ident_type, t(:type) + '*'
|
||||||
.col-md-7
|
.col-md-7
|
||||||
- if @contact.persisted? && f.object.ident_type.present?
|
- if ident_complete && @contact.persisted? && f.object.ident_type.present?
|
||||||
.disabled-value
|
.disabled-value
|
||||||
= Depp::Contact.type_string(f.object.ident_type)
|
= Depp::Contact.type_string(f.object.ident_type)
|
||||||
= " [#{f.object.ident_type}]"
|
= " [#{f.object.ident_type}]"
|
||||||
- else
|
- else
|
||||||
- type_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_type) || 'bic')
|
= f.select(:ident_type, Depp::Contact::SELECTION_TYPES, { selected: type_selected },
|
||||||
= f.select(:ident_type, Depp::Contact::SELECTION_TYPES,
|
|
||||||
{ selected: type_selected },
|
|
||||||
class: 'js-ident-type', required: true)
|
class: 'js-ident-type', required: true)
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
.col-md-3.control-label
|
.col-md-3.control-label
|
||||||
= f.label :ident, t(:ident) + '*'
|
= f.label :ident, t(:ident) + '*'
|
||||||
.col-md-7
|
.col-md-7
|
||||||
- if @contact.persisted? && f.object.ident.present?
|
- if ident_complete && @contact.persisted? && f.object.ident.present?
|
||||||
.disabled-value
|
.disabled-value
|
||||||
= f.object.ident
|
= f.object.ident
|
||||||
- else
|
- else
|
||||||
= f.text_field :ident, class: 'form-control', required: true, disabled: @contact.persisted?
|
= f.text_field :ident, class: 'form-control', required: true
|
||||||
- tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none'
|
- tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none'
|
||||||
.js-ident-tip{ style: tip_visibility }
|
.js-ident-tip{ style: tip_visibility }
|
||||||
= t(:birthday_format)
|
= t(:birthday_format)
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
%dd
|
%dd
|
||||||
= text_field_tag :password, @contact.password, readonly: true, class: 'partially-hidden'
|
= text_field_tag :password, @contact.password, readonly: true, class: 'partially-hidden'
|
||||||
|
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
|
||||||
%dt= t(:ident)
|
%dt= t(:ident)
|
||||||
|
|
|
@ -12,5 +12,3 @@
|
||||||
%tr
|
%tr
|
||||||
%td= s.first
|
%td= s.first
|
||||||
%td= s.second
|
%td= s.second
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,6 @@ en:
|
||||||
value:
|
value:
|
||||||
taken: 'Status already exists on this domain'
|
taken: 'Status already exists on this domain'
|
||||||
|
|
||||||
|
|
||||||
user:
|
user:
|
||||||
attributes:
|
attributes:
|
||||||
username:
|
username:
|
||||||
|
@ -515,7 +514,7 @@ en:
|
||||||
crt_revoked: 'CRT (revoked)'
|
crt_revoked: 'CRT (revoked)'
|
||||||
contact_org_error: 'Parameter value policy error. Org must be blank'
|
contact_org_error: 'Parameter value policy error. Org must be blank'
|
||||||
contact_fax_error: 'Parameter value policy error. Fax must be blank'
|
contact_fax_error: 'Parameter value policy error. Fax must be blank'
|
||||||
ident_update_error: 'Parameter value policy error. Update of ident data not allowed'
|
ident_update_error: 'Parameter value policy error. Update of ident data not allowed [ident]'
|
||||||
invoices: 'Invoices'
|
invoices: 'Invoices'
|
||||||
no_such_user: 'No such user'
|
no_such_user: 'No such user'
|
||||||
log_in: 'Log in'
|
log_in: 'Log in'
|
||||||
|
|
5
db/migrate/20150903105659_add_updated_token.rb
Normal file
5
db/migrate/20150903105659_add_updated_token.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddUpdatedToken < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :contacts, :legacy_ident_updated_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
5
db/migrate/20150921110152_update_contacts_logs.rb
Normal file
5
db/migrate/20150921110152_update_contacts_logs.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class UpdateContactsLogs < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :log_contacts, :legacy_ident_updated_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class RenameContactIdentUpdator < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :contacts, :legacy_ident_updated_at, :ident_updated_at
|
||||||
|
rename_column :log_contacts, :legacy_ident_updated_at, :ident_updated_at
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# 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: 20150915094707) do
|
ActiveRecord::Schema.define(version: 20150921111842) 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"
|
||||||
|
@ -203,6 +203,7 @@ ActiveRecord::Schema.define(version: 20150915094707) do
|
||||||
t.hstore "status_notes"
|
t.hstore "status_notes"
|
||||||
t.integer "legacy_history_id"
|
t.integer "legacy_history_id"
|
||||||
t.integer "copy_from_id"
|
t.integer "copy_from_id"
|
||||||
|
t.datetime "ident_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree
|
add_index "contacts", ["code"], name: "index_contacts_on_code", using: :btree
|
||||||
|
@ -585,15 +586,16 @@ ActiveRecord::Schema.define(version: 20150915094707) do
|
||||||
add_index "log_contact_statuses", ["whodunnit"], name: "index_log_contact_statuses_on_whodunnit", using: :btree
|
add_index "log_contact_statuses", ["whodunnit"], name: "index_log_contact_statuses_on_whodunnit", using: :btree
|
||||||
|
|
||||||
create_table "log_contacts", force: :cascade do |t|
|
create_table "log_contacts", force: :cascade do |t|
|
||||||
t.string "item_type", null: false
|
t.string "item_type", null: false
|
||||||
t.integer "item_id", null: false
|
t.integer "item_id", null: false
|
||||||
t.string "event", null: false
|
t.string "event", null: false
|
||||||
t.string "whodunnit"
|
t.string "whodunnit"
|
||||||
t.json "object"
|
t.json "object"
|
||||||
t.json "object_changes"
|
t.json "object_changes"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.string "session"
|
t.string "session"
|
||||||
t.json "children"
|
t.json "children"
|
||||||
|
t.datetime "ident_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "log_contacts", ["item_type", "item_id"], name: "index_log_contacts_on_item_type_and_item_id", using: :btree
|
add_index "log_contacts", ["item_type", "item_id"], name: "index_log_contacts_on_item_type_and_item_id", using: :btree
|
||||||
|
|
|
@ -598,7 +598,8 @@ CREATE TABLE contacts (
|
||||||
statuses character varying[],
|
statuses character varying[],
|
||||||
status_notes hstore,
|
status_notes hstore,
|
||||||
legacy_history_id integer,
|
legacy_history_id integer,
|
||||||
copy_from_id integer
|
copy_from_id integer,
|
||||||
|
ident_updated_at timestamp without time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1502,7 +1503,8 @@ CREATE TABLE log_contacts (
|
||||||
object_changes json,
|
object_changes json,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
session character varying,
|
session character varying,
|
||||||
children json
|
children json,
|
||||||
|
ident_updated_at timestamp without time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -4934,7 +4936,13 @@ INSERT INTO schema_migrations (version) VALUES ('20150825125118');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150827151906');
|
INSERT INTO schema_migrations (version) VALUES ('20150827151906');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150903105659');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150910113839');
|
INSERT INTO schema_migrations (version) VALUES ('20150910113839');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20150915094707');
|
INSERT INTO schema_migrations (version) VALUES ('20150915094707');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150921110152');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20150921111842');
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
<simpleType name="identEnumType">
|
<simpleType name="identEnumType">
|
||||||
<restriction base="token">
|
<restriction base="token">
|
||||||
<enumeration value="bic"/>
|
<enumeration value="org"/>
|
||||||
<enumeration value="priv"/>
|
<enumeration value="priv"/>
|
||||||
<enumeration value="birthday"/>
|
<enumeration value="birthday"/>
|
||||||
</restriction>
|
</restriction>
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
<simpleType name="identEnumType">
|
<simpleType name="identEnumType">
|
||||||
<restriction base="token">
|
<restriction base="token">
|
||||||
<enumeration value="bic"/>
|
<enumeration value="org"/>
|
||||||
<enumeration value="priv"/>
|
<enumeration value="priv"/>
|
||||||
<enumeration value="birthday"/>
|
<enumeration value="birthday"/>
|
||||||
</restriction>
|
</restriction>
|
||||||
|
|
|
@ -6,7 +6,7 @@ class SortedCountry
|
||||||
include ActionView::Helpers
|
include ActionView::Helpers
|
||||||
|
|
||||||
def all_options(selected = nil)
|
def all_options(selected = nil)
|
||||||
quick_options = options_for_select([['', '']] + quick_list, { selected: selected })
|
quick_options = options_for_select(quick_list, { selected: selected })
|
||||||
|
|
||||||
# no double select
|
# no double select
|
||||||
selected = quick_list.map(&:second).include?(selected) ? '' : selected
|
selected = quick_list.map(&:second).include?(selected) ? '' : selected
|
||||||
|
|
|
@ -116,6 +116,10 @@ describe Contact do
|
||||||
@contact.valid?
|
@contact.valid?
|
||||||
@contact.errors[:email].should == ['Email is invalid']
|
@contact.errors[:email].should == ['Email is invalid']
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
|
@ -234,6 +238,18 @@ describe Contact do
|
||||||
contact.status_notes['someotherstatus'].should == nil
|
contact.status_notes['someotherstatus'].should == nil
|
||||||
end
|
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 = Fabricate(:contact)
|
||||||
|
contact.update_column(:ident_updated_at, nil)
|
||||||
|
|
||||||
|
Contact.find(contact.id).ident_updated_at.should == nil
|
||||||
|
end
|
||||||
|
|
||||||
context 'as birthday' do
|
context 'as birthday' do
|
||||||
before do
|
before do
|
||||||
@domain = Fabricate(:domain)
|
@domain = Fabricate(:domain)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue