Add configurations for Cloud SQL secrets (#266)

This commit is contained in:
Shicong Huang 2019-09-11 12:20:08 -04:00 committed by GitHub
parent 401653ad4a
commit 48d8b1274f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 95 additions and 8 deletions

View file

@ -46,6 +46,15 @@ public class KmsKeyringTest {
keyring = new KmsKeyring(new FakeKmsConnection());
}
@Test
public void test_getCloudSqlPassword() throws Exception {
saveCleartextSecret("cloud-sql-password-string");
String cloudSqlPassword = keyring.getCloudSqlPassword();
assertThat(cloudSqlPassword).isEqualTo("cloud-sql-password-stringmoo");
}
@Test
public void test_getRdeSigningKey() throws Exception {
saveKeyPairSecret("rde-signing-public", "rde-signing-private");

View file

@ -91,6 +91,14 @@ public class KmsUpdaterTest {
getCiphertext(KmsTestHelper.getPublicKey()));
}
@Test
public void test_setCloudSqlPassword() {
updater.setCloudSqlPassword("value1").update();
verifySecretAndSecretRevisionWritten(
"cloud-sql-password-string", "cloud-sql-password-string/foo", getCiphertext("value1"));
}
@Test
public void test_setIcannReportingPassword() {
updater.setIcannReportingPassword("value1").update();

View file

@ -56,6 +56,7 @@ public final class FakeKeyringModule {
private static final String MARKSDB_LORDN_PASSWORD = "yolo";
private static final String MARKSDB_SMDRL_LOGIN_AND_PASSWORD = "smdrl:yolo";
private static final String JSON_CREDENTIAL = "json123";
private static final String CLOUD_SQL_PASSWORD = "cloudsqlpw";
@Provides
public Keyring get() {
@ -80,6 +81,11 @@ public final class FakeKeyringModule {
final String sshPrivate = loadFile(FakeKeyringModule.class, "registry-unittest.id_rsa");
return new Keyring() {
@Override
public String getCloudSqlPassword() {
return CLOUD_SQL_PASSWORD;
}
@Override
public PGPPublicKey getRdeStagingEncryptionKey() {
return rdeStagingKey.getPublicKey();