Refactor RdeKeyringModule into FakeKeyringModule

A fake Keyring implementation is needed to test Keyring related tools now, so
I've refactored the fake RdeKeyring to support all Keyring API methods and
moved it to the common testing package.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149977968
This commit is contained in:
shikhman 2017-03-13 12:55:51 -07:00 committed by Ben McIlwain
parent 2353bcd8c5
commit 5779cc988b
15 changed files with 281 additions and 47 deletions

View file

@ -63,6 +63,7 @@ import google.registry.testing.AppEngineRule;
import google.registry.testing.BouncyCastleProviderRule;
import google.registry.testing.ExceptionRule;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeKeyringModule;
import google.registry.testing.FakeResponse;
import google.registry.testing.FakeSleeper;
import google.registry.testing.GpgSystemCommandRule;
@ -183,7 +184,7 @@ public class RdeUploadActionTest {
}};
private RdeUploadAction createAction(URI uploadUrl) {
try (Keyring keyring = new RdeKeyringModule().get()) {
try (Keyring keyring = new FakeKeyringModule().get()) {
RdeUploadAction action = new RdeUploadAction();
action.clock = clock;
action.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE);
@ -230,7 +231,7 @@ public class RdeUploadActionTest {
@Before
public void before() throws Exception {
createTld("tld");
PGPPublicKey encryptKey = new RdeKeyringModule().get().getRdeStagingEncryptionKey();
PGPPublicKey encryptKey = new FakeKeyringModule().get().getRdeStagingEncryptionKey();
writeGcsFile(gcsService, GHOSTRYDE_FILE,
Ghostryde.encode(DEPOSIT_XML.read(), encryptKey, "lobster.xml", clock.nowUtc()));
writeGcsFile(gcsService, GHOSTRYDE_R1_FILE,