forked from prospero238/liquibase-runner
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no longer assuming just one liquibase builder per project. Also better way of testing migration
- Loading branch information
1 parent
a764793
commit 4073144
Showing
6 changed files
with
66 additions
and
198 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
63 changes: 63 additions & 0 deletions
63
src/test/java/org/jenkinsci/plugins/liquibase/evaluator/CredentialsMigratorTest.java
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,63 @@ | ||
package org.jenkinsci.plugins.liquibase.evaluator; | ||
|
||
import hudson.model.Project; | ||
import jenkins.model.Jenkins; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class CredentialsMigratorTest { | ||
|
||
|
||
private static final Logger LOG = LoggerFactory.getLogger(CredentialsMigratorTest.class); | ||
|
||
@ClassRule | ||
public static JenkinsRule jenkinsRule = new JenkinsRule().withPresetData("update-test-data"); | ||
|
||
/** | ||
* Covers JENKINS-40920. The preset data contains a job containing < 1.2.0 plugin format, and | ||
* whose credentials should therefore be migrated. | ||
* The test does verify that the old job does indeed exist in the preset data. | ||
* @throws IOException | ||
*/ | ||
@Test | ||
public void should_migrate_both_builder() throws IOException { | ||
Jenkins jenkins = jenkinsRule.getInstance(); | ||
List<Project> projects = jenkins.getItems(Project.class); | ||
|
||
boolean presetDataIncludedLiquibaseBuilder = false; | ||
boolean projectContainedMoreThanOneBuilder = false; | ||
|
||
int builderCounter = 0; | ||
|
||
for (Project project : projects) { | ||
List all = project.getBuildersList().getAll(AbstractLiquibaseBuilder.class); | ||
for (Object o : all) { | ||
AbstractLiquibaseBuilder liquibaseBuilder = (AbstractLiquibaseBuilder) o; | ||
builderCounter++; | ||
if (liquibaseBuilder!=null) { | ||
assertThat(liquibaseBuilder.getCredentialsId(), is(notNullValue())); | ||
assertThat(liquibaseBuilder.hasLegacyCredentials(), is(false)); | ||
if (!presetDataIncludedLiquibaseBuilder) { | ||
presetDataIncludedLiquibaseBuilder = true; | ||
} | ||
} | ||
} | ||
projectContainedMoreThanOneBuilder = builderCounter>1; | ||
} | ||
|
||
assertThat(presetDataIncludedLiquibaseBuilder, is(true)); | ||
assertThat(projectContainedMoreThanOneBuilder, is(true)); | ||
} | ||
|
||
} |
37 changes: 0 additions & 37 deletions
37
src/test/resources/scripted-upgrade-test/oldauth_job_config.xml
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
src/test/resources/scripted-upgrade-test/unsecured-jenkins.xml
This file was deleted.
Oops, something went wrong.
118 changes: 0 additions & 118 deletions
118
src/test/resources/scripted-upgrade-test/upgrade-credentials-test.sh
This file was deleted.
Oops, something went wrong.
Binary file not shown.