Fix add/remove calculations when updating multiple domains

Lists used as accumulators were being updated individually for each domain
without starting over from a fresh list each time, so the number of changes
would grow for each additional domain and potentially be wrong if the previous
domains were set up differently.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204526006
This commit is contained in:
mcilwain 2018-07-13 14:09:23 -07:00 committed by jianglai
parent 278ec2b289
commit 8942c4fad1
3 changed files with 99 additions and 26 deletions

View file

@ -16,6 +16,7 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
import static google.registry.testing.DatastoreHelper.createTlds;
import static google.registry.testing.DatastoreHelper.newContactResource;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
@ -23,6 +24,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.beust.jcommander.ParameterException;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.model.contact.ContactResource;
@ -77,6 +79,32 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
.verifySent("domain_update_complete_abc.xml");
}
@Test
public void testSuccess_multipleDomains_setNameservers() throws Exception {
createTlds("abc", "tld");
HostResource host1 = persistActiveHost("foo.bar.tld");
HostResource host2 = persistActiveHost("baz.bar.tld");
persistResource(
newDomainResource("example.abc")
.asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host1)))
.build());
persistResource(
newDomainResource("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host2)))
.build());
runCommandForced(
"--client=NewRegistrar", "-n ns1.foo.fake,ns2.foo.fake", "example.abc", "example.tld");
eppVerifier
.verifySent(
"domain_update_add_two_hosts_remove_one.xml",
ImmutableMap.of("DOMAIN", "example.abc", "REMOVEHOST", "foo.bar.tld"))
.verifySent(
"domain_update_add_two_hosts_remove_one.xml",
ImmutableMap.of("DOMAIN", "example.tld", "REMOVEHOST", "baz.bar.tld"));
}
@Test
public void testSuccess_add() throws Exception {
runCommandForced(