diff --git a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java index a6ad8beed..044f28acc 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -14,7 +14,6 @@ package google.registry.flows.domain; -import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; import static com.google.common.collect.Sets.symmetricDifference; @@ -282,7 +281,7 @@ public final class DomainUpdateFlow implements MutatingFlow { .removeContacts(remove.getContacts()) .addContacts(add.getContacts()) .setRegistrant(determineUpdatedRegistrant(change, domain)) - .setAuthInfo(firstNonNull(change.getAuthInfo(), domain.getAuthInfo())); + .setAuthInfo(Optional.ofNullable(change.getAuthInfo()).orElse(domain.getAuthInfo())); if (!add.getNameservers().isEmpty()) { domainBuilder.addNameservers(add.getNameservers().stream().collect(toImmutableSet())); diff --git a/core/src/main/java/google/registry/model/domain/DomainBase.java b/core/src/main/java/google/registry/model/domain/DomainBase.java index c853a8208..0e61c3041 100644 --- a/core/src/main/java/google/registry/model/domain/DomainBase.java +++ b/core/src/main/java/google/registry/model/domain/DomainBase.java @@ -144,6 +144,7 @@ public class DomainBase extends EppResource @AttributeOverride(name = "pw.value", column = @Column(name = "auth_info_value")), @AttributeOverride(name = "pw.repoId", column = @Column(name = "auth_info_repo_id")), }) + @Nullable DomainAuthInfo authInfo; /** Data used to construct DS records for this domain. */ @@ -620,6 +621,7 @@ public class DomainBase extends EppResource return getAllContacts(true); } + @Nullable public DomainAuthInfo getAuthInfo() { return authInfo; } diff --git a/core/src/main/java/google/registry/model/eppcommon/AuthInfo.java b/core/src/main/java/google/registry/model/eppcommon/AuthInfo.java index 3eab36dc9..5d67505e3 100644 --- a/core/src/main/java/google/registry/model/eppcommon/AuthInfo.java +++ b/core/src/main/java/google/registry/model/eppcommon/AuthInfo.java @@ -16,6 +16,7 @@ package google.registry.model.eppcommon; import google.registry.model.ImmutableObject; import google.registry.model.UnsafeSerializable; +import javax.annotation.Nullable; import javax.persistence.Embeddable; import javax.persistence.Embedded; import javax.persistence.MappedSuperclass; @@ -49,10 +50,12 @@ public abstract class AuthInfo extends ImmutableObject implements UnsafeSerializ public static class PasswordAuth extends ImmutableObject implements UnsafeSerializable { @XmlValue @XmlJavaTypeAdapter(NormalizedStringAdapter.class) + @Nullable String value; @XmlAttribute(name = "roid") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @Nullable String repoId; public String getValue() { @@ -63,14 +66,14 @@ public abstract class AuthInfo extends ImmutableObject implements UnsafeSerializ return repoId; } - public static PasswordAuth create(String value, String repoId) { + public static PasswordAuth create(@Nullable String value, @Nullable String repoId) { PasswordAuth instance = new PasswordAuth(); instance.value = value; instance.repoId = repoId; return instance; } - public static PasswordAuth create(String value) { + public static PasswordAuth create(@Nullable String value) { return create(value, null); } } diff --git a/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java index a58da9542..e1ee7aa2b 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java @@ -104,8 +104,10 @@ import google.registry.model.contact.Contact; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.Domain; +import google.registry.model.domain.DomainAuthInfo; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.secdns.DomainDsData; +import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.Trid; import google.registry.model.host.Host; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; @@ -264,6 +266,38 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase hasAuthInfoPwd(String pw) { + public And hasAuthInfoPwd(@Nullable String pw) { AuthInfo authInfo = actual.getAuthInfo(); return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw"); } diff --git a/core/src/test/resources/google/registry/flows/domain/domain_update_no_auth_change.xml b/core/src/test/resources/google/registry/flows/domain/domain_update_no_auth_change.xml new file mode 100644 index 000000000..7e2b44f3a --- /dev/null +++ b/core/src/test/resources/google/registry/flows/domain/domain_update_no_auth_change.xml @@ -0,0 +1,26 @@ + + + + + example.tld + + + ns2.example.foo + + mak21 + Payment overdue. + + + + ns1.example.foo + + sh8013 + + + + + ABC-12345 + +