Skip to content

Commit

Permalink
Added testing framework modifications for flow DAT 10586 (#2981)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Massaro <steven.massaro.web@gmail.com>
  • Loading branch information
wwillard7800 and StevenMassaro committed Jun 22, 2022
1 parent 6a76491 commit 0418087
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,9 @@ Long Description: ${commandDefinition.getLongDescription() ?: "NOT SET"}
this.setups.add(new SetupModifyTextFile(textFile, originalString, newString))
}

void modifyDbCredentials(File textFile) {
this.setups.add(new SetupModifyDbCredentials(textFile))
}
private void validate() throws IllegalArgumentException {

}
Expand Down
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)
}
}

0 comments on commit 0418087

Please sign in to comment.