mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Merge pull request #2400 from internetee/whois-record-registrant-phone
Disclose additional registrant data
This commit is contained in:
commit
1b92bf0d64
13 changed files with 238 additions and 347 deletions
|
@ -3,7 +3,6 @@ module Api
|
|||
class ContactRequestsController < BaseController
|
||||
before_action :authenticate_shared_key
|
||||
|
||||
# POST api/v1/contact_requests/
|
||||
def create
|
||||
return head(:bad_request) if contact_request_params[:email].blank?
|
||||
|
||||
|
@ -19,6 +18,8 @@ module Api
|
|||
process_id(params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def process_id(id)
|
||||
record = ContactRequest.find_by(id: id)
|
||||
return :not_found unless record
|
||||
|
|
|
@ -46,63 +46,26 @@ module Api
|
|||
end
|
||||
|
||||
def update
|
||||
logger.debug 'Received update request'
|
||||
logger.debug params
|
||||
contact = current_user_contacts.find_by!(uuid: params[:uuid])
|
||||
contact.name = params[:name] if params[:name].present?
|
||||
contact.email = params[:email] if params[:email].present?
|
||||
contact.phone = params[:phone] if params[:phone].present?
|
||||
contact = find_contact_and_update_credentials(params[:uuid], params[:name], params[:email], params[:phone])
|
||||
reparsed_request = reparsed_request(request.body.string)
|
||||
disclosed_attributes = reparsed_request[:disclosed_attributes]
|
||||
|
||||
# Needed to support passing empty array, which otherwise gets parsed to nil
|
||||
# https://github.com/rails/rails/pull/13157
|
||||
reparsed_request_json = ActiveSupport::JSON.decode(request.body.string)
|
||||
.with_indifferent_access
|
||||
logger.debug 'Reparsed request is following'
|
||||
logger.debug reparsed_request_json.to_s
|
||||
disclosed_attributes = reparsed_request_json[:disclosed_attributes]
|
||||
|
||||
if disclosed_attributes
|
||||
if disclosed_attributes.present? && contact.org?
|
||||
error_msg = "Legal person's data is visible by default and cannot be concealed." \
|
||||
' Please remove this parameter.'
|
||||
render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
|
||||
return
|
||||
end
|
||||
|
||||
contact.disclosed_attributes = disclosed_attributes
|
||||
end
|
||||
contact.disclosed_attributes = disclosed_attributes if disclosed_attributes
|
||||
publishable = reparsed_request[:registrant_publishable]
|
||||
contact.registrant_publishable = publishable if publishable.in? [true, false]
|
||||
|
||||
logger.debug "Setting.address_processing is set to #{Setting.address_processing}"
|
||||
|
||||
if Setting.address_processing && params[:address]
|
||||
address = Contact::Address.new(params[:address][:street],
|
||||
params[:address][:zip],
|
||||
params[:address][:city],
|
||||
params[:address][:state],
|
||||
params[:address][:country_code])
|
||||
contact.address = address
|
||||
end
|
||||
|
||||
if !Setting.address_processing && params[:address]
|
||||
error_msg = 'Address processing is disabled and therefore cannot be updated'
|
||||
render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return
|
||||
end
|
||||
contact.address = parse_address(params[:address]) if Setting.address_processing && params[:address]
|
||||
render_address_error and return if !Setting.address_processing && params[:address]
|
||||
|
||||
contact.fax = params[:fax] if ENV['fax_enabled'] == 'true' && params[:fax].present?
|
||||
|
||||
logger.debug "ENV['fax_enabled'] is set to #{ENV['fax_enabled']}"
|
||||
if ENV['fax_enabled'] != 'true' && params[:fax]
|
||||
error_msg = 'Fax processing is disabled and therefore cannot be updated'
|
||||
render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return
|
||||
end
|
||||
render_fax_error and return if ENV['fax_enabled'] != 'true' && params[:fax]
|
||||
|
||||
contact.transaction do
|
||||
contact.save!
|
||||
action = current_registrant_user.actions.create!(contact: contact, operation: :update)
|
||||
contact.registrar.notify(action)
|
||||
end
|
||||
contact = update_and_notify!(contact)
|
||||
|
||||
render json: serialize_contact(contact, false)
|
||||
render json: serialize_contact(contact, true)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -136,6 +99,59 @@ module Api
|
|||
def logger
|
||||
Rails.logger
|
||||
end
|
||||
|
||||
def render_disclosed_attributes_error
|
||||
error_msg = "Legal person's data is visible by default and cannot be concealed." \
|
||||
' Please remove this parameter.'
|
||||
render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
|
||||
end
|
||||
|
||||
def parse_address(address)
|
||||
Contact::Address.new(
|
||||
address[:street],
|
||||
address[:zip],
|
||||
address[:city],
|
||||
address[:state],
|
||||
address[:country_code]
|
||||
)
|
||||
end
|
||||
|
||||
def render_address_error
|
||||
error_msg = 'Address processing is disabled and therefore cannot be updated'
|
||||
render json: { errors: [{ address: [error_msg] }] }, status: :bad_request
|
||||
end
|
||||
|
||||
def render_fax_error
|
||||
error_msg = 'Fax processing is disabled and therefore cannot be updated'
|
||||
render json: { errors: [{ address: [error_msg] }] }, status: :bad_request
|
||||
end
|
||||
|
||||
def update_and_notify!(contact)
|
||||
contact.transaction do
|
||||
contact.save!
|
||||
action = current_registrant_user.actions.create!(contact: contact, operation: :update)
|
||||
contact.registrar.notify(action)
|
||||
end
|
||||
|
||||
contact
|
||||
end
|
||||
|
||||
def reparsed_request(request_body)
|
||||
reparsed_request = ActiveSupport::JSON.decode(request_body).with_indifferent_access
|
||||
logger.debug 'Reparsed request is following'
|
||||
logger.debug reparsed_request.to_s
|
||||
|
||||
reparsed_request
|
||||
end
|
||||
|
||||
def find_contact_and_update_credentials(uuid, name, email, phone)
|
||||
contact = current_user_contacts.find_by!(uuid: uuid)
|
||||
contact.name = name if name.present?
|
||||
contact.email = email if email.present?
|
||||
contact.phone = phone if phone.present?
|
||||
|
||||
contact
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,27 +32,40 @@ module Zone::WhoisQueryable
|
|||
# Take note - since this concern only used to zone whois queries, dnssec keys are set to
|
||||
# empty array
|
||||
def domain_vars
|
||||
{ disclaimer: Setting.registry_whois_disclaimer, name: origin,
|
||||
{
|
||||
disclaimer: Setting.registry_whois_disclaimer, name: origin,
|
||||
registered: created_at.try(:to_s, :iso8601), status: ['ok (paid and in zone)'],
|
||||
changed: updated_at.try(:to_s, :iso8601), email: Setting.registry_email,
|
||||
admin_contacts: [contact_vars], tech_contacts: [contact_vars],
|
||||
nameservers: nameserver_vars, dnssec_keys: [], dnssec_changed: nil }
|
||||
nameservers: nameserver_vars, dnssec_keys: [],
|
||||
dnssec_changed: nil
|
||||
}
|
||||
end
|
||||
|
||||
def registrar_vars
|
||||
{ registrar: Setting.registry_juridical_name, registrar_website: Setting.registry_url,
|
||||
registrar_phone: Setting.registry_phone }
|
||||
{
|
||||
registrar: Setting.registry_juridical_name,
|
||||
registrar_website: Setting.registry_url,
|
||||
registrar_phone: Setting.registry_phone,
|
||||
}
|
||||
end
|
||||
|
||||
def registrant_vars
|
||||
{ registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no,
|
||||
registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org',
|
||||
registrant_disclosed_attributes: %w[name email] }
|
||||
{
|
||||
registrant: Setting.registry_juridical_name,
|
||||
registrant_reg_no: Setting.registry_reg_no,
|
||||
registrant_ident_country_code: Setting.registry_country_code,
|
||||
registrant_kind: 'org',
|
||||
registrant_disclosed_attributes: %w[name email phone],
|
||||
}
|
||||
end
|
||||
|
||||
def contact_vars
|
||||
{ name: Setting.registry_invoice_contact, email: Setting.registry_email,
|
||||
disclosed_attributes: %w[name email] }
|
||||
{
|
||||
name: Setting.registry_invoice_contact,
|
||||
email: Setting.registry_email,
|
||||
disclosed_attributes: %w[name email],
|
||||
}
|
||||
end
|
||||
|
||||
def nameserver_vars
|
||||
|
|
|
@ -64,6 +64,8 @@ class Contact < ApplicationRecord
|
|||
|
||||
validate :validate_html
|
||||
validate :validate_country_code, if: -> { self.class.address_processing? }
|
||||
validates :registrant_publishable, inclusion: { in: [true, false] }, if: -> { registrant? }
|
||||
# validates :registrant_publishable, inclusion: { in: [false] }, unless: -> { registrant? }
|
||||
|
||||
after_initialize do
|
||||
self.status_notes = {} if status_notes.nil?
|
||||
|
|
|
@ -15,15 +15,6 @@ class ContactRequest < ApplicationRecord
|
|||
attr_readonly :secret,
|
||||
:valid_to
|
||||
|
||||
def self.save_record(params)
|
||||
contact_request = new(params)
|
||||
contact_request.secret = create_random_secret
|
||||
contact_request.valid_to = set_valid_to_24_hours_from_now
|
||||
contact_request.status = STATUS_NEW
|
||||
contact_request.save!
|
||||
contact_request
|
||||
end
|
||||
|
||||
def update_record(params)
|
||||
self.status = params['status'] if params['status']
|
||||
self.ip_address = params['ip'] if params['ip']
|
||||
|
@ -31,11 +22,22 @@ class ContactRequest < ApplicationRecord
|
|||
save!
|
||||
end
|
||||
|
||||
def self.create_random_secret
|
||||
SecureRandom.hex(64)
|
||||
end
|
||||
class << self
|
||||
def save_record(params)
|
||||
contact_request = new(params)
|
||||
contact_request.secret = create_random_secret
|
||||
contact_request.valid_to = set_valid_to_24_hours_from_now
|
||||
contact_request.status = STATUS_NEW
|
||||
contact_request.save!
|
||||
contact_request
|
||||
end
|
||||
|
||||
def self.set_valid_to_24_hours_from_now
|
||||
(Time.zone.now + 24.hours)
|
||||
def create_random_secret
|
||||
SecureRandom.hex(64)
|
||||
end
|
||||
|
||||
def set_valid_to_24_hours_from_now
|
||||
(Time.zone.now + 24.hours)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,4 +3,8 @@ class Registrant < Contact
|
|||
def epp_code_map
|
||||
{}
|
||||
end
|
||||
|
||||
def publishable?
|
||||
registrant_publishable
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,7 +51,9 @@ class WhoisRecord < ApplicationRecord
|
|||
end
|
||||
|
||||
h[:email] = registrant.email
|
||||
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
|
||||
h[:phone] = registrant.phone
|
||||
h[:registrant_publishable] = registrant.publishable?
|
||||
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
|
||||
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes
|
||||
|
||||
h[:admin_contacts] = []
|
||||
|
@ -78,7 +80,6 @@ class WhoisRecord < ApplicationRecord
|
|||
h[:dnssec_keys] = domain.dnskeys.map { |key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
|
||||
h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil
|
||||
|
||||
|
||||
h
|
||||
end
|
||||
|
||||
|
@ -112,8 +113,10 @@ class WhoisRecord < ApplicationRecord
|
|||
{
|
||||
name: contact.name,
|
||||
email: contact.email,
|
||||
phone: contact.phone,
|
||||
changed: contact.updated_at.try(:to_s, :iso8601),
|
||||
disclosed_attributes: contact.disclosed_attributes,
|
||||
contact_publishable: contact.registrant_publishable?,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddRegistrantPublishableToContacts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :contacts, :registrant_publishable, :boolean, default: false
|
||||
end
|
||||
end
|
197
db/structure.sql
197
db/structure.sql
|
@ -216,7 +216,7 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex
|
|||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_with_oids = false;
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- Name: account_activities; Type: TABLE; Schema: public; Owner: -
|
||||
|
@ -670,7 +670,8 @@ CREATE TABLE public.contacts (
|
|||
up_date timestamp without time zone,
|
||||
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
disclosed_attributes character varying[] DEFAULT '{}'::character varying[] NOT NULL,
|
||||
email_history character varying
|
||||
email_history character varying,
|
||||
registrant_publishable boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
|
@ -955,14 +956,15 @@ CREATE TABLE public.domains (
|
|||
pending_json jsonb,
|
||||
force_delete_date date,
|
||||
statuses character varying[],
|
||||
status_notes public.hstore,
|
||||
statuses_before_force_delete character varying[] DEFAULT '{}'::character varying[],
|
||||
upid integer,
|
||||
up_date timestamp without time zone,
|
||||
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
locked_by_registrant_at timestamp without time zone,
|
||||
force_delete_start timestamp without time zone,
|
||||
force_delete_data public.hstore,
|
||||
json_statuses_history jsonb
|
||||
json_statuses_history jsonb,
|
||||
status_notes public.hstore
|
||||
);
|
||||
|
||||
|
||||
|
@ -2285,74 +2287,6 @@ CREATE SEQUENCE public.payment_orders_id_seq
|
|||
ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.pghero_query_stats (
|
||||
id bigint NOT NULL,
|
||||
database text,
|
||||
"user" text,
|
||||
query text,
|
||||
query_hash bigint,
|
||||
total_time double precision,
|
||||
calls bigint,
|
||||
captured_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.pghero_query_stats_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_space_stats; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.pghero_space_stats (
|
||||
id bigint NOT NULL,
|
||||
database text,
|
||||
schema text,
|
||||
relation text,
|
||||
size bigint,
|
||||
captured_at timestamp without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.pghero_space_stats_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: prices; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -2391,48 +2325,6 @@ CREATE SEQUENCE public.prices_id_seq
|
|||
ALTER SEQUENCE public.prices_id_seq OWNED BY public.prices.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: que_jobs; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.que_jobs (
|
||||
priority smallint DEFAULT 100 NOT NULL,
|
||||
run_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||
job_id bigint NOT NULL,
|
||||
job_class text NOT NULL,
|
||||
args json DEFAULT '[]'::json NOT NULL,
|
||||
error_count integer DEFAULT 0 NOT NULL,
|
||||
last_error text,
|
||||
queue text DEFAULT ''::text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TABLE que_jobs; Type: COMMENT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON TABLE public.que_jobs IS '3';
|
||||
|
||||
|
||||
--
|
||||
-- Name: que_jobs_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.que_jobs_job_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: que_jobs_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.que_jobs_job_id_seq OWNED BY public.que_jobs.job_id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -2713,7 +2605,8 @@ CREATE TABLE public.validation_events (
|
|||
validation_eventable_type character varying,
|
||||
validation_eventable_id bigint,
|
||||
created_at timestamp(6) without time zone NOT NULL,
|
||||
updated_at timestamp(6) without time zone NOT NULL
|
||||
updated_at timestamp(6) without time zone NOT NULL,
|
||||
event_type public.validation_type
|
||||
);
|
||||
|
||||
|
||||
|
@ -3255,20 +3148,6 @@ ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('publi
|
|||
ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: prices id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -3276,13 +3155,6 @@ ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('
|
|||
ALTER TABLE ONLY public.prices ALTER COLUMN id SET DEFAULT nextval('public.prices_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: que_jobs job_id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.que_jobs ALTER COLUMN job_id SET DEFAULT nextval('public.que_jobs_job_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: registrant_verifications id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -3792,22 +3664,6 @@ ALTER TABLE ONLY public.payment_orders
|
|||
ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.pghero_query_stats
|
||||
ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.pghero_space_stats
|
||||
ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -3816,14 +3672,6 @@ ALTER TABLE ONLY public.prices
|
|||
ADD CONSTRAINT prices_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: que_jobs que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.que_jobs
|
||||
ADD CONSTRAINT que_jobs_pkey PRIMARY KEY (queue, priority, run_at, job_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: registrant_verifications registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -4578,20 +4426,6 @@ CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING b
|
|||
CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -4648,6 +4482,13 @@ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_
|
|||
CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_validation_events_on_event_type; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_validation_events_on_event_type ON public.validation_events USING btree (event_type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -5393,11 +5234,9 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20210708131814'),
|
||||
('20210729131100'),
|
||||
('20210729134625'),
|
||||
('20211028122103'),
|
||||
('20211028125245'),
|
||||
('20211029082225'),
|
||||
('20210827185249'),
|
||||
('20211029073644'),
|
||||
('20211124071418'),
|
||||
('20211124084308'),
|
||||
('20211125181033'),
|
||||
('20211125184334'),
|
||||
('20211126085139'),
|
||||
|
@ -5406,6 +5245,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20220113201642'),
|
||||
('20220113220809'),
|
||||
('20220124105717'),
|
||||
('20220216113112'),
|
||||
('20220228093211'),
|
||||
('20220316140727'),
|
||||
('20220406085500'),
|
||||
|
@ -5416,6 +5256,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20220504090512'),
|
||||
('20220524130709'),
|
||||
('20220701113409'),
|
||||
('20220715145808'),
|
||||
('20220818075833'),
|
||||
('20221011061840');
|
||||
|
||||
|
|
|
@ -102,18 +102,19 @@ Update contact.
|
|||
|
||||
#### Parameters
|
||||
|
||||
| Field name | Required | Type | Allowed values | Description |
|
||||
| ---- | --- | --- | --- | --- |
|
||||
| name | false | String | | New name |
|
||||
| email | false | String | | New email |
|
||||
| phone | false | String | | New phone number |
|
||||
| fax | false | String | | New fax number |
|
||||
| address[street] | false | String | | New street name |
|
||||
| address[zip] | false | String | | New zip |
|
||||
| address[city] | false | String | | New city name |
|
||||
| address[state] | false | String | | New state name |
|
||||
| address[country_code] | false | String | | New country code in 2 letter format (ISO 3166-1 alpha-2) |
|
||||
| disclosed_attributes | false | Array | | Possible values: "name", "email"
|
||||
| Field name | Required | Type | Allowed values | Description |
|
||||
| ---- | --- | --- | --- | --- |
|
||||
| name | false | String | | New name |
|
||||
| email | false | String | | New email |
|
||||
| phone | false | String | | New phone number |
|
||||
| fax | false | String | | New fax number |
|
||||
| address[street] | false | String | | New street name |
|
||||
| address[zip] | false | String | | New zip |
|
||||
| address[city] | false | String | | New city name |
|
||||
| address[state] | false | String | | New state name |
|
||||
| address[country_code] | false | String | | New country code in 2 letter format (ISO 3166-1 alpha-2) |
|
||||
| disclosed_attributes | false | Array | | Possible values: "name", "email", "phone" |
|
||||
| registrant_publishable | false | Boolean | | Possible values: true, false |
|
||||
|
||||
|
||||
#### Request
|
||||
|
|
|
@ -31,6 +31,7 @@ module Serializers
|
|||
auth_info: contact.auth_info,
|
||||
statuses: contact.statuses,
|
||||
disclosed_attributes: contact.disclosed_attributes,
|
||||
registrant_publishable: contact.registrant_publishable,
|
||||
}
|
||||
|
||||
obj[:links] = contact.related_domains if @links
|
||||
|
|
|
@ -38,7 +38,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
|
|||
},
|
||||
auth_info: @contact.auth_info,
|
||||
statuses: @contact.statuses,
|
||||
disclosed_attributes: @contact.disclosed_attributes }),
|
||||
disclosed_attributes: @contact.disclosed_attributes,
|
||||
registrant_publishable: @contact.registrant_publishable }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -91,31 +91,18 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
@contact.address
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled_without_address_params
|
||||
Setting.address_processing = true
|
||||
# def test_update_address_when_enabled_without_address_params
|
||||
# Setting.address_processing = false
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
# patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
|
||||
# as: :json,
|
||||
# headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
@contact.address
|
||||
end
|
||||
|
||||
def test_update_address_when_enabled_without_address_params
|
||||
Setting.address_processing = true
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
@contact.reload
|
||||
assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
@contact.address
|
||||
end
|
||||
# assert_response :bad_request
|
||||
# @contact.reload
|
||||
# assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
|
||||
# @contact.address
|
||||
# end
|
||||
|
||||
def test_address_is_optional_when_enabled
|
||||
Setting.address_processing = true
|
||||
|
@ -189,84 +176,98 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
|
|||
assert_empty @contact.disclosed_attributes
|
||||
end
|
||||
|
||||
def test_legal_persons_disclosed_attributes_cannot_be_changed
|
||||
# def test_legal_persons_disclosed_attributes_cannot_be_changed
|
||||
# @contact = contacts(:acme_ltd)
|
||||
|
||||
# # contacts(:acme_ltd).ident
|
||||
# assert_equal '1234567', @contact.ident
|
||||
|
||||
# assert_equal Contact::ORG, @contact.ident_type
|
||||
# assert_equal 'US', @contact.ident_country_code
|
||||
# @contact.update!(disclosed_attributes: %w[])
|
||||
# assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
# assert_no_changes -> { @contact.disclosed_attributes } do
|
||||
# patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
# params: { disclosed_attributes: %w[name] },
|
||||
# as: :json,
|
||||
# headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
# @contact.reload
|
||||
# end
|
||||
# assert_response :bad_request
|
||||
|
||||
# error_msg = "Legal person's data is visible by default and cannot be concealed." \
|
||||
# ' Please remove this parameter.'
|
||||
# assert_equal ({ errors: [{ disclosed_attributes: [error_msg] }] }),
|
||||
# JSON.parse(response.body, symbolize_names: true)
|
||||
# end
|
||||
|
||||
def test_legal_persons_disclosed_attributes_change_when_phone
|
||||
@contact = contacts(:acme_ltd)
|
||||
|
||||
# contacts(:acme_ltd).ident
|
||||
assert_equal '1234567', @contact.ident
|
||||
|
||||
assert_equal Contact::ORG, @contact.ident_type
|
||||
assert_equal 'US', @contact.ident_country_code
|
||||
@contact.update!(disclosed_attributes: %w[])
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
||||
assert_no_changes -> { @contact.disclosed_attributes } do
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[name] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
end
|
||||
assert_response :bad_request
|
||||
|
||||
error_msg = "Legal person's data is visible by default and cannot be concealed." \
|
||||
' Please remove this parameter.'
|
||||
assert_equal ({ errors: [{ disclosed_attributes: [error_msg] }] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_return_contact_details
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[phone] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
assert_equal ({ id: @contact.uuid,
|
||||
name: 'new name',
|
||||
code: @contact.code,
|
||||
fax: @contact.fax,
|
||||
ident: {
|
||||
code: @contact.ident,
|
||||
type: @contact.ident_type,
|
||||
country_code: @contact.ident_country_code,
|
||||
},
|
||||
email: @contact.email,
|
||||
phone: @contact.phone,
|
||||
address: {
|
||||
street: @contact.street,
|
||||
zip: @contact.zip,
|
||||
city: @contact.city,
|
||||
state: @contact.state,
|
||||
country_code: @contact.country_code,
|
||||
},
|
||||
auth_info: @contact.auth_info,
|
||||
statuses: @contact.statuses,
|
||||
disclosed_attributes: @contact.disclosed_attributes }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
@contact.reload
|
||||
|
||||
assert_response :ok
|
||||
assert_equal %w[phone], @contact.disclosed_attributes
|
||||
end
|
||||
|
||||
def test_registrant_publishable_change_when_true
|
||||
@contact = contacts(:acme_ltd)
|
||||
@contact.update!(registrant_publishable: false)
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[], registrant_publishable: true },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
|
||||
assert_response :ok
|
||||
assert @contact.registrant_publishable
|
||||
end
|
||||
|
||||
def test_registrant_publishable_change_when_false
|
||||
@contact = contacts(:acme_ltd)
|
||||
@contact.update!(registrant_publishable: true)
|
||||
|
||||
patch api_v1_registrant_contact_path(@contact.uuid),
|
||||
params: { disclosed_attributes: %w[], registrant_publishable: false },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
@contact.reload
|
||||
|
||||
assert_response :ok
|
||||
assert_not @contact.registrant_publishable
|
||||
end
|
||||
|
||||
def test_errors
|
||||
patch api_v1_registrant_contact_path(@contact.uuid), params: { phone: 'invalid' },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ errors: { phone: ['Phone nr is invalid'] } }), JSON.parse(response.body,
|
||||
symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_org_disclosed_attributes
|
||||
patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
# def test_org_disclosed_attributes
|
||||
# patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
|
||||
# as: :json,
|
||||
# headers: { 'HTTP_AUTHORIZATION' => auth_token }
|
||||
|
||||
assert_response :bad_request
|
||||
# assert_response :bad_request
|
||||
|
||||
err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter."
|
||||
# err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter."
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
response_msg = response_json[:errors][0][:disclosed_attributes][0]
|
||||
# response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
# response_msg = response_json[:errors][0][:disclosed_attributes][0]
|
||||
|
||||
assert_equal err_msg, response_msg
|
||||
end
|
||||
# assert_equal err_msg, response_msg
|
||||
# end
|
||||
|
||||
def test_unmanaged_contact_cannot_be_updated
|
||||
assert_equal 'US-1234', @user.registrant_ident
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue