diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java index 7e070dd607..506a154a69 100644 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java @@ -24,11 +24,13 @@ import org.junit.Rule; import org.junit.Test; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; +import org.keycloak.models.UserCredentialModel; import org.keycloak.models.UserCredentialValueModel; import org.keycloak.models.UserModel; import org.keycloak.models.UserModel.RequiredAction; import org.keycloak.offlineconfig.AdminRecovery; import org.keycloak.offlineconfig.OfflineConfigException; +import org.keycloak.services.managers.RealmManager; import org.keycloak.testsuite.rule.KeycloakRule; import org.keycloak.testsuite.rule.WebRule; @@ -39,7 +41,27 @@ import org.keycloak.testsuite.rule.WebRule; */ public class AdminRecoveryTest { @ClassRule - public static KeycloakRule keycloakRule = new KeycloakRule(); + public static KeycloakRule keycloakRule = new KeycloakRule() { + + @Override + protected void after() { + + // Need to reset admin user to default password and remove required action to not break next tests + update(new KeycloakSetup() { + + @Override + public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) { + UserModel adminUser = session.users().getUserByUsername("admin", adminstrationRealm); + UserCredentialModel password = UserCredentialModel.password("admin"); + adminUser.updateCredential(password); + + adminUser.removeRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD); + } + }); + + super.after(); + } + }; @Rule public WebRule webRule = new WebRule(this);