-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow the use of specific user for DML updates in Flyway #29704
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
...ns/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java
Show resolved
Hide resolved
void testDifferentUserConfig() throws SQLException { | ||
FlywayDataSourceRuntimeConfig runtimeConfig = FlywayDataSourceRuntimeConfig.defaultConfig(); | ||
FlywayDataSourceBuildTimeConfig buildConfig = FlywayDataSourceBuildTimeConfig.defaultConfig(); | ||
runtimeConfig.username = runtimeConfig.username.of("sa"); | ||
runtimeConfig.password = runtimeConfig.password.of("sa"); | ||
runtimeConfig.jdbcUrl = runtimeConfig.jdbcUrl.of("jdbc:h2:~/test"); | ||
creator = new FlywayCreator(runtimeConfig, buildConfig); | ||
Flyway flyway = creator.createFlyway(dataSource); | ||
boolean error = false; | ||
try { | ||
flyway.validate(); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
error = true; | ||
} | ||
|
||
assertEquals(false, error, "Database connection with different user failed! "); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't think this test is right.
Ideally the test(s) should check if the Flyway configuration is using the expected JDBC URL, user and password when provided
|
||
import javax.sql.DataSource; | ||
|
||
public class DataSourceDecorator implements DataSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class DataSourceDecorator implements DataSource { | |
/** | |
* Calls getConnection(user,password) for a given when getConnection() is called | |
*/ | |
class CredentialsDataSource implements DataSource { |
private DataSource dataSource; | ||
private String username; | ||
private String password; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make them final
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-test-h2</artifactId> | ||
<scope>test</scope> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be moved to the <!-- test dependencies -->
section below
Closes #24639