forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes keycloak#24031 Co-authored-by: Alexander Schwartz <[email protected]>
- Loading branch information
Showing
7 changed files
with
148 additions
and
11 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
41 changes: 41 additions & 0 deletions
41
...keycloak/connections/jpa/updater/liquibase/custom/JpaUpdate22_0_5_UpdateAccountTheme.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,41 @@ | ||
/* | ||
* Copyright 2023 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.connections.jpa.updater.liquibase.custom; | ||
|
||
import liquibase.exception.CustomChangeException; | ||
import liquibase.statement.core.UpdateStatement; | ||
import liquibase.structure.core.Table; | ||
|
||
/** | ||
* <p>Migration class to update themes for those who had upgraded to 22.0.0 already.</p> | ||
*/ | ||
public class JpaUpdate22_0_5_UpdateAccountTheme extends CustomKeycloakTask { | ||
|
||
@Override | ||
protected void generateStatementsImpl() throws CustomChangeException { | ||
statements.add(new UpdateStatement(null, null, database.correctObjectName("REALM", Table.class)) | ||
.addNewColumnValue("ACCOUNT_THEME", "keycloak.v2") | ||
.setWhereClause("ACCOUNT_THEME=?") | ||
.addWhereParameter("keycloak")); | ||
} | ||
|
||
@Override | ||
protected String getTaskId() { | ||
return "Update account theme for keycloak 22.0.5"; | ||
} | ||
|
||
} |
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
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
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
56 changes: 56 additions & 0 deletions
56
.../base/src/test/java/org/keycloak/testsuite/migration/JsonFileImport1903MigrationTest.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,56 @@ | ||
/* | ||
* Copyright 2023 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.junit.Test; | ||
import org.keycloak.exportimport.util.ImportUtils; | ||
import org.keycloak.representations.idm.RealmRepresentation; | ||
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. | ||
*/ | ||
public class JsonFileImport1903MigrationTest extends AbstractJsonFileImportMigrationTest { | ||
|
||
@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-19.0.3.json")); | ||
masterRep = reps.remove("master"); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
for (RealmRepresentation rep : reps.values()) { | ||
testRealms.add(rep); | ||
} | ||
} | ||
|
||
@Test | ||
public void migration19_0_3Test() throws Exception { | ||
checkRealmsImported(); | ||
testMigrationTo20_x(); | ||
testMigrationTo21_x(); | ||
testMigrationTo22_x(); | ||
} | ||
|
||
} |
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