Commit graph

117 commits

Author SHA1 Message Date
Shicong Huang
b05f6b4ba3
Add SQL schema for DelegationSignerData (#713)
* Add SQL schema for DelegationSignerData

* Remove join table

* Rebased on HEAD

* Rebase on head
2020-10-09 10:22:31 -04:00
Shicong Huang
17a1387184
Disable auto-generation on id for HostHistory and ContactHistory (#827) 2020-10-08 12:30:54 -04:00
Michael Muller
299b093f78
Correctly restore composite VKeys in DomainContent (#825)
* Restore composite vkeys in DomainContent

PollMessage/BillingEvent vkeys in DomainContent must have their ofy keys
restored from other fields in DomainContent (namely the repo id and their
specific history event ids).

Add PostLoad methods to DomainContent and DomainHistory to do the restoration.

* Fixes for review.

* Deal with foreign-key cycles
2020-10-07 12:42:01 -04:00
Shicong Huang
95f6ccc657
Fix vkey reconstruction for PollMessage (#823)
* Fix vkey reconstruction for PollMessage

* Add foreign key

* Rebase on HEAD
2020-10-05 10:35:40 -04:00
Shicong Huang
fd40a6a2b9
Use composite primary key for HostHistory and ContactHistory (#809)
* Use composite primary key for HostHistory and ContactHistory

* Update flyway file version

* Make getters private

* Add javadoc

* Rebase on HEAD
2020-10-01 11:01:57 -04:00
Michael Muller
6f75dfd116
Create a flyway index file and verify correctness (#819)
* Create a flyway index file and verify correctness

Create an index file (flyway.txt) containing the names of all of the flyway
files and verify that it is ordered and in sync with the actual contents of
the flyway directory.  Also provide a target (generateFlywayIndex) to
automatically generate it.

The purpose of flyway.txt is to cause a merge conflict in the event that two
different developers add a flyway file with the same sequence number, an event
which has occurred multiple times.
2020-09-29 11:26:05 -04:00
Weimin Yu
553d5717cb
Enhance the test for forbidden Schema changes (#815)
* Enhance the test for forbidden Schema changes

Current test is git-based. It is difficult to maintain and does not
catch out-of-order version numbers. It is also more aggressive than
necessary, failing on changes to submitted scripts that have not been
deployed yet.

The new test starts a database, deploys the current schema to it,
then deploys the set of Flyway scripts in this repository to the database.
2020-09-24 12:31:08 -04:00
Shicong Huang
1056fdbb64
Fix VKey reconstruction issue in BillingEvent (#805)
* Fix VKey reconstruction issue in BillingEvent

* Rebase on head
2020-09-23 19:04:58 -04:00
gbrodman
2a5d9c8ef5
Allow explicitly for null EPP resources in History objects (#790)
* Allow explicitly for null EPP resources in History objects

* Repo IDs should always be nonnull

* Add a test to verify loading / comparison of legacy HistoryEntry objects

* Format javadoc + annotations

* More javadoc changes

* V52 -> V56

* V56 -> V57

* saveNew -> insert in new tests
2020-09-21 15:50:15 -04:00
gbrodman
597f5746a4
Rename V54 -> V56 on host table rename (#811) 2020-09-21 13:34:37 -04:00
Michael Muller
5bff53a711
Rename HostResource table to Host (#804)
* Rename HostResource table to Host

* Convert drop/creates to renames
2020-09-21 11:43:25 -04:00
gbrodman
3b841bbb5b
Add domain-specific history fields to DomainHistory objects (#794)
* Add domain-specific history fields to DomainHistory objects

* Add javadoc for Hibernate-only methods

* V52 -> V54

* Use only a single DomainTransactionRecord table

* Add nullables and fix up a comment

* V54 -> V55

* Regenerate db schema

* Regen SQL file
2020-09-18 15:55:17 -04:00
gbrodman
798879d031
Fix semantic merge conflict in Registry (#810)
* Fix semantic merge conflict in Registry
2020-09-18 14:40:11 -04:00
sarahcaseybot
7468a9915b
Migrate Registry objects to a TLD table in Cloud SQL (#803)
* Add TLD table

* Change reservedLists to array

* Change ReservedLists back to a set

* Rename reservedListKeyConverter to ReservedListKeySetConverter

* Add a postload method
2020-09-17 12:47:50 -04:00
Shicong Huang
5ab0f97351
Add and use temp_history_id_sequence to avoid release error (#795) 2020-09-11 12:25:08 -04:00
Michael Muller
36482ce94f
Fix the billing occurrence foreign key (#797)
* Fix the billing occurrence foreign key

Fix the Domain.billing_occurrence_id foreign key constraint to reference the
correct table (BillingRecurrence, not BillingEvent).
2020-09-10 12:02:24 -04:00
Shicong Huang
cdf2c7f7cb
Merge ClaimsList into ClaimsListShard (#694)
* Merge ClaimsList into ClaimsListShard

* Add a TODO to rename the class

* Rebase on HEAD

* Improve javadoc
2020-09-03 11:18:40 -04:00
Shicong Huang
ecafebdc3d
Use composite primary key for DomainHistory (#767)
* Use composite primary key for DomainHistory

* Move History table's SequenceGenerator to orm.xml

* Rebase on HEAD and remove default value for key in History tables

* Use primitive type for id.

* Revert the cache change
2020-09-03 10:21:23 -04:00
Shicong Huang
bb2f35b673
Use composite primary key for RegistrarContact (#761)
* Use composite primary key for RegistrarPoc

* Increase the serial number for flyway file and resolve comments

* Rebase on HEAD

* Rebase on HEAD
2020-08-21 11:17:36 -04:00
gbrodman
5c30ef7086
Add a SQL schema to AllocationToken (#763)
* Add a SQL schema to AllocationToken

* Respond to CR

- rename field in tests
- rename allowed_registrar_ids field
- remove unnecessary db load in GATC

* Add TODO for HistoryEntry vkeys

* Run autoformat

* V48 -> V49
2020-08-20 20:18:34 -04:00
Weimin Yu
70274da971
Allow schema push in alpha and crash (#771)
* Allow schema push in alpha and crash

This allows unsubmitted changes to be tested in alpha and
crash.

Also updated the README file and reformatted with the internal
mdformat tool.
2020-08-19 00:05:57 -04:00
Ben McIlwain
d873b9f69a
Add autoRenewEndTime field to Domain entity (#765)
* Add autoRenewEndTime field to Domain entity

This is the first step towards allowing administrators to selectively disable autorenew.
2020-08-13 10:40:11 -04:00
gbrodman
44d7ad61c0
Remove spec11 domain foreign key (#757)
We'll want this eventually but until the Domain SQL table is populated,
we can't rely on domains' existence.
2020-08-10 14:55:40 -04:00
Weimin Yu
85970daa70
Make index on contactId not unique (#751)
* Make index on contactId not unique

This column cannot be unique due to the fundamantal design of the domain
model.
2020-08-10 13:09:37 -04:00
Shicong Huang
486bf32353
Add SQL schema for GracePeriod (#709)
* Add SQL schema for GracePeriod

* Remove the join table

* Add a domainRepoId in GracePeriod

* Move the clone logic to GracePeriod

* Rebase on HEAD
2020-08-06 10:26:19 -04:00
gbrodman
d8ec6294c3
Refactor DomainBase into DomainContent and create DomainHistory (#668)
* Refactor DomainBase into DomainContent and create DomainHistory

This is similar to #587 and #634, but for domains.

One caveat is that we refactor some of the Domain* instance methods to
be static so that they can be called either on DomainBase or
DomainContent, returning the appropriate type each time.

Note that we set DomainHistory to use the same revision ID sequence as
HostHistory and ContactHistory.

In addition, we refactor the tests to the History objects a bit to
reduce duplicate code and because we cannot guarantee yet that the
SQL-stored VKeys are symmetrical -- the ofy keys are not persisted at
the moment.

In addition, rename the DomainHost table to the default Domain_nsHosts so that it automatically creates two separate nsHosts tables for us -- one foreign-keyed on the domain repo ID, and one foreign-keyed on the history revision ID

* Use access hackery to allow manual names for nsHosts tables

* Clean up post merge artifacts

* Add unused setters that Hibernate requires

* Fix the tests and semantic merge conflicts

* Change ns_hosts to ns_host everywhere

* Rename ns_host to host_repo_id

* V42 -> V44
2020-08-03 17:36:12 -04:00
Lai Jiang
9304e2f421
Enable Java 11 features (#737)
* Enable Java 11 features

As of this commit Java 11 must be used to build. The generated bytecode
is still at Java 8 due to App Engine task queue limit.

Also fixed a bug where the included google-java-format jar file is not
used, requiring the user to install it separately.

See: https://cloud.google.com/appengine/docs/standard/java/taskqueue/push
2020-08-03 16:08:29 -04:00
sarahcaseybot
4ad7f9734d
Add IntervalDescriptor and change DurationConverter to use Interval datatype (#653)
* Add use of interval data type

* Add support for Millis

* Use Java-object type

* Change column type for relock_duration

* add years and months

* Add tests for hours, minutes, and seconds

* Add javadoc describing how joda duration is stored

* Add test for lots of days
2020-08-03 12:42:34 -04:00
Ben McIlwain
16a31e460c
Get rid of all remaining JUnit 4 usages except in prober & proxy (#731)
* Get rid of all remaining JUnit 4 usages except in prober & proxy subprojects

Caveat: Test suites aren't yet implemented in JUnit 5 so we still use the ones
from JUnit 5 in the core subproject.

* Fix some build errors
2020-07-30 20:29:00 -04:00
Lai Jiang
8750c07fef
Clean up generated sources configuration (#724)
1. The Gradle apt plugin is no longer needed to process annotations.
2. Without the apt plugin, Gralde puts the source files generated by
   annotation processors in build/generated/sources/annotationProcessor.
3. Change the location of custom generated files to be consistent.
4. Fix a javadoc formatting error.
2020-07-30 15:43:42 -04:00
Michael Muller
f55270c46f
Integrate transaction persistence into JpaTM (#717)
* Integrate transaction persistence into JpaTM

Store the serialized transaction whenever we commit from the JPA transaction
manager.  This change also adds:

-   The Transaction table.
-   The TransactionEntity which is stored in it.
-   Changes to the test infrastructure to register the TransactionEntity for
    tests where we don't load the nomulus schema.
-   A new configuration variable to allow us to turn the transaction
    persistence functionality on and off (default is "off").

* Changes for review.

* Incremented sequence number of flyway file
2020-07-28 19:23:44 -04:00
Michael Muller
0ce431212e
Add the :nom:generate_golden_schema pseudo-task (#718)
Add a "pseudo-task" in nom_build to do the three step process of generating
the golden schema.  In the course of this, add support for pseudo-tasks in
general, improve the database directory readme and make nom_build not call
gradlew if there are no tasks.
2020-07-27 18:33:16 -04:00
Shicong Huang
0ecc20b48c
Rename a V40 flyway file to V41 to resolve conflict (#719) 2020-07-27 15:16:01 -04:00
Shicong Huang
c65af4b480
Add remaining columns to Domain's SQL schema (#702) 2020-07-27 13:32:39 -04:00
Legina Chen
3a15a8bdc7
Drop foreign key constraint for Registrar table (#715) 2020-07-27 09:05:30 -07:00
Weimin Yu
9806fab880
Use rearranged sql credentials in flyway task (#712)
* Use rearranged sql credentials in flyway task

Let the flyway tasks use the sql credential files set up for BEAM
pipelines.

Credential files have been created for each environment in GCS
at gs://${project}-beam/cloudsql/admin_credential.enc. All
project editors have access to this file, including the Dataflow
control service account.

Alpha and crash use the 'nomulus-tools-key' in their own project to
decrypt the credential file.

Sandbox and production use the 'nomulus-tools-key' in
domain-registry-dev to decrypt the credential file.

Note that this setup is temporary. It will become obsolete once
we migrate to Cloud Secret Manager for secret storage.
2020-07-24 15:32:01 -04:00
Shicong Huang
f5186f8476
Merge two PremiumList entities (#690) 2020-07-21 18:18:52 -04:00
Weimin Yu
94c8c6b9f3
Add lastUpdateTime column to epp resources (#683)
* Add lastUpdateTime column to epp resources

Property was inadvertently left out.

Renamed getter and setter to match the property name.

Added a test helper to compare EppResources while ignoring
lastUpdateTime, which changes every time an instance is persisted.
2020-07-14 14:53:05 -04:00
Shicong Huang
e1db357fc3
Merge two reserved list entities (#616)
* Merge reserved list

* Replace INSTANCE with getInstance()

* Fix broken test

* Rebase on master

* Simplify class
2020-07-13 13:40:34 -04:00
Ben McIlwain
4cb88ab6e7
Convert RDE tests (and some test rules) from JUnit 4 to JUnit 5 (#677)
* Add JUnit Params and start using it

* Convert rest of RDE tests

* Don't check headers for generated tests

* Expand visibility to fix build breakage

* Bump JUnit versions to 5.6.2
2020-07-10 21:32:36 -04:00
gbrodman
c24a61f813
Refactor ContactResource into ContactBase and create ContactHistory (#634)
* Create ContactHistory class + table

This is similar to #587, but with contacts instead of hosts.

This also includes a couple cleanups for HostHistoryTest and RegistryLockDaoTest, just making code more proper (we shouldn't be referencing constant revision IDs when using a sequence that is used by multiple classes, and RLDT can extend EntityTest)

Note as well that we set ContactHistory to use the same revision ID sequence as HostHistory.

* Move ContactResource -> ContactBase

* Alter ContactBase and ContactResource
2020-07-06 12:52:16 -04:00
Legina Chen
5c5b6b20ce
Allow multiple threat types in the Spec11ThreatMatch table (#650)
* Update to generic Spec11ThreatMatch table

* Fix SQL syntax

* Make changes to the schema and add a test for null and empty threatTypes

* Fix a small typo

* Change the exception thrown with illegal arguments

Change the import for isNullOrEmpty

* Fix import for checkArgument

* Added a threat to test multiple threat types
2020-06-26 10:35:00 -07:00
Legina Chen
ec09226baa
Create a Java entity to store ThreatMatch objects in SQL (#617)
* Squash everything together
Create SafeBrowsing_Threats table

Create LocalDateConverter and add indexes to SafeBrowsingThreats

Add indexes to SafeBrowsingThreats and make small style changes

Pass in DateTimeFormatter

Delete LocalDateConverterTest.java

Rebase

Make changes to ThreatType comments

Create LocalDateConverterTest

Add review changes

Add SafeBrowsingThreatTest

Rename repoId, refactor LocalDateConverterTest/SafeBrowsingThreatTest, add foreign keys

Change imports

Add foreign keys and rename version number

Add new generated db-schema file

Clean up null test cases

Add changes

Add foreign keys into SafeBrowsingThreatTeat and apply style checks

Add SafeBrowsingThreatTest into SqlIntegrationTestSuite and change golden file

Make small changes to SafeBrowsingThreatTest

Add tests for ForeignKeyViolations and remove setId in SafeBrowsingThreat

* Change V35 -> V36

* Add a foreign key test for a reference to Registrar

* Move some variables around
2020-06-22 12:07:59 -07:00
Weimin Yu
2c243a7d5f
Add testcontainers' Junit5 support dependency (#640)
* Add testcontainers' Junit5 support dependency

Also updated guava, dagger, hibernate, postgresql, and cloud socket factory
to latest version.

Migrated PersistenceModuleTest as an example.

Real changes:
- dependencies.gradle
- core/build.gradle
- PersistenceModuleTest.java
2020-06-22 13:12:58 -04:00
Ben McIlwain
df8ce38796
Rename whitelist -> allow list (#635)
* Rename whitelist -> allow list

* Merge branch 'master' into allowlist-denylist
2020-06-18 18:36:05 -04:00
gbrodman
69a1d04c18
Remove 'fullyQualified' from host and domain names (#631)
* Remove 'fullyQualified' from host and domain names

We don't actually enforce that these are properly fully-qualified
(there's no dot at the end) and we specifically use the term "label
name" when talking about labels.

Note: this doesn't convert FQDN -> DN (et al) in at least two types of
cases:
1. When the term is part of the XML schema
2. When the term is used by some external system, e.g. SafeBrowsing API

* Add TODO to rename fields
2020-06-17 16:19:26 -04:00
gbrodman
4f37c65af5
Fix versioning semantic merge conflict (#629) 2020-06-16 12:51:28 -04:00
gbrodman
47178d4fb5
Add HostBase and HostHistory classes (#587)
* Add proof of concept for HostBase and HostHistory classes

* Use a PROPERTY accessor for @Ids

* Add an unused setter method for Hibernate's sake

* Refactor HostHistory

* Some responses to CR

* Fix relationship and test

* Manually manage the foreign keys for HostHistory

* Protect HostBase's builder and use text for the enum type

* Add responses to CR

- Add javadocs
- Create an ID sequence for host history objects

* Don't try to set the ID

* Use a Long and remove the setter

* Add some comments and rename a couple fields

* Don't change Datastore schema

* Use Long in the Datastore schema

* Add new createVKey method

* Add comments and rename fields

* Rename v27->v31 and regenerate the golden

* Fix superordinateDomain and inetAddresses in HostHistory

* V31 -> V32

* Fix SQL files that got messed up in the merge

* Configure and use a manually-created history ID sequence

* Add three more indices to HostHistory
2020-06-16 11:47:17 -04:00
Shicong Huang
26e2a51180
Refactor TransferData to remove unused fields in Contact table (#623)
* Add DomainTransferData and ContactTransferData

* Refactor TransferData to remove unused fields in Contact table

* Add scope for TransferData's type parameter
2020-06-16 10:42:57 -04:00
gbrodman
1c62728886
Rename V30 -> V31 to avoid duplicates (#621) 2020-06-10 16:08:31 -04:00