mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
Merge pull request #2683 from internetee/fix-contact-name-issues
Updated contact name data type in db schemas
This commit is contained in:
commit
ee5cf99b13
12 changed files with 109 additions and 45 deletions
|
@ -74,6 +74,7 @@ module Epp
|
||||||
|
|
||||||
def validate_against_schema
|
def validate_against_schema
|
||||||
return if %w[hello error].include?(params[:action])
|
return if %w[hello error].include?(params[:action])
|
||||||
|
|
||||||
schema.validate(params[:nokogiri_frame]).each do |error|
|
schema.validate(params[:nokogiri_frame]).each do |error|
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: 2001,
|
code: 2001,
|
||||||
|
@ -100,6 +101,7 @@ module Epp
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
return unless signed_in?
|
return unless signed_in?
|
||||||
|
|
||||||
epp_session.user
|
epp_session.user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ module EppErrors
|
||||||
errors.each do |err|
|
errors.each do |err|
|
||||||
code, value = find_epp_code_and_value(err)
|
code, value = find_epp_code_and_value(err)
|
||||||
next unless code
|
next unless code
|
||||||
|
|
||||||
msg = attr.to_sym == :base ? err : "#{err} [#{attr}]"
|
msg = attr.to_sym == :base ? err : "#{err} [#{attr}]"
|
||||||
epp_errors.add(attr, code: code, msg: msg, value: value)
|
epp_errors.add(attr, code: code, msg: msg, value: value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,6 +46,7 @@ class Contact < ApplicationRecord
|
||||||
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x
|
[\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x
|
||||||
|
|
||||||
validates :name, :email, presence: true
|
validates :name, :email, presence: true
|
||||||
|
validates :name, length: { maximum: 255, message: :too_long_contact_name }
|
||||||
validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? }
|
validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? }
|
||||||
|
|
||||||
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
|
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
|
||||||
|
|
|
@ -12,6 +12,7 @@ class Epp::Contact < Contact
|
||||||
|
|
||||||
def manage_permissions
|
def manage_permissions
|
||||||
return unless update_prohibited? || delete_prohibited?
|
return unless update_prohibited? || delete_prohibited?
|
||||||
|
|
||||||
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
|
add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation))
|
||||||
throw(:abort)
|
throw(:abort)
|
||||||
end
|
end
|
||||||
|
@ -76,6 +77,7 @@ class Epp::Contact < Contact
|
||||||
],
|
],
|
||||||
'2005' => [ # Value syntax error
|
'2005' => [ # Value syntax error
|
||||||
[:name, :invalid],
|
[:name, :invalid],
|
||||||
|
[:name, :too_long_contact_name],
|
||||||
[:phone, :invalid],
|
[:phone, :invalid],
|
||||||
[:email, :invalid],
|
[:email, :invalid],
|
||||||
[:country_code, :invalid],
|
[:country_code, :invalid],
|
||||||
|
|
|
@ -15,6 +15,7 @@ en:
|
||||||
name:
|
name:
|
||||||
blank: "Required parameter missing - name"
|
blank: "Required parameter missing - name"
|
||||||
invalid: "Name is invalid"
|
invalid: "Name is invalid"
|
||||||
|
too_long_contact_name: "Contact name is too long, max 255 characters"
|
||||||
phone:
|
phone:
|
||||||
blank: "Required parameter missing - phone"
|
blank: "Required parameter missing - phone"
|
||||||
invalid: "Phone nr is invalid"
|
invalid: "Phone nr is invalid"
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
# encoding: UTF-8
|
|
||||||
# This file is auto-generated from the current state of the database. Instead
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
#
|
#
|
||||||
# Note that this schema.rb definition is the authoritative source for your
|
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||||
# database schema. If you need to create the application database on another
|
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
||||||
# system, you should be using db:schema:load, not running all the migrations
|
# be faster and is potentially less error prone than running all of your
|
||||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
# migrations from scratch. Old migrations may fail to apply correctly if those
|
||||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
# migrations use external dependencies or application code.
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
|
||||||
|
@ -17,35 +16,33 @@ ActiveRecord::Schema.define(version: 0) do
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
create_table "epp_logs", force: :cascade do |t|
|
create_table "epp_logs", force: :cascade do |t|
|
||||||
t.text "request"
|
t.text "request"
|
||||||
t.text "response"
|
t.text "response"
|
||||||
t.string "request_command", limit: 255
|
t.string "request_command", limit: 255
|
||||||
t.string "request_object", limit: 255
|
t.string "request_object"
|
||||||
t.boolean "request_successful"
|
t.boolean "request_successful"
|
||||||
t.string "api_user_name", limit: 255
|
t.string "api_user_name", limit: 255
|
||||||
t.string "api_user_registrar", limit: 255
|
t.string "api_user_registrar", limit: 255
|
||||||
t.string "ip", limit: 255
|
t.string "ip", limit: 255
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "uuid"
|
t.string "uuid"
|
||||||
|
t.index ["uuid"], name: "epp_logs_uuid"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "epp_logs", ["uuid"], name: "epp_logs_uuid", using: :btree
|
|
||||||
|
|
||||||
create_table "repp_logs", force: :cascade do |t|
|
create_table "repp_logs", force: :cascade do |t|
|
||||||
t.string "request_path", limit: 255
|
t.string "request_path", limit: 255
|
||||||
t.string "request_method", limit: 255
|
t.string "request_method", limit: 255
|
||||||
t.text "request_params"
|
t.text "request_params"
|
||||||
t.text "response"
|
t.text "response"
|
||||||
t.string "response_code", limit: 255
|
t.string "response_code", limit: 255
|
||||||
t.string "api_user_name", limit: 255
|
t.string "api_user_name", limit: 255
|
||||||
t.string "api_user_registrar", limit: 255
|
t.string "api_user_registrar", limit: 255
|
||||||
t.string "ip", limit: 255
|
t.string "ip", limit: 255
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "uuid"
|
t.string "uuid"
|
||||||
|
t.index ["uuid"], name: "repp_logs_uuid"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "repp_logs", ["uuid"], name: "repp_logs_uuid", using: :btree
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class RemoveLogDomainStatuses < ActiveRecord::Migration[6.0]
|
class RemoveLogDomainStatuses < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
drop_table :log_domain_statuses
|
drop_table :log_domain_statuses if table_exists?(:log_domain_statuses)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
class ChangeRequestObjectTypeInEppLogs < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
with_api_log_connection do |connection|
|
||||||
|
connection.change_column :epp_logs, :request_object, :string, limit: nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
with_api_log_connection do |connection|
|
||||||
|
connection.change_column :epp_logs, :request_object, :string, limit: 255
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def with_api_log_connection
|
||||||
|
api_log_connection = ActiveRecord::Base.establish_connection("api_log_#{Rails.env}".to_sym).connection
|
||||||
|
|
||||||
|
yield(api_log_connection)
|
||||||
|
|
||||||
|
ensure
|
||||||
|
# Re-establish the original connection
|
||||||
|
ActiveRecord::Base.establish_connection(original_connection_config)
|
||||||
|
end
|
||||||
|
|
||||||
|
def original_connection_config
|
||||||
|
Rails.configuration.database_configuration[Rails.env]
|
||||||
|
end
|
||||||
|
end
|
29
db/migrate/20240816092636_change_data_type_in_contacts.rb
Normal file
29
db/migrate/20240816092636_change_data_type_in_contacts.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
class ChangeDataTypeInContacts < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
safety_assured do
|
||||||
|
change_column :contacts, :code, :string, limit: 255
|
||||||
|
change_column :contacts, :phone, :string, limit: 255
|
||||||
|
change_column :contacts, :email, :string, limit: 255
|
||||||
|
change_column :contacts, :fax, :string, limit: 255
|
||||||
|
change_column :contacts, :ident, :string, limit: 255
|
||||||
|
change_column :contacts, :ident_type, :string, limit: 255
|
||||||
|
change_column :contacts, :auth_info, :string, limit: 255
|
||||||
|
change_column :contacts, :name, :string, limit: 255
|
||||||
|
change_column :contacts, :org_name, :string, limit: 255
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
safety_assured do
|
||||||
|
change_column :contacts, :code, :string, limit: nil
|
||||||
|
change_column :contacts, :phone, :string, limit: nil
|
||||||
|
change_column :contacts, :email, :string, limit: nil
|
||||||
|
change_column :contacts, :fax, :string, limit: nil
|
||||||
|
change_column :contacts, :ident, :string, limit: nil
|
||||||
|
change_column :contacts, :ident_type, :string, limit: nil
|
||||||
|
change_column :contacts, :auth_info, :string, limit: nil
|
||||||
|
change_column :contacts, :name, :string, limit: nil
|
||||||
|
change_column :contacts, :org_name, :string, limit: nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -661,17 +661,17 @@ ALTER SEQUENCE public.contact_requests_id_seq OWNED BY public.contact_requests.i
|
||||||
|
|
||||||
CREATE TABLE public.contacts (
|
CREATE TABLE public.contacts (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
code character varying NOT NULL,
|
code character varying(255) NOT NULL,
|
||||||
phone character varying,
|
phone character varying(255),
|
||||||
email character varying NOT NULL,
|
email character varying(255) NOT NULL,
|
||||||
fax character varying,
|
fax character varying(255),
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
ident character varying,
|
ident character varying(255),
|
||||||
ident_type character varying,
|
ident_type character varying(255),
|
||||||
auth_info character varying NOT NULL,
|
auth_info character varying(255) NOT NULL,
|
||||||
name character varying NOT NULL,
|
name character varying(255) NOT NULL,
|
||||||
org_name character varying,
|
org_name character varying(255),
|
||||||
registrar_id integer NOT NULL,
|
registrar_id integer NOT NULL,
|
||||||
creator_str character varying,
|
creator_str character varying,
|
||||||
updator_str character varying,
|
updator_str character varying,
|
||||||
|
@ -5470,6 +5470,8 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20221214073933'),
|
('20221214073933'),
|
||||||
('20221214074252'),
|
('20221214074252'),
|
||||||
('20230531111154'),
|
('20230531111154'),
|
||||||
('20230707084741');
|
('20230707084741'),
|
||||||
|
('20240816091049'),
|
||||||
|
('20240816092636');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
#
|
#
|
||||||
# Note that this schema.rb definition is the authoritative source for your
|
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||||
# database schema. If you need to create the application database on another
|
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
||||||
# system, you should be using db:schema:load, not running all the migrations
|
# be faster and is potentially less error prone than running all of your
|
||||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
# migrations from scratch. Old migrations may fail to apply correctly if those
|
||||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
# migrations use external dependencies or application code.
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ if ENV['COVERAGE']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ENV['RAILS_ENV'] ||= 'test'
|
ENV['RAILS_ENV'] = 'test'
|
||||||
require_relative '../config/environment'
|
require_relative '../config/environment'
|
||||||
require 'rails/test_help'
|
require 'rails/test_help'
|
||||||
require 'minitest/mock'
|
require 'minitest/mock'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue