Skip to content

Commit 50fa49e

Browse files
authored
Always act as if contacts are prohibited (#2897)
This PR finds instances where we previously checked if the feature flag for contacts-prohibited was set and removes those checks, making the contacts-prohibited behavior the only behavior. Because the tests didn't have that feature flag set, this means we need to change a ton of tests to remove contact references.
1 parent a581259 commit 50fa49e

File tree

180 files changed

+76
-1995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+76
-1995
lines changed

core/src/main/java/google/registry/batch/RemoveAllDomainContactsAction.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
package google.registry.batch;
1616

17-
import static com.google.common.base.Preconditions.checkState;
1817
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
1918
import static google.registry.flows.FlowUtils.marshalWithLenientRetry;
20-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_PROHIBITED;
2119
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
2220
import static google.registry.util.DateTimeUtils.END_OF_TIME;
2321
import static google.registry.util.ResourceUtils.readResourceUtf8;
@@ -36,7 +34,6 @@
3634
import google.registry.flows.EppRequestSource;
3735
import google.registry.flows.PasswordOnlyTransportCredentials;
3836
import google.registry.flows.StatelessRequestSessionMetadata;
39-
import google.registry.model.common.FeatureFlag;
4037
import google.registry.model.contact.Contact;
4138
import google.registry.model.domain.DesignatedContact;
4239
import google.registry.model.domain.Domain;
@@ -106,11 +103,7 @@ public class RemoveAllDomainContactsAction implements Runnable {
106103

107104
@Override
108105
public void run() {
109-
checkState(
110-
tm().transact(() -> FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_PROHIBITED)),
111-
"Minimum dataset migration must be completed prior to running this action");
112106
response.setContentType(PLAIN_TEXT_UTF_8);
113-
114107
Callable<Void> runner =
115108
() -> {
116109
try {

core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,9 @@
186186
* @error {@link DomainFlowUtils.LinkedResourceInPendingDeleteProhibitsOperationException}
187187
* @error {@link DomainFlowUtils.MalformedTcnIdException}
188188
* @error {@link DomainFlowUtils.MaxSigLifeNotSupportedException}
189-
* @error {@link DomainFlowUtils.MissingAdminContactException}
190189
* @error {@link DomainFlowUtils.MissingBillingAccountMapException}
191190
* @error {@link DomainFlowUtils.MissingClaimsNoticeException}
192191
* @error {@link DomainFlowUtils.MissingContactTypeException}
193-
* @error {@link DomainFlowUtils.MissingRegistrantException}
194-
* @error {@link DomainFlowUtils.MissingTechnicalContactException}
195192
* @error {@link DomainFlowUtils.NameserversNotAllowedForTldException}
196193
* @error {@link DomainFlowUtils.NameserversNotSpecifiedForTldWithNameserverAllowListException}
197194
* @error {@link DomainFlowUtils.PremiumNameBlockedException}

core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java

Lines changed: 14 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import static com.google.common.collect.Sets.intersection;
2525
import static com.google.common.collect.Sets.union;
2626
import static google.registry.bsa.persistence.BsaLabelUtils.isLabelBlocked;
27-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_OPTIONAL;
28-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_PROHIBITED;
2927
import static google.registry.model.domain.Domain.MAX_REGISTRATION_YEARS;
3028
import static google.registry.model.domain.token.AllocationToken.TokenType.REGISTER_BSA;
3129
import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY;
@@ -81,7 +79,6 @@
8179
import google.registry.model.billing.BillingBase.Flag;
8280
import google.registry.model.billing.BillingBase.Reason;
8381
import google.registry.model.billing.BillingRecurrence;
84-
import google.registry.model.common.FeatureFlag;
8582
import google.registry.model.contact.Contact;
8683
import google.registry.model.domain.DesignatedContact;
8784
import google.registry.model.domain.DesignatedContact.Type;
@@ -138,7 +135,6 @@
138135
import java.math.BigDecimal;
139136
import java.util.Collection;
140137
import java.util.Comparator;
141-
import java.util.HashSet;
142138
import java.util.List;
143139
import java.util.Map;
144140
import java.util.Map.Entry;
@@ -486,31 +482,12 @@ static void validateNoDuplicateContacts(Set<DesignatedContact> contacts)
486482
*/
487483
static void validateCreateContactData(
488484
Optional<VKey<Contact>> registrant, Set<DesignatedContact> contacts)
489-
throws RequiredParameterMissingException, ParameterValuePolicyErrorException {
490-
// TODO(b/353347632): Change these flag checks to a registry config check once minimum data set
491-
// migration is completed.
492-
if (FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_PROHIBITED)) {
493-
if (registrant.isPresent()) {
494-
throw new RegistrantProhibitedException();
495-
}
496-
if (!contacts.isEmpty()) {
497-
throw new ContactsProhibitedException();
498-
}
499-
} else if (!FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_OPTIONAL)) {
500-
if (registrant.isEmpty()) {
501-
throw new MissingRegistrantException();
502-
}
503-
504-
Set<Type> roles = new HashSet<>();
505-
for (DesignatedContact contact : contacts) {
506-
roles.add(contact.getType());
507-
}
508-
if (!roles.contains(Type.ADMIN)) {
509-
throw new MissingAdminContactException();
510-
}
511-
if (!roles.contains(Type.TECH)) {
512-
throw new MissingTechnicalContactException();
513-
}
485+
throws ParameterValuePolicyErrorException {
486+
if (registrant.isPresent()) {
487+
throw new RegistrantProhibitedException();
488+
}
489+
if (!contacts.isEmpty()) {
490+
throw new ContactsProhibitedException();
514491
}
515492
}
516493

@@ -523,33 +500,14 @@ static void validateUpdateContactData(
523500
Optional<VKey<Contact>> newRegistrant,
524501
Set<DesignatedContact> existingContacts,
525502
Set<DesignatedContact> newContacts)
526-
throws RequiredParameterMissingException, ParameterValuePolicyErrorException {
527-
// TODO(b/353347632): Change these flag checks to a registry config check once minimum data set
528-
// migration is completed.
529-
if (FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_PROHIBITED)) {
530-
// Throw if the update specifies a new registrant that is different from the existing one.
531-
if (newRegistrant.isPresent() && !newRegistrant.equals(existingRegistrant)) {
532-
throw new RegistrantProhibitedException();
533-
}
534-
// Throw if the update specifies any new contacts that weren't already present on the domain.
535-
if (!Sets.difference(newContacts, existingContacts).isEmpty()) {
536-
throw new ContactsProhibitedException();
537-
}
538-
} else if (!FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_OPTIONAL)) {
539-
// Throw if the update empties out a registrant that had been present.
540-
if (newRegistrant.isEmpty() && existingRegistrant.isPresent()) {
541-
throw new MissingRegistrantException();
542-
}
543-
// Throw if the update contains no admin contact when one had been present.
544-
if (existingContacts.stream().anyMatch(c -> c.getType().equals(Type.ADMIN))
545-
&& newContacts.stream().noneMatch(c -> c.getType().equals(Type.ADMIN))) {
546-
throw new MissingAdminContactException();
547-
}
548-
// Throw if the update contains no tech contact when one had been present.
549-
if (existingContacts.stream().anyMatch(c -> c.getType().equals(Type.TECH))
550-
&& newContacts.stream().noneMatch(c -> c.getType().equals(Type.TECH))) {
551-
throw new MissingTechnicalContactException();
552-
}
503+
throws ParameterValuePolicyErrorException {
504+
// Throw if the update specifies a new registrant that is different from the existing one.
505+
if (newRegistrant.isPresent() && !newRegistrant.equals(existingRegistrant)) {
506+
throw new RegistrantProhibitedException();
507+
}
508+
// Throw if the update specifies any new contacts that weren't already present on the domain.
509+
if (!Sets.difference(newContacts, existingContacts).isEmpty()) {
510+
throw new ContactsProhibitedException();
553511
}
554512
}
555513

@@ -1398,34 +1356,13 @@ public InvalidIdnDomainLabelException() {
13981356
}
13991357
}
14001358

1401-
/** Registrant is required. */
1402-
static class MissingRegistrantException extends RequiredParameterMissingException {
1403-
public MissingRegistrantException() {
1404-
super("Registrant is required");
1405-
}
1406-
}
1407-
14081359
/** Having a registrant is prohibited by registry policy. */
14091360
static class RegistrantProhibitedException extends ParameterValuePolicyErrorException {
14101361
public RegistrantProhibitedException() {
14111362
super("Having a registrant is prohibited by registry policy");
14121363
}
14131364
}
14141365

1415-
/** Admin contact is required. */
1416-
static class MissingAdminContactException extends RequiredParameterMissingException {
1417-
public MissingAdminContactException() {
1418-
super("Admin contact is required");
1419-
}
1420-
}
1421-
1422-
/** Technical contact is required. */
1423-
static class MissingTechnicalContactException extends RequiredParameterMissingException {
1424-
public MissingTechnicalContactException() {
1425-
super("Technical contact is required");
1426-
}
1427-
}
1428-
14291366
/** Too many nameservers set on this domain. */
14301367
static class TooManyNameserversException extends ParameterValuePolicyErrorException {
14311368
public TooManyNameserversException(String message) {

core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
import static google.registry.flows.domain.DomainFlowUtils.validateUpdateContactData;
4040
import static google.registry.flows.domain.DomainFlowUtils.verifyClientUpdateNotProhibited;
4141
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPendingDelete;
42-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_OPTIONAL;
43-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_PROHIBITED;
4442
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_UPDATE;
4543
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
4644

@@ -61,13 +59,11 @@
6159
import google.registry.flows.custom.DomainUpdateFlowCustomLogic.AfterValidationParameters;
6260
import google.registry.flows.custom.DomainUpdateFlowCustomLogic.BeforeSaveParameters;
6361
import google.registry.flows.custom.EntityChanges;
64-
import google.registry.flows.domain.DomainFlowUtils.MissingRegistrantException;
6562
import google.registry.flows.domain.DomainFlowUtils.NameserversNotSpecifiedForTldWithNameserverAllowListException;
6663
import google.registry.flows.domain.DomainFlowUtils.RegistrantProhibitedException;
6764
import google.registry.model.ImmutableObject;
6865
import google.registry.model.billing.BillingBase.Reason;
6966
import google.registry.model.billing.BillingEvent;
70-
import google.registry.model.common.FeatureFlag;
7167
import google.registry.model.contact.Contact;
7268
import google.registry.model.domain.DesignatedContact;
7369
import google.registry.model.domain.Domain;
@@ -123,10 +119,7 @@
123119
* @error {@link DomainFlowUtils.LinkedResourcesDoNotExistException}
124120
* @error {@link DomainFlowUtils.LinkedResourceInPendingDeleteProhibitsOperationException}
125121
* @error {@link DomainFlowUtils.MaxSigLifeChangeNotSupportedException}
126-
* @error {@link DomainFlowUtils.MissingAdminContactException}
127122
* @error {@link DomainFlowUtils.MissingContactTypeException}
128-
* @error {@link DomainFlowUtils.MissingTechnicalContactException}
129-
* @error {@link DomainFlowUtils.MissingRegistrantException}
130123
* @error {@link DomainFlowUtils.NameserversNotAllowedForTldException}
131124
* @error {@link NameserversNotSpecifiedForTldWithNameserverAllowListException}
132125
* @error {@link DomainFlowUtils.NotAuthorizedForTldException}
@@ -307,18 +300,11 @@ private Domain performUpdate(Update command, Domain domain, DateTime now) throws
307300
return domainBuilder.build();
308301
}
309302

310-
private Optional<VKey<Contact>> determineUpdatedRegistrant(Change change, Domain domain)
311-
throws EppException {
303+
private Optional<VKey<Contact>> determineUpdatedRegistrant(Change change, Domain domain) {
312304
// During or after the minimum dataset transition, allow registrant to be removed.
313305
if (change.getRegistrantContactId().isPresent()
314306
&& change.getRegistrantContactId().get().isEmpty()) {
315-
// TODO(b/353347632): Change this flag check to a registry config check.
316-
if (FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_OPTIONAL)
317-
|| FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_PROHIBITED)) {
318-
return Optional.empty();
319-
} else {
320-
throw new MissingRegistrantException();
321-
}
307+
return Optional.empty();
322308
}
323309
return change.getRegistrant().or(domain::getRegistrant);
324310
}

core/src/main/java/google/registry/tools/CreateDomainCommand.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616

1717
import static com.google.common.base.Preconditions.checkArgument;
1818
import static com.google.common.base.Strings.isNullOrEmpty;
19-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_OPTIONAL;
20-
import static google.registry.model.common.FeatureFlag.FeatureName.MINIMUM_DATASET_CONTACTS_PROHIBITED;
21-
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
2219
import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName;
23-
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
2420
import static org.joda.time.DateTimeZone.UTC;
2521

2622
import com.beust.jcommander.Parameter;
2723
import com.beust.jcommander.Parameters;
2824
import com.google.template.soy.data.SoyMapData;
29-
import google.registry.model.common.FeatureFlag;
3025
import google.registry.model.pricing.PremiumPricingEngine.DomainPrices;
3126
import google.registry.tools.soy.DomainCreateSoyInfo;
3227
import google.registry.util.StringGenerator;
@@ -62,15 +57,6 @@ final class CreateDomainCommand extends CreateOrUpdateDomainCommand {
6257

6358
@Override
6459
protected void initMutatingEppToolCommand() {
65-
tm().transact(
66-
() -> {
67-
if (!FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_OPTIONAL)
68-
&& !FeatureFlag.isActiveNow(MINIMUM_DATASET_CONTACTS_PROHIBITED)) {
69-
checkArgumentNotNull(registrant, "Registrant must be specified");
70-
checkArgument(!admins.isEmpty(), "At least one admin must be specified");
71-
checkArgument(!techs.isEmpty(), "At least one tech must be specified");
72-
}
73-
});
7460
if (isNullOrEmpty(password)) {
7561
password = passwordGenerator.createString(PASSWORD_LENGTH);
7662
}

0 commit comments

Comments
 (0)