mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 17:33:03 -05:00
fix(rds): register instances before starting auth proxy (#3467)
* fix(rds): register instances before starting auth proxy * fix(rds): keep provisioning instances in creating state --------- Co-authored-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
This commit is contained in:
1 parent
01ec7af8d5
commit
34efd8957a
2 files changed
+55
-9
No files matched your search
@@ -171,6 +171,40 @@ class RdsServiceTest {
|
||||
assertEquals("arn:aws:rds:us-east-1:123456789012:db:mydb", instance.getDbInstanceArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbInstanceMakesRequestedPasswordValidBeforeProxyStartsAcceptingConnections() {
|
||||
doAnswer(invocation -> {
|
||||
assertEquals(DbInstanceStatus.CREATING,
|
||||
rdsService.getDbInstance("mypostgres").getStatus());
|
||||
RdsAuthProxy.MasterPasswordCheck passwordCheck = invocation.getArgument(10);
|
||||
assertTrue(passwordCheck.validate("admin", "secret123"));
|
||||
assertFalse(passwordCheck.validate("admin", "wrong"));
|
||||
return null;
|
||||
}).when(proxyManager).startProxy(any(), any(), anyBoolean(), anyInt(), any(), anyInt(),
|
||||
any(), any(), any(), any(), any());
|
||||
|
||||
DbInstance instance = rdsService.createDbInstance("mypostgres", "postgres", "13",
|
||||
"admin", "secret123", null, "db.t3.micro",
|
||||
20, false, null, null, null, null, false);
|
||||
|
||||
assertEquals(DbInstanceStatus.AVAILABLE, instance.getStatus());
|
||||
assertEquals(DbInstanceStatus.AVAILABLE,
|
||||
rdsService.getDbInstance("mypostgres").getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbInstanceRemovesVisibleRecordWhenProxyStartupFails() {
|
||||
doThrow(new IllegalStateException("proxy down"))
|
||||
.when(proxyManager).startProxy(any(), any(), anyBoolean(), anyInt(), any(), anyInt(),
|
||||
any(), any(), any(), any(), any());
|
||||
|
||||
assertThrows(IllegalStateException.class, () -> rdsService.createDbInstance(
|
||||
"mypostgres", "postgres", "13",
|
||||
"admin", "secret123", null, "db.t3.micro",
|
||||
20, false, null, null, null, null, false));
|
||||
assertThrows(AwsException.class, () -> rdsService.getDbInstance("mypostgres"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDbInstanceRejectsLegacyBareAuroraEngine() {
|
||||
// "aurora" (bare) is the retired Aurora MySQL 5.6 identifier; real AWS no
|
||||
|
||||
Reference in new issue
Block a user