Merge pull request #43771 from hezean
* gh-43771: Polish "Add support for empty password in bitnami/postgresql" Add support for empty password in bitnami/postgresql Closes gh-43771
This commit is contained in:
commit
6c476a2b92
|
|
@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Scott Frederick
|
* @author Scott Frederick
|
||||||
|
* @author He Zean
|
||||||
*/
|
*/
|
||||||
class PostgresJdbcDockerComposeConnectionDetailsFactoryIntegrationTests {
|
class PostgresJdbcDockerComposeConnectionDetailsFactoryIntegrationTests {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Scott Frederick
|
* @author Scott Frederick
|
||||||
|
* @author He Zean
|
||||||
*/
|
*/
|
||||||
class PostgresR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests {
|
class PostgresR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,9 @@ class PostgresEnvironment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD"));
|
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD"));
|
||||||
Assert.state(StringUtils.hasLength(password), "PostgreSQL password must be provided");
|
boolean allowEmpty = env.containsKey("ALLOW_EMPTY_PASSWORD");
|
||||||
return password;
|
Assert.state(allowEmpty || StringUtils.hasLength(password), "No PostgreSQL password found");
|
||||||
|
return (password != null) ? password : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUsingTrustHostAuthMethod(Map<String, String> env) {
|
private boolean isUsingTrustHostAuthMethod(Map<String, String> env) {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class PostgresEnvironmentTests {
|
||||||
@Test
|
@Test
|
||||||
void createWhenNoPostgresPasswordThrowsException() {
|
void createWhenNoPostgresPasswordThrowsException() {
|
||||||
assertThatIllegalStateException().isThrownBy(() -> new PostgresEnvironment(Collections.emptyMap()))
|
assertThatIllegalStateException().isThrownBy(() -> new PostgresEnvironment(Collections.emptyMap()))
|
||||||
.withMessage("PostgreSQL password must be provided");
|
.withMessage("No PostgreSQL password found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -93,6 +93,12 @@ class PostgresEnvironmentTests {
|
||||||
assertThat(environment.getPassword()).isNull();
|
assertThat(environment.getPassword()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getPasswordWhenHasNoPasswordAndAllowEmptyPassword() {
|
||||||
|
PostgresEnvironment environment = new PostgresEnvironment(Map.of("ALLOW_EMPTY_PASSWORD", "yes"));
|
||||||
|
assertThat(environment.getPassword()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getDatabaseWhenNoPostgresDbOrPostgresUser() {
|
void getDatabaseWhenNoPostgresDbOrPostgresUser() {
|
||||||
PostgresEnvironment environment = new PostgresEnvironment(Map.of("POSTGRES_PASSWORD", "secret"));
|
PostgresEnvironment environment = new PostgresEnvironment(Map.of("POSTGRES_PASSWORD", "secret"));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue