-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added testing framework modifications for flow DAT 10586 (#2981)
Co-authored-by: Steven Massaro <steven.massaro.web@gmail.com>
- Loading branch information
1 parent
6a76491
commit 0418087
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
...testing/src/main/groovy/liquibase/extension/testing/setup/SetupModifyDbCredentials.groovy
This file contains 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package liquibase.extension.testing.setup | ||
|
||
import liquibase.util.FileUtil | ||
|
||
/** | ||
* | ||
* This class allows modification of a text file to | ||
* replace tokens with the actual database credential | ||
* as specified in the environment | ||
* | ||
*/ | ||
class SetupModifyDbCredentials extends TestSetup { | ||
|
||
private static final String URL = "_URL_" | ||
private static final String USERNAME = "_USERNAME_" | ||
private static final String PASSWORD = "_PASSWORD_" | ||
private final File textFile | ||
|
||
SetupModifyDbCredentials(File textFile) { | ||
this.textFile = textFile | ||
} | ||
|
||
@Override | ||
void setup(TestSetupEnvironment testSetupEnvironment) throws Exception { | ||
String contents = FileUtil.getContents(textFile) | ||
contents = contents.replaceAll(URL, testSetupEnvironment.url) | ||
contents = contents.replaceAll(USERNAME, testSetupEnvironment.username) | ||
contents = contents.replaceAll(PASSWORD, testSetupEnvironment.password) | ||
FileUtil.write(contents, textFile) | ||
} | ||
} |