Search in sources :

Example 1 with Migration

use of org.keycloak.testsuite.arquillian.migration.Migration in project keycloak by keycloak.

the class MigrationTestExecutionDecider method decide.

@Override
public ExecutionDecision decide(Method method) {
    String migratedAuthServerVersion = System.getProperty(MIGRATED_AUTH_SERVER_VERSION_PROPERTY);
    boolean migrationTest = migratedAuthServerVersion != null;
    Migration migrationAnnotation = method.getAnnotation(Migration.class);
    if (migrationTest && migrationAnnotation != null) {
        log.info("migration from version: " + migratedAuthServerVersion);
        String versionFrom = migrationAnnotation.versionFrom();
        if (migratedAuthServerVersion.startsWith(versionFrom)) {
            return ExecutionDecision.execute();
        } else {
            return ExecutionDecision.dontExecute(method.getName() + "doesn't fit with migration version.");
        }
    }
    if ((migrationTest && migrationAnnotation == null) || (!migrationTest && migrationAnnotation != null)) {
        return ExecutionDecision.dontExecute("Migration test and no migration annotation or no migration test and migration annotation");
    }
    return ExecutionDecision.execute();
}
Also used : Migration(org.keycloak.testsuite.arquillian.migration.Migration)

Example 2 with Migration

use of org.keycloak.testsuite.arquillian.migration.Migration in project keycloak by keycloak.

the class MigrationTest method migration2_xTest.

@Test
@Migration(versionFrom = "2.")
public void migration2_xTest() throws Exception {
    // the realm with special characters in its id was succesfully migrated (no error during migration)
    // removing it now as testMigratedData() expects specific clients and roles
    // we need to perform the removal via run on server to workaround escaping parameters when using rest call
    testingClient.server().run(session -> {
        RealmModel realm = session.realms().getRealm("test ' and ; and -- and \"");
        new RealmManager(session).removeRealm(realm);
    });
    testMigratedData();
    testMigrationTo3_x();
    testMigrationTo4_x();
    testMigrationTo5_x();
    testMigrationTo6_x();
    testMigrationTo7_x(true);
    testMigrationTo8_x();
    testMigrationTo9_x();
    testMigrationTo12_x(false);
    // Always test offline-token login during migration test
    testOfflineTokenLogin();
}
Also used : RealmModel(org.keycloak.models.RealmModel) RealmManager(org.keycloak.services.managers.RealmManager) Test(org.junit.Test) Migration(org.keycloak.testsuite.arquillian.migration.Migration)

Aggregations

Migration (org.keycloak.testsuite.arquillian.migration.Migration)2 Test (org.junit.Test)1 RealmModel (org.keycloak.models.RealmModel)1 RealmManager (org.keycloak.services.managers.RealmManager)1