mirror of
https://github.com/google/nomulus
synced 2026-09-07 16:47:03 +00:00
Refactor StringGenerator bindings
Make every dependency request explicit on what encoding is used. Also get rid of InjectRule in XjcToDomainResourceConverterTest. Random number generator providers are separated to secure and insecure ones. The insecure ones must be explicitly requested (usually for use cases where security is not of concern, for better speed). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217921422
This commit is contained in:
@@ -50,9 +50,12 @@ import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import google.registry.util.RandomStringGenerator;
|
||||
import google.registry.util.StringGenerator;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -91,12 +94,14 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
||||
persistActiveContact("sh8013");
|
||||
response = new FakeResponse();
|
||||
mrRunner = makeDefaultRunner();
|
||||
action = new RdeDomainImportAction(
|
||||
mrRunner,
|
||||
response,
|
||||
IMPORT_BUCKET_NAME,
|
||||
IMPORT_FILE_NAME,
|
||||
Optional.of(3));
|
||||
action =
|
||||
new RdeDomainImportAction(
|
||||
mrRunner,
|
||||
response,
|
||||
IMPORT_BUCKET_NAME,
|
||||
IMPORT_FILE_NAME,
|
||||
Optional.of(3),
|
||||
new RandomStringGenerator(StringGenerator.Alphabets.BASE_64, new SecureRandom()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -51,7 +51,6 @@ import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import google.registry.testing.InjectRule;
|
||||
import google.registry.util.StringGenerator;
|
||||
import google.registry.xjc.rdedomain.XjcRdeDomain;
|
||||
import google.registry.xjc.rdedomain.XjcRdeDomainElement;
|
||||
@@ -90,17 +89,16 @@ public class XjcToDomainResourceConverterTest {
|
||||
"google.registry.xjc.smd"));
|
||||
|
||||
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||
@Rule public final InjectRule inject = new InjectRule();
|
||||
|
||||
private Unmarshaller unmarshaller;
|
||||
private DeterministicStringGenerator stringGenerator;
|
||||
|
||||
private final DeterministicStringGenerator stringGenerator =
|
||||
new DeterministicStringGenerator(StringGenerator.Alphabets.BASE_64);
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
createTld("example");
|
||||
unmarshaller = JAXBContext.newInstance(JAXB_CONTEXT_PACKAGES).createUnmarshaller();
|
||||
stringGenerator = new DeterministicStringGenerator(StringGenerator.Alphabets.BASE_64);
|
||||
inject.setStaticField(XjcToDomainResourceConverter.class, "stringGenerator", stringGenerator);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -415,7 +413,7 @@ public class XjcToDomainResourceConverterTest {
|
||||
// without that there's no way to actually test the capping of the projected registration here.
|
||||
}
|
||||
|
||||
private static DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) {
|
||||
private DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) {
|
||||
return ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
@@ -426,7 +424,7 @@ public class XjcToDomainResourceConverterTest {
|
||||
createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry);
|
||||
ofy().save().entities(historyEntry, autorenewBillingEvent, autorenewPollMessage);
|
||||
return XjcToDomainResourceConverter.convertDomain(
|
||||
xjcDomain, autorenewBillingEvent, autorenewPollMessage);
|
||||
xjcDomain, autorenewBillingEvent, autorenewPollMessage, stringGenerator);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user