Skip to content

Commit

Permalink
TRUNK-6258: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Aug 14, 2024
1 parent 78b573c commit 0b8035b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/src/main/java/org/openmrs/util/DatabaseUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ public void setId(String id) {
* @return list of change sets that both have and haven't been run
*/
public static List<OpenMRSChangeSet> getDatabaseChanges() throws Exception {
Context.requirePrivilege(PrivilegeConstants.GET_DATABASE_CHANGES);
if (Context.isSessionOpen()) { // Do not check privileges if not run in webapp context (e.g. in tests)
Context.requirePrivilege(PrivilegeConstants.GET_DATABASE_CHANGES);
}
List<OpenMRSChangeSet> result = new ArrayList<>();

String initialSnapshotVersion = changeLogDetective.getInitialLiquibaseSnapshotVersion(CONTEXT,
Expand Down Expand Up @@ -651,7 +653,9 @@ public static List<OpenMRSChangeSet> getDatabaseChanges() throws Exception {
* @return list of change sets that were not run yet.
*/
public static List<OpenMRSChangeSet> getUnrunDatabaseChanges(LiquibaseProvider liquibaseProvider) throws Exception {
Context.requirePrivilege(PrivilegeConstants.GET_DATABASE_CHANGES);
if (Context.isSessionOpen()) { // Do not check privileges if not run in webapp context (e.g. in tests)
Context.requirePrivilege(PrivilegeConstants.GET_DATABASE_CHANGES);
}
String initialSnapshotVersion = changeLogDetective.getInitialLiquibaseSnapshotVersion(CONTEXT, liquibaseProvider);
log.debug("initial snapshot version is '{}'", initialSnapshotVersion);

Expand All @@ -674,7 +678,9 @@ public static List<OpenMRSChangeSet> getUnrunDatabaseChanges(LiquibaseProvider l
* @return list of change sets
*/
public static List<OpenMRSChangeSet> getUnrunDatabaseChanges(String... changeLogFilenames) {
Context.requirePrivilege(PrivilegeConstants.GET_DATABASE_CHANGES);
if (Context.isSessionOpen()) { // Do not check privileges if not run in webapp context (e.g. in tests)
Context.requirePrivilege(PrivilegeConstants.GET_DATABASE_CHANGES);
}
log.debug("looking for un-run change sets in '{}'", Arrays.toString(changeLogFilenames));

Database database = null;
Expand Down

0 comments on commit 0b8035b

Please sign in to comment.