KEYCLOAK-7310 Add migration test from 3.4.x to 4.x
This commit is contained in:
parent
8eabd4ae89
commit
9c1a411c6e
6 changed files with 4892 additions and 17 deletions
|
@ -494,6 +494,16 @@ public abstract class AbstractMigrationTest extends AbstractKeycloakTest {
|
||||||
String mode = getMigrationMode();
|
String mode = getMigrationMode();
|
||||||
return "import".equals(mode);
|
return "import".equals(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void testMigrationTo2_x() throws Exception {
|
||||||
|
testMigrationTo2_0_0();
|
||||||
|
testMigrationTo2_1_0();
|
||||||
|
testMigrationTo2_2_0();
|
||||||
|
testMigrationTo2_3_0();
|
||||||
|
testMigrationTo2_5_0();
|
||||||
|
testMigrationTo2_5_1();
|
||||||
|
}
|
||||||
|
|
||||||
protected void testMigrationTo3_x() {
|
protected void testMigrationTo3_x() {
|
||||||
// NOTE:
|
// NOTE:
|
||||||
testMigrationTo3_0_0();
|
testMigrationTo3_0_0();
|
||||||
|
@ -507,11 +517,4 @@ public abstract class AbstractMigrationTest extends AbstractKeycloakTest {
|
||||||
testMigrationTo4_0_0();
|
testMigrationTo4_0_0();
|
||||||
testMigrationTo4_2_0();
|
testMigrationTo4_2_0();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void testMigrationTo3_x_and_higher() {
|
|
||||||
// NOTE: add future methods
|
|
||||||
testMigrationTo3_x();
|
|
||||||
testMigrationTo4_x();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,11 @@ public class JsonFileImport198MigrationTest extends AbstractJsonFileImportMigrat
|
||||||
testMigrationTo2_3_0();
|
testMigrationTo2_3_0();
|
||||||
testMigrationTo2_5_0();
|
testMigrationTo2_5_0();
|
||||||
//testMigrationTo2_5_1(); // Offline tokens migration is skipped for JSON
|
//testMigrationTo2_5_1(); // Offline tokens migration is skipped for JSON
|
||||||
testMigrationTo3_x_and_higher();
|
testMigrationTo3_x();
|
||||||
|
testMigrationTo4_x();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void testMigrationTo2_3_0() {
|
protected void testMigrationTo2_3_0() {
|
||||||
testUpdateProtocolMappers(migrationRealm);
|
testUpdateProtocolMappers(migrationRealm);
|
||||||
testExtractRealmKeysMigrationRealm(migrationRealm);
|
testExtractRealmKeysMigrationRealm(migrationRealm);
|
||||||
|
|
|
@ -64,7 +64,8 @@ public class JsonFileImport255MigrationTest extends AbstractJsonFileImportMigrat
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void migration2_5_5Test() throws Exception {
|
public void migration2_5_5Test() throws Exception {
|
||||||
testMigrationTo3_x_and_higher();
|
testMigrationTo3_x();
|
||||||
|
testMigrationTo4_x();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.keycloak.testsuite.migration;
|
||||||
|
|
||||||
|
import org.jboss.arquillian.container.test.api.Deployment;
|
||||||
|
import org.jboss.arquillian.container.test.api.TargetsContainer;
|
||||||
|
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.keycloak.exportimport.util.ImportUtils;
|
||||||
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
import org.keycloak.testsuite.arquillian.DeploymentTargetModifier;
|
||||||
|
import org.keycloak.testsuite.runonserver.RunOnServerDeployment;
|
||||||
|
import org.keycloak.testsuite.utils.io.IOUtil;
|
||||||
|
import org.keycloak.util.JsonSerialization;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that we can import json file from previous version. MigrationTest only tests DB.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||||
|
* @version $Revision: 1 $
|
||||||
|
*/
|
||||||
|
public class JsonFileImport343MigrationTest extends AbstractJsonFileImportMigrationTest {
|
||||||
|
|
||||||
|
@Deployment
|
||||||
|
@TargetsContainer(DeploymentTargetModifier.AUTH_SERVER_CURRENT)
|
||||||
|
public static WebArchive deploy() {
|
||||||
|
return RunOnServerDeployment.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
||||||
|
Map<String, RealmRepresentation> reps = null;
|
||||||
|
try {
|
||||||
|
reps = ImportUtils.getRealmsFromStream(JsonSerialization.mapper, IOUtil.class.getResourceAsStream("/migration-test/migration-realm-3.4.3.Final.json"));
|
||||||
|
masterRep = reps.remove("master");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
for (RealmRepresentation rep : reps.values()) {
|
||||||
|
testRealms.add(rep);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void migration3_4_3Test() throws Exception {
|
||||||
|
testMigrationTo4_x();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -47,6 +47,7 @@ public class MigrationTest extends AbstractMigrationTest {
|
||||||
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
||||||
log.info("Adding no test realms for migration test. Test realm should be migrated from previous vesrion.");
|
log.info("Adding no test realms for migration test. Test realm should be migrated from previous vesrion.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void beforeMigrationTest() {
|
public void beforeMigrationTest() {
|
||||||
migrationRealm = adminClient.realms().realm(MIGRATION);
|
migrationRealm = adminClient.realms().realm(MIGRATION);
|
||||||
|
@ -58,29 +59,36 @@ public class MigrationTest extends AbstractMigrationTest {
|
||||||
addTestRealmToTestRealmReps(migrationRealm2);
|
addTestRealmToTestRealmReps(migrationRealm2);
|
||||||
addTestRealmToTestRealmReps(migrationRealm3);
|
addTestRealmToTestRealmReps(migrationRealm3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTestRealmToTestRealmReps(RealmResource realm) {
|
private void addTestRealmToTestRealmReps(RealmResource realm) {
|
||||||
try {
|
try {
|
||||||
testRealmReps.add(realm.toRepresentation());
|
testRealmReps.add(realm.toRepresentation());
|
||||||
} catch (NotFoundException ex) {
|
} catch (NotFoundException ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Migration(versionFrom = "3.4.3.Final")
|
||||||
|
public void migration3_4_3Test() {
|
||||||
|
testMigratedData();
|
||||||
|
testMigrationTo4_x();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Migration(versionFrom = "2.5.5.Final")
|
@Migration(versionFrom = "2.5.5.Final")
|
||||||
public void migration2_5_5Test() {
|
public void migration2_5_5Test() {
|
||||||
testMigratedData();
|
testMigratedData();
|
||||||
testMigrationTo3_x_and_higher();
|
testMigrationTo3_x();
|
||||||
|
testMigrationTo4_x();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Migration(versionFrom = "1.9.8.Final")
|
@Migration(versionFrom = "1.9.8.Final")
|
||||||
public void migration1_9_8Test() throws Exception {
|
public void migration1_9_8Test() throws Exception {
|
||||||
testMigratedData();
|
testMigratedData();
|
||||||
testMigrationTo2_0_0();
|
testMigrationTo2_x();
|
||||||
testMigrationTo2_1_0();
|
testMigrationTo3_x();
|
||||||
testMigrationTo2_2_0();
|
testMigrationTo4_x();
|
||||||
testMigrationTo2_3_0();
|
|
||||||
testMigrationTo2_5_0();
|
|
||||||
testMigrationTo2_5_1();
|
|
||||||
testMigrationTo3_x_and_higher();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue