-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Provide configuration properties for Flyway's Vault and Conjur support #25456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c1a7d5f
Add configuration properties for Flyway Vault and Conjur support
onobc 72044e1
Implement suggestions from code review
onobc e7490bb
Removed old comment that was missed during removal of teams property …
onobc 8a5800f
Fix checkstyle issues w/ IDEA auto-gened getters (no this. )
onobc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,9 @@ | |
import org.springframework.boot.jdbc.DataSourceBuilder; | ||
import org.springframework.boot.jdbc.SchemaManagement; | ||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | ||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
import org.springframework.boot.test.context.runner.ContextConsumer; | ||
import org.springframework.boot.test.system.CapturedOutput; | ||
import org.springframework.boot.test.system.OutputCaptureExtension; | ||
import org.springframework.context.annotation.Bean; | ||
|
@@ -82,6 +84,7 @@ | |
* @author Dominic Gunn | ||
* @author András Deák | ||
* @author Takaaki Shimbo | ||
* @author Chris Bono | ||
*/ | ||
@ExtendWith(OutputCaptureExtension.class) | ||
class FlywayAutoConfigurationTests { | ||
|
@@ -413,34 +416,21 @@ void configurationCustomizersAreConfiguredAndOrdered() { | |
@Test | ||
void batchIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.batch=true").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" batch "); | ||
}); | ||
.withPropertyValues("spring.flyway.batch=true").run(validateTeamsPropertyCorrectlyMapped("batch")); | ||
} | ||
|
||
@Test | ||
void dryRunOutputIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.dryRunOutput=dryrun.sql").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" dryRunOutput "); | ||
}); | ||
.withPropertyValues("spring.flyway.dryRunOutput=dryrun.sql") | ||
.run(validateTeamsPropertyCorrectlyMapped("dryRunOutput")); | ||
} | ||
|
||
@Test | ||
void errorOverridesIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.errorOverrides=D12345").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" errorOverrides "); | ||
}); | ||
.withPropertyValues("spring.flyway.errorOverrides=D12345") | ||
.run(validateTeamsPropertyCorrectlyMapped("errorOverrides")); | ||
} | ||
|
||
@Test | ||
|
@@ -453,45 +443,28 @@ void licenseKeyIsCorrectlyMapped(CapturedOutput output) { | |
@Test | ||
void oracleSqlplusIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.oracle-sqlplus=true").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" oracle.sqlplus "); | ||
}); | ||
.withPropertyValues("spring.flyway.oracle-sqlplus=true") | ||
.run(validateTeamsPropertyCorrectlyMapped("oracle.sqlplus")); | ||
} | ||
|
||
@Test | ||
void oracleSqlplusWarnIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.oracle-sqlplus-warn=true").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" oracle.sqlplusWarn "); | ||
}); | ||
.withPropertyValues("spring.flyway.oracle-sqlplus-warn=true") | ||
.run(validateTeamsPropertyCorrectlyMapped("oracle.sqlplusWarn")); | ||
} | ||
|
||
@Test | ||
void streamIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.stream=true").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" stream "); | ||
}); | ||
.withPropertyValues("spring.flyway.stream=true").run(validateTeamsPropertyCorrectlyMapped("stream")); | ||
} | ||
|
||
@Test | ||
void undoSqlMigrationPrefix() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.undo-sql-migration-prefix=undo").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" undoSqlMigrationPrefix "); | ||
}); | ||
.withPropertyValues("spring.flyway.undo-sql-migration-prefix=undo") | ||
.run(validateTeamsPropertyCorrectlyMapped("undoSqlMigrationPrefix")); | ||
} | ||
|
||
@Test | ||
|
@@ -526,67 +499,78 @@ void initSqlsWithFlywayUrl() { | |
@Test | ||
void cherryPickIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.cherry-pick=1.1").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" cherryPick "); | ||
}); | ||
.withPropertyValues("spring.flyway.cherry-pick=1.1") | ||
.run(validateTeamsPropertyCorrectlyMapped("cherryPick")); | ||
} | ||
|
||
@Test | ||
void jdbcPropertiesAreCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.jdbc-properties.prop=value").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" jdbcProperties "); | ||
}); | ||
.withPropertyValues("spring.flyway.jdbc-properties.prop=value") | ||
.run(validateTeamsPropertyCorrectlyMapped("jdbcProperties")); | ||
} | ||
|
||
@Test | ||
void oracleKerberosCacheFileIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.oracle-kerberos-cache-file=/tmp/cache").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" oracle.kerberosCacheFile "); | ||
}); | ||
.withPropertyValues("spring.flyway.oracle-kerberos-cache-file=/tmp/cache") | ||
.run(validateTeamsPropertyCorrectlyMapped("oracle.kerberosCacheFile")); | ||
} | ||
|
||
@Test | ||
void oracleKerberosConfigFileIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.oracle-kerberos-config-file=/tmp/config").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" oracle.kerberosConfigFile "); | ||
}); | ||
.withPropertyValues("spring.flyway.oracle-kerberos-config-file=/tmp/config") | ||
.run(validateTeamsPropertyCorrectlyMapped("oracle.kerberosConfigFile")); | ||
} | ||
|
||
@Test | ||
void outputQueryResultsIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.output-query-results=false").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" outputQueryResults "); | ||
}); | ||
.withPropertyValues("spring.flyway.output-query-results=false") | ||
.run(validateTeamsPropertyCorrectlyMapped("outputQueryResults")); | ||
} | ||
|
||
@Test | ||
void skipExecutingMigrationsIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.skip-executing-migrations=true").run((context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(" skipExecutingMigrations "); | ||
}); | ||
.withPropertyValues("spring.flyway.skip-executing-migrations=true") | ||
.run(validateTeamsPropertyCorrectlyMapped("skipExecutingMigrations")); | ||
} | ||
|
||
@Test | ||
void conjurUrlIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.conjur-url=http://foo.com/secrets") | ||
.run(validateTeamsPropertyCorrectlyMapped("conjurUrl")); | ||
} | ||
|
||
@Test | ||
void conjurTokenIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.conjur-token=5150") | ||
.run(validateTeamsPropertyCorrectlyMapped("conjurToken")); | ||
} | ||
|
||
@Test | ||
void vaultUrlIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.vault-url=http://foo.com/secrets") | ||
.run(validateTeamsPropertyCorrectlyMapped("vaultUrl")); | ||
} | ||
|
||
@Test | ||
void vaultTokenIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
.withPropertyValues("spring.flyway.vault-token=5150") | ||
.run(validateTeamsPropertyCorrectlyMapped("vaultToken")); | ||
} | ||
|
||
@Test | ||
void vaultSecretsIsCorrectlyMapped() { | ||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snicoll thx for the suggestion. Keeping the setup in each test makes it easy to see what the test is doing from first glance. Sharing only the common validation reduces the duplicated lines (and that was the main goal of the first attempt). 👍🏻 |
||
.withPropertyValues("spring.flyway.vault-secrets=kv/test/1/config,kv/test/2/config") | ||
.run(validateTeamsPropertyCorrectlyMapped("vaultSecrets")); | ||
} | ||
|
||
@Test | ||
|
@@ -616,6 +600,15 @@ void whenCustomFlywayIsDefinedThenJooqDslContextDependsOnIt() { | |
}); | ||
} | ||
|
||
private ContextConsumer<AssertableApplicationContext> validateTeamsPropertyCorrectlyMapped(String propertyName) { | ||
return (context) -> { | ||
assertThat(context).hasFailed(); | ||
Throwable failure = context.getStartupFailure(); | ||
assertThat(failure).hasRootCauseInstanceOf(FlywayTeamsUpgradeRequiredException.class); | ||
assertThat(failure).hasMessageContaining(String.format(" %s ", propertyName)); | ||
}; | ||
} | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
static class FlywayDataSourceConfiguration { | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.