Merge pull request #3968 from vramik/KEYCLOAK-4229
KEYCLOAK-4229 Add migration test from 2.5.5
This commit is contained in:
commit
815e9e8e02
3 changed files with 4486 additions and 3 deletions
|
@ -52,7 +52,7 @@
|
|||
<!--migration properties-->
|
||||
<migration.70.version>1.9.8.Final</migration.70.version>
|
||||
<migration.70.authz.version>2.2.1.Final</migration.70.authz.version>
|
||||
<!--<migration.71.version>2.5.1.Final</migration.71.version>-->
|
||||
<migration.71.version>2.5.5.Final</migration.71.version>
|
||||
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -176,7 +176,7 @@
|
|||
</pluginManagement>
|
||||
</build>
|
||||
</profile>
|
||||
<!-- <profile>
|
||||
<profile>
|
||||
<id>test-71-migration</id>
|
||||
<properties>
|
||||
<migrated.auth.server.version>${migration.71.version}</migrated.auth.server.version>
|
||||
|
@ -195,7 +195,7 @@
|
|||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</profile>-->
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -59,6 +59,9 @@ import org.keycloak.testsuite.runonserver.RunHelpers;
|
|||
import org.keycloak.testsuite.runonserver.RunOnServerDeployment;
|
||||
import org.keycloak.testsuite.util.OAuthClient;
|
||||
|
||||
import static org.keycloak.models.AccountRoles.MANAGE_ACCOUNT;
|
||||
import static org.keycloak.models.AccountRoles.MANAGE_ACCOUNT_LINKS;
|
||||
import static org.keycloak.models.Constants.ACCOUNT_MANAGEMENT_CLIENT_ID;
|
||||
import static org.keycloak.testsuite.Assert.assertEquals;
|
||||
import static org.keycloak.testsuite.Assert.assertFalse;
|
||||
import static org.keycloak.testsuite.Assert.assertNames;
|
||||
|
@ -111,6 +114,13 @@ public class MigrationTest extends AbstractKeycloakTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Migration(versionFrom = "2.5.5.Final")
|
||||
public void migration2_5_5Test() {
|
||||
testMigratedData();
|
||||
testMigrationTo3_0_0();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Migration(versionFrom = "1.9.8.Final")
|
||||
public void migration1_9_8Test() {
|
||||
|
@ -121,6 +131,7 @@ public class MigrationTest extends AbstractKeycloakTest {
|
|||
testMigrationTo2_3_0();
|
||||
testMigrationTo2_5_0();
|
||||
testMigrationTo2_5_1();
|
||||
testMigrationTo3_0_0();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -179,6 +190,9 @@ public class MigrationTest extends AbstractKeycloakTest {
|
|||
testExtractRealmKeys(masterRealm, migrationRealm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.keycloak.migration.migrators.MigrateTo2_5_0
|
||||
*/
|
||||
private void testMigrationTo2_5_0() {
|
||||
testLdapKerberosMigration_2_5_0();
|
||||
|
||||
|
@ -189,6 +203,36 @@ public class MigrationTest extends AbstractKeycloakTest {
|
|||
private void testMigrationTo2_5_1() {
|
||||
testOfflineTokenLogin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.keycloak.migration.migrators.MigrateTo3_0_0
|
||||
*/
|
||||
private void testMigrationTo3_0_0() {
|
||||
testRoleManageAccountLinks(masterRealm, migrationRealm);
|
||||
}
|
||||
|
||||
private void testRoleManageAccountLinks(RealmResource... realms) {
|
||||
log.info("testing role manage account links");
|
||||
for (RealmResource realm : realms) {
|
||||
List<ClientRepresentation> clients = realm.clients().findByClientId(ACCOUNT_MANAGEMENT_CLIENT_ID);
|
||||
if (!clients.isEmpty()) {
|
||||
String accountClientId = clients.get(0).getId();
|
||||
ClientResource accountClient = realm.clients().get(accountClientId);
|
||||
accountClient.roles().get(MANAGE_ACCOUNT_LINKS).toRepresentation(); //the role should be presented, it'll throw javax.ws.rs.NotFoundException in case the role is not found
|
||||
|
||||
Set<RoleRepresentation> roleComposites = accountClient.roles().get(MANAGE_ACCOUNT).getRoleComposites();
|
||||
boolean success = false;
|
||||
for (RoleRepresentation roleComposite : roleComposites) {
|
||||
if (roleComposite.getName().equals(MANAGE_ACCOUNT_LINKS)) {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
fail("'manage-account' role of client 'account' should have composite role 'manage-account-links'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testExtractRealmKeys(RealmResource masterRealm, RealmResource migrationRealm) {
|
||||
log.info("testing extract realm keys");
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue