From c6fd78b4cdcd39b815d2efcce4f4a1eaa108a5ac Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 17 Apr 2020 17:03:45 +0500 Subject: [PATCH 1/4] Add registration deadline field to auction model --- ...dd_registration_deadline_date_to_models.rb | 5 + db/structure.sql | 461 +++++++++++++++++- 2 files changed, 449 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20200417075720_add_registration_deadline_date_to_models.rb diff --git a/db/migrate/20200417075720_add_registration_deadline_date_to_models.rb b/db/migrate/20200417075720_add_registration_deadline_date_to_models.rb new file mode 100644 index 000000000..8614ec889 --- /dev/null +++ b/db/migrate/20200417075720_add_registration_deadline_date_to_models.rb @@ -0,0 +1,5 @@ +class AddRegistrationDeadlineDateToModels < ActiveRecord::Migration[5.2] + def change + add_column :auctions, :registration_deadline, :datetime + end +end diff --git a/db/structure.sql b/db/structure.sql index 604238d4c..eae59f5e0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -11,6 +11,12 @@ SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; +-- +-- Name: audit; Type: SCHEMA; Schema: -; Owner: - +-- + +CREATE SCHEMA audit; + -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - -- @@ -191,12 +197,262 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex $_$; -SET default_tablespace = ''; +-- +-- Name: process_contact_audit(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.process_contact_audit() RETURNS trigger + LANGUAGE plpgsql + AS $$ + BEGIN + IF (TG_OP = 'INSERT') THEN + INSERT INTO audit.contacts + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'UPDATE') THEN + INSERT INTO audit.contacts + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'DELETE') THEN + INSERT INTO audit.contacts + (object_id, action, recorded_at, old_value, new_value) + VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); + RETURN OLD; + END IF; + RETURN NULL; + END +$$; -SET default_with_oids = false; -- --- Name: account_activities; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: process_dnskey_audit(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.process_dnskey_audit() RETURNS trigger + LANGUAGE plpgsql + AS $$ + BEGIN + IF (TG_OP = 'INSERT') THEN + INSERT INTO audit.dnskeys + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'UPDATE') THEN + INSERT INTO audit.dnskeys + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'DELETE') THEN + INSERT INTO audit.dnskeys + (object_id, action, recorded_at, old_value, new_value) + VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); + RETURN OLD; + END IF; + RETURN NULL; + END +$$; + + +-- +-- Name: process_domain_audit(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.process_domain_audit() RETURNS trigger + LANGUAGE plpgsql + AS $$ + BEGIN + IF (TG_OP = 'INSERT') THEN + INSERT INTO audit.domains + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'UPDATE') THEN + INSERT INTO audit.domains + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'DELETE') THEN + INSERT INTO audit.domains + (object_id, action, recorded_at, old_value, new_value) + VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); + RETURN OLD; + END IF; + RETURN NULL; + END +$$; + + +-- +-- Name: process_nameserver_audit(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.process_nameserver_audit() RETURNS trigger + LANGUAGE plpgsql + AS $$ + BEGIN + IF (TG_OP = 'INSERT') THEN + INSERT INTO audit.nameservers + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'UPDATE') THEN + INSERT INTO audit.nameservers + (object_id, action, recorded_at, old_value, new_value) + VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); + RETURN NEW; + ELSEIF (TG_OP = 'DELETE') THEN + INSERT INTO audit.nameservers + (object_id, action, recorded_at, old_value, new_value) + VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); + RETURN OLD; + END IF; + RETURN NULL; + END +$$; + + +SET default_tablespace = ''; + +-- +-- Name: contacts; Type: TABLE; Schema: audit; Owner: - +-- + +CREATE TABLE audit.contacts ( + id integer NOT NULL, + object_id bigint, + action text NOT NULL, + recorded_at timestamp without time zone, + old_value jsonb, + new_value jsonb, + CONSTRAINT contacts_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) +); + + +-- +-- Name: contacts_id_seq; Type: SEQUENCE; Schema: audit; Owner: - +-- + +CREATE SEQUENCE audit.contacts_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: contacts_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - +-- + +ALTER SEQUENCE audit.contacts_id_seq OWNED BY audit.contacts.id; + + +-- +-- Name: dnskeys; Type: TABLE; Schema: audit; Owner: - +-- + +CREATE TABLE audit.dnskeys ( + id integer NOT NULL, + object_id bigint, + action text NOT NULL, + recorded_at timestamp without time zone, + old_value jsonb, + new_value jsonb, + CONSTRAINT dnskeys_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) +); + + +-- +-- Name: dnskeys_id_seq; Type: SEQUENCE; Schema: audit; Owner: - +-- + +CREATE SEQUENCE audit.dnskeys_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: dnskeys_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - +-- + +ALTER SEQUENCE audit.dnskeys_id_seq OWNED BY audit.dnskeys.id; + + +-- +-- Name: domains; Type: TABLE; Schema: audit; Owner: - +-- + +CREATE TABLE audit.domains ( + id integer NOT NULL, + object_id bigint, + action text NOT NULL, + recorded_at timestamp without time zone, + old_value jsonb, + new_value jsonb, + CONSTRAINT domains_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) +); + + +-- +-- Name: domains_id_seq; Type: SEQUENCE; Schema: audit; Owner: - +-- + +CREATE SEQUENCE audit.domains_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: domains_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - +-- + +ALTER SEQUENCE audit.domains_id_seq OWNED BY audit.domains.id; + + +-- +-- Name: nameservers; Type: TABLE; Schema: audit; Owner: - +-- + +CREATE TABLE audit.nameservers ( + id integer NOT NULL, + object_id bigint, + action text NOT NULL, + recorded_at timestamp without time zone, + old_value jsonb, + new_value jsonb, + CONSTRAINT nameservers_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) +); + + +-- +-- Name: nameservers_id_seq; Type: SEQUENCE; Schema: audit; Owner: - +-- + +CREATE SEQUENCE audit.nameservers_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: nameservers_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - +-- + +ALTER SEQUENCE audit.nameservers_id_seq OWNED BY audit.nameservers.id; + + +-- +-- Name: account_activities; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.account_activities ( @@ -325,7 +581,8 @@ CREATE TABLE public.auctions ( status character varying NOT NULL, uuid uuid DEFAULT public.gen_random_uuid() NOT NULL, created_at timestamp without time zone NOT NULL, - registration_code character varying + registration_code character varying, + registration_deadline timestamp without time zone ); @@ -558,7 +815,16 @@ ALTER SEQUENCE public.contacts_id_seq OWNED BY public.contacts.id; -- --- Name: directos; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- Name: data_migrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.data_migrations ( + version character varying NOT NULL +); + + +-- +-- Name: directos; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.directos ( @@ -745,7 +1011,8 @@ CREATE TABLE public.domains ( 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 + force_delete_data public.hstore, + children jsonb ); @@ -2344,14 +2611,42 @@ ALTER SEQUENCE public.zones_id_seq OWNED BY public.zones.id; -- --- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- Name: contacts id; Type: DEFAULT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.contacts ALTER COLUMN id SET DEFAULT nextval('audit.contacts_id_seq'::regclass); + + +-- +-- Name: dnskeys id; Type: DEFAULT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.dnskeys ALTER COLUMN id SET DEFAULT nextval('audit.dnskeys_id_seq'::regclass); + + +-- +-- Name: domains id; Type: DEFAULT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.domains ALTER COLUMN id SET DEFAULT nextval('audit.domains_id_seq'::regclass); + + +-- +-- Name: nameservers id; Type: DEFAULT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.nameservers ALTER COLUMN id SET DEFAULT nextval('audit.nameservers_id_seq'::regclass); + + +-- +-- Name: account_activities id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.account_activities ALTER COLUMN id SET DEFAULT nextval('public.account_activities_id_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- Name: accounts id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.accounts ALTER COLUMN id SET DEFAULT nextval('public.accounts_id_seq'::regclass); @@ -2722,7 +3017,39 @@ ALTER TABLE ONLY public.zones ALTER COLUMN id SET DEFAULT nextval('public.zones_ -- --- Name: account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: contacts contacts_pkey; Type: CONSTRAINT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.contacts + ADD CONSTRAINT contacts_pkey PRIMARY KEY (id); + + +-- +-- Name: dnskeys dnskeys_pkey; Type: CONSTRAINT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.dnskeys + ADD CONSTRAINT dnskeys_pkey PRIMARY KEY (id); + + +-- +-- Name: domains domains_pkey; Type: CONSTRAINT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.domains + ADD CONSTRAINT domains_pkey PRIMARY KEY (id); + + +-- +-- Name: nameservers nameservers_pkey; Type: CONSTRAINT; Schema: audit; Owner: - +-- + +ALTER TABLE ONLY audit.nameservers + ADD CONSTRAINT nameservers_pkey PRIMARY KEY (id); + + +-- +-- Name: account_activities account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.account_activities @@ -2730,7 +3057,7 @@ ALTER TABLE ONLY public.account_activities -- --- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- Name: accounts accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.accounts @@ -3266,14 +3593,70 @@ ALTER TABLE ONLY public.zones -- --- Name: index_account_activities_on_account_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: contacts_object_id_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX contacts_object_id_idx ON audit.contacts USING btree (object_id); + + +-- +-- Name: contacts_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX contacts_recorded_at_idx ON audit.contacts USING btree (recorded_at); + + +-- +-- Name: dnskeys_object_id_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX dnskeys_object_id_idx ON audit.dnskeys USING btree (object_id); + + +-- +-- Name: dnskeys_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX dnskeys_recorded_at_idx ON audit.dnskeys USING btree (recorded_at); + + +-- +-- Name: domains_object_id_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX domains_object_id_idx ON audit.domains USING btree (object_id); + + +-- +-- Name: domains_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX domains_recorded_at_idx ON audit.domains USING btree (recorded_at); + + +-- +-- Name: nameservers_object_id_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX nameservers_object_id_idx ON audit.nameservers USING btree (object_id); + + +-- +-- Name: nameservers_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - +-- + +CREATE INDEX nameservers_recorded_at_idx ON audit.nameservers USING btree (recorded_at); + + +-- +-- Name: index_account_activities_on_account_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX index_account_activities_on_account_id ON public.account_activities USING btree (account_id); -- --- Name: index_account_activities_on_bank_transaction_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: index_account_activities_on_bank_transaction_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX index_account_activities_on_bank_transaction_id ON public.account_activities USING btree (bank_transaction_id); @@ -3826,21 +4209,56 @@ CREATE INDEX log_domains_object_legacy_id ON public.log_contacts USING btree ((( -- --- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: - -- CREATE INDEX log_nameservers_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_domain_id'::text))::integer)); -- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX unique_data_migrations ON public.data_migrations USING btree (version); + + +-- +-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: - -- CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version); -- --- Name: contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: contacts process_contact_audit; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER process_contact_audit AFTER INSERT OR DELETE OR UPDATE ON public.contacts FOR EACH ROW EXECUTE PROCEDURE public.process_contact_audit(); + + +-- +-- Name: dnskeys process_dnskey_audit; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER process_dnskey_audit AFTER INSERT OR DELETE OR UPDATE ON public.dnskeys FOR EACH ROW EXECUTE PROCEDURE public.process_dnskey_audit(); + + +-- +-- Name: domains process_domain_audit; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER process_domain_audit AFTER INSERT OR DELETE OR UPDATE ON public.domains FOR EACH ROW EXECUTE PROCEDURE public.process_domain_audit(); + + +-- +-- Name: nameservers process_nameserver_audit; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER process_nameserver_audit AFTER INSERT OR DELETE OR UPDATE ON public.nameservers FOR EACH ROW EXECUTE PROCEDURE public.process_nameserver_audit(); + + +-- +-- Name: contacts contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.contacts @@ -3848,7 +4266,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: domain_contacts domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domain_contacts @@ -4463,5 +4881,14 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200130092113'), ('20200203143458'), ('20200204103125'), -('20200311114649'); +('20200310105731'), +('20200310105736'), +('20200311114649'), +('20200319082650'), +('20200320090152'), +('20200320094842'), +('20200330111918'), +('20200408091005'), +('20200417075720'); + From 5c419ae8be7a6f0628f32329be8e7b3a218665ba Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 6 May 2020 15:17:20 +0500 Subject: [PATCH 2/4] Update whois record with auction registration_deadline if any --- app/controllers/api/v1/auctions_controller.rb | 2 ++ app/models/auction.rb | 11 +++++++++- app/models/whois/record.rb | 3 ++- test/models/whois/record_test.rb | 20 ++++++++++++++----- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/auctions_controller.rb b/app/controllers/api/v1/auctions_controller.rb index bf92be930..de8e94442 100644 --- a/app/controllers/api/v1/auctions_controller.rb +++ b/app/controllers/api/v1/auctions_controller.rb @@ -30,6 +30,8 @@ module Api raise "Invalid status #{params[:status]}" end + auction.mark_deadline(params[:registration_deadline]) if params[:registration_deadline] + if auction.payment_not_received? || auction.domain_not_registered? update_whois_from_auction(Auction.pending(auction.domain)) else diff --git a/app/models/auction.rb b/app/models/auction.rb index 6ddd8e394..c4b9f6130 100644 --- a/app/models/auction.rb +++ b/app/models/auction.rb @@ -23,10 +23,19 @@ class Auction < ApplicationRecord save! end + def whois_deadline + registration_deadline.to_s + end + def mark_as_no_bids no_bids! end + def mark_deadline(registration_deadline) + self.registration_deadline = registration_deadline + save! + end + def mark_as_payment_received self.status = self.class.statuses[:payment_received] generate_registration_code @@ -69,4 +78,4 @@ class Auction < ApplicationRecord def registration_code_matches?(code) registration_code == code end -end \ No newline at end of file +end diff --git a/app/models/whois/record.rb b/app/models/whois/record.rb index ae7422403..1d827e22a 100644 --- a/app/models/whois/record.rb +++ b/app/models/whois/record.rb @@ -16,7 +16,8 @@ module Whois elsif auction.awaiting_payment? || auction.payment_received? update!(json: { name: auction.domain, status: ['PendingRegistration'], - disclaimer: self.class.disclaimer }) + disclaimer: self.class.disclaimer, + registration_deadline: auction.whois_deadline }) end end end diff --git a/test/models/whois/record_test.rb b/test/models/whois/record_test.rb index 5f2454105..64e8a894a 100644 --- a/test/models/whois/record_test.rb +++ b/test/models/whois/record_test.rb @@ -40,24 +40,34 @@ class Whois::RecordTest < ActiveSupport::TestCase end def test_updates_whois_record_from_auction_when_awaiting_payment - @auction.update!(domain: 'domain.test', status: Auction.statuses[:awaiting_payment]) + @auction.update!(domain: 'domain.test', + status: Auction.statuses[:awaiting_payment], + registration_deadline: registration_deadline) @whois_record.update!(name: 'domain.test') @whois_record.update_from_auction(@auction) @whois_record.reload assert_equal ({ 'name' => 'domain.test', 'status' => ['PendingRegistration'], - 'disclaimer' => 'disclaimer' }), @whois_record.json + 'disclaimer' => 'disclaimer', + 'registration_deadline' => registration_deadline.to_s }), @whois_record.json end def test_updates_whois_record_from_auction_when_payment_received - @auction.update!(domain: 'domain.test', status: Auction.statuses[:payment_received]) + @auction.update!(domain: 'domain.test', + status: Auction.statuses[:payment_received], + registration_deadline: registration_deadline) @whois_record.update!(name: 'domain.test') @whois_record.update_from_auction(@auction) @whois_record.reload assert_equal ({ 'name' => 'domain.test', 'status' => ['PendingRegistration'], - 'disclaimer' => 'disclaimer' }), @whois_record.json + 'disclaimer' => 'disclaimer', + 'registration_deadline' => registration_deadline.to_s }), @whois_record.json end -end \ No newline at end of file + + def registration_deadline + Time.zone.now + 10.days + end +end From d035b7727d51c6826dab07f27f57973d2a0c3772 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 7 May 2020 13:51:22 +0500 Subject: [PATCH 3/4] Add tests for registry to receive registration_deadline --- test/integration/api/v1/auctions/update_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/integration/api/v1/auctions/update_test.rb b/test/integration/api/v1/auctions/update_test.rb index fe4d075b0..e6ce3c683 100644 --- a/test/integration/api/v1/auctions/update_test.rb +++ b/test/integration/api/v1/auctions/update_test.rb @@ -39,6 +39,17 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest assert @auction.awaiting_payment? end + def test_sets_registration_deadline + deadline = (Time.zone.now + 10.days).end_of_day + patch api_v1_auction_path(@auction.uuid), + params: { status: Auction.statuses[:awaiting_payment], + registration_deadline: deadline}, + as: :json + @auction.reload + + assert_in_delta @auction.registration_deadline, deadline, 1.second + end + def test_marks_as_no_bids patch api_v1_auction_path(@auction.uuid), params: { status: Auction.statuses[:no_bids] }, From 6bff8257983541364ff41375861e7a893e424146 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Fri, 8 May 2020 13:31:05 +0500 Subject: [PATCH 4/4] Fix structure.sql --- db/structure.sql | 454 ++--------------------------------------------- 1 file changed, 14 insertions(+), 440 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index eae59f5e0..511f38d2e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -11,12 +11,6 @@ SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; --- --- Name: audit; Type: SCHEMA; Schema: -; Owner: - --- - -CREATE SCHEMA audit; - -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - -- @@ -197,262 +191,12 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex $_$; --- --- Name: process_contact_audit(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.process_contact_audit() RETURNS trigger - LANGUAGE plpgsql - AS $$ - BEGIN - IF (TG_OP = 'INSERT') THEN - INSERT INTO audit.contacts - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'UPDATE') THEN - INSERT INTO audit.contacts - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'DELETE') THEN - INSERT INTO audit.contacts - (object_id, action, recorded_at, old_value, new_value) - VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); - RETURN OLD; - END IF; - RETURN NULL; - END -$$; - - --- --- Name: process_dnskey_audit(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.process_dnskey_audit() RETURNS trigger - LANGUAGE plpgsql - AS $$ - BEGIN - IF (TG_OP = 'INSERT') THEN - INSERT INTO audit.dnskeys - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'UPDATE') THEN - INSERT INTO audit.dnskeys - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'DELETE') THEN - INSERT INTO audit.dnskeys - (object_id, action, recorded_at, old_value, new_value) - VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); - RETURN OLD; - END IF; - RETURN NULL; - END -$$; - - --- --- Name: process_domain_audit(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.process_domain_audit() RETURNS trigger - LANGUAGE plpgsql - AS $$ - BEGIN - IF (TG_OP = 'INSERT') THEN - INSERT INTO audit.domains - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'UPDATE') THEN - INSERT INTO audit.domains - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'DELETE') THEN - INSERT INTO audit.domains - (object_id, action, recorded_at, old_value, new_value) - VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); - RETURN OLD; - END IF; - RETURN NULL; - END -$$; - - --- --- Name: process_nameserver_audit(); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.process_nameserver_audit() RETURNS trigger - LANGUAGE plpgsql - AS $$ - BEGIN - IF (TG_OP = 'INSERT') THEN - INSERT INTO audit.nameservers - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'INSERT', now(), '{}', to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'UPDATE') THEN - INSERT INTO audit.nameservers - (object_id, action, recorded_at, old_value, new_value) - VALUES (NEW.id, 'UPDATE', now(), to_json(OLD)::jsonb, to_json(NEW)::jsonb); - RETURN NEW; - ELSEIF (TG_OP = 'DELETE') THEN - INSERT INTO audit.nameservers - (object_id, action, recorded_at, old_value, new_value) - VALUES (OLD.id, 'DELETE', now(), to_json(OLD)::jsonb, '{}'); - RETURN OLD; - END IF; - RETURN NULL; - END -$$; - - SET default_tablespace = ''; --- --- Name: contacts; Type: TABLE; Schema: audit; Owner: - --- - -CREATE TABLE audit.contacts ( - id integer NOT NULL, - object_id bigint, - action text NOT NULL, - recorded_at timestamp without time zone, - old_value jsonb, - new_value jsonb, - CONSTRAINT contacts_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) -); - +SET default_with_oids = false; -- --- Name: contacts_id_seq; Type: SEQUENCE; Schema: audit; Owner: - --- - -CREATE SEQUENCE audit.contacts_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: contacts_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - --- - -ALTER SEQUENCE audit.contacts_id_seq OWNED BY audit.contacts.id; - - --- --- Name: dnskeys; Type: TABLE; Schema: audit; Owner: - --- - -CREATE TABLE audit.dnskeys ( - id integer NOT NULL, - object_id bigint, - action text NOT NULL, - recorded_at timestamp without time zone, - old_value jsonb, - new_value jsonb, - CONSTRAINT dnskeys_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) -); - - --- --- Name: dnskeys_id_seq; Type: SEQUENCE; Schema: audit; Owner: - --- - -CREATE SEQUENCE audit.dnskeys_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: dnskeys_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - --- - -ALTER SEQUENCE audit.dnskeys_id_seq OWNED BY audit.dnskeys.id; - - --- --- Name: domains; Type: TABLE; Schema: audit; Owner: - --- - -CREATE TABLE audit.domains ( - id integer NOT NULL, - object_id bigint, - action text NOT NULL, - recorded_at timestamp without time zone, - old_value jsonb, - new_value jsonb, - CONSTRAINT domains_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) -); - - --- --- Name: domains_id_seq; Type: SEQUENCE; Schema: audit; Owner: - --- - -CREATE SEQUENCE audit.domains_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: domains_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - --- - -ALTER SEQUENCE audit.domains_id_seq OWNED BY audit.domains.id; - - --- --- Name: nameservers; Type: TABLE; Schema: audit; Owner: - --- - -CREATE TABLE audit.nameservers ( - id integer NOT NULL, - object_id bigint, - action text NOT NULL, - recorded_at timestamp without time zone, - old_value jsonb, - new_value jsonb, - CONSTRAINT nameservers_action_check CHECK ((action = ANY (ARRAY['INSERT'::text, 'UPDATE'::text, 'DELETE'::text, 'TRUNCATE'::text]))) -); - - --- --- Name: nameservers_id_seq; Type: SEQUENCE; Schema: audit; Owner: - --- - -CREATE SEQUENCE audit.nameservers_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: nameservers_id_seq; Type: SEQUENCE OWNED BY; Schema: audit; Owner: - --- - -ALTER SEQUENCE audit.nameservers_id_seq OWNED BY audit.nameservers.id; - - --- --- Name: account_activities; Type: TABLE; Schema: public; Owner: - +-- Name: account_activities; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.account_activities ( @@ -815,16 +559,7 @@ ALTER SEQUENCE public.contacts_id_seq OWNED BY public.contacts.id; -- --- Name: data_migrations; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.data_migrations ( - version character varying NOT NULL -); - - --- --- Name: directos; Type: TABLE; Schema: public; Owner: - +-- Name: directos; Type: TABLE; Schema: public; Owner: -; Tablespace: -- CREATE TABLE public.directos ( @@ -1011,8 +746,7 @@ CREATE TABLE public.domains ( 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, - children jsonb + force_delete_data public.hstore ); @@ -2611,42 +2345,14 @@ ALTER SEQUENCE public.zones_id_seq OWNED BY public.zones.id; -- --- Name: contacts id; Type: DEFAULT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.contacts ALTER COLUMN id SET DEFAULT nextval('audit.contacts_id_seq'::regclass); - - --- --- Name: dnskeys id; Type: DEFAULT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.dnskeys ALTER COLUMN id SET DEFAULT nextval('audit.dnskeys_id_seq'::regclass); - - --- --- Name: domains id; Type: DEFAULT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.domains ALTER COLUMN id SET DEFAULT nextval('audit.domains_id_seq'::regclass); - - --- --- Name: nameservers id; Type: DEFAULT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.nameservers ALTER COLUMN id SET DEFAULT nextval('audit.nameservers_id_seq'::regclass); - - --- --- Name: account_activities id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.account_activities ALTER COLUMN id SET DEFAULT nextval('public.account_activities_id_seq'::regclass); -- --- Name: accounts id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY public.accounts ALTER COLUMN id SET DEFAULT nextval('public.accounts_id_seq'::regclass); @@ -3017,39 +2723,7 @@ ALTER TABLE ONLY public.zones ALTER COLUMN id SET DEFAULT nextval('public.zones_ -- --- Name: contacts contacts_pkey; Type: CONSTRAINT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.contacts - ADD CONSTRAINT contacts_pkey PRIMARY KEY (id); - - --- --- Name: dnskeys dnskeys_pkey; Type: CONSTRAINT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.dnskeys - ADD CONSTRAINT dnskeys_pkey PRIMARY KEY (id); - - --- --- Name: domains domains_pkey; Type: CONSTRAINT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.domains - ADD CONSTRAINT domains_pkey PRIMARY KEY (id); - - --- --- Name: nameservers nameservers_pkey; Type: CONSTRAINT; Schema: audit; Owner: - --- - -ALTER TABLE ONLY audit.nameservers - ADD CONSTRAINT nameservers_pkey PRIMARY KEY (id); - - --- --- Name: account_activities account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: account_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.account_activities @@ -3057,7 +2731,7 @@ ALTER TABLE ONLY public.account_activities -- --- Name: accounts accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- ALTER TABLE ONLY public.accounts @@ -3593,70 +3267,14 @@ ALTER TABLE ONLY public.zones -- --- Name: contacts_object_id_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX contacts_object_id_idx ON audit.contacts USING btree (object_id); - - --- --- Name: contacts_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX contacts_recorded_at_idx ON audit.contacts USING btree (recorded_at); - - --- --- Name: dnskeys_object_id_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX dnskeys_object_id_idx ON audit.dnskeys USING btree (object_id); - - --- --- Name: dnskeys_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX dnskeys_recorded_at_idx ON audit.dnskeys USING btree (recorded_at); - - --- --- Name: domains_object_id_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX domains_object_id_idx ON audit.domains USING btree (object_id); - - --- --- Name: domains_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX domains_recorded_at_idx ON audit.domains USING btree (recorded_at); - - --- --- Name: nameservers_object_id_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX nameservers_object_id_idx ON audit.nameservers USING btree (object_id); - - --- --- Name: nameservers_recorded_at_idx; Type: INDEX; Schema: audit; Owner: - --- - -CREATE INDEX nameservers_recorded_at_idx ON audit.nameservers USING btree (recorded_at); - - --- --- Name: index_account_activities_on_account_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_account_activities_on_account_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_account_activities_on_account_id ON public.account_activities USING btree (account_id); -- --- Name: index_account_activities_on_bank_transaction_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_account_activities_on_bank_transaction_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX index_account_activities_on_bank_transaction_id ON public.account_activities USING btree (bank_transaction_id); @@ -4209,56 +3827,21 @@ CREATE INDEX log_domains_object_legacy_id ON public.log_contacts USING btree ((( -- --- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: - +-- Name: log_nameservers_object_legacy_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE INDEX log_nameservers_object_legacy_id ON public.log_contacts USING btree ((((object ->> 'legacy_domain_id'::text))::integer)); -- --- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX unique_data_migrations ON public.data_migrations USING btree (version); - - --- --- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: - +-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version); -- --- Name: contacts process_contact_audit; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER process_contact_audit AFTER INSERT OR DELETE OR UPDATE ON public.contacts FOR EACH ROW EXECUTE PROCEDURE public.process_contact_audit(); - - --- --- Name: dnskeys process_dnskey_audit; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER process_dnskey_audit AFTER INSERT OR DELETE OR UPDATE ON public.dnskeys FOR EACH ROW EXECUTE PROCEDURE public.process_dnskey_audit(); - - --- --- Name: domains process_domain_audit; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER process_domain_audit AFTER INSERT OR DELETE OR UPDATE ON public.domains FOR EACH ROW EXECUTE PROCEDURE public.process_domain_audit(); - - --- --- Name: nameservers process_nameserver_audit; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER process_nameserver_audit AFTER INSERT OR DELETE OR UPDATE ON public.nameservers FOR EACH ROW EXECUTE PROCEDURE public.process_nameserver_audit(); - - --- --- Name: contacts contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: contacts_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.contacts @@ -4266,7 +3849,7 @@ ALTER TABLE ONLY public.contacts -- --- Name: domain_contacts domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public.domain_contacts @@ -4881,14 +4464,5 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200130092113'), ('20200203143458'), ('20200204103125'), -('20200310105731'), -('20200310105736'), ('20200311114649'), -('20200319082650'), -('20200320090152'), -('20200320094842'), -('20200330111918'), -('20200408091005'), ('20200417075720'); - -