Fix AdminRecoveryTest to not break admin tests
This commit is contained in:
parent
9a5ca4d367
commit
e96ba202e9
1 changed files with 23 additions and 1 deletions
|
@ -24,11 +24,13 @@ import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
|
import org.keycloak.models.UserCredentialModel;
|
||||||
import org.keycloak.models.UserCredentialValueModel;
|
import org.keycloak.models.UserCredentialValueModel;
|
||||||
import org.keycloak.models.UserModel;
|
import org.keycloak.models.UserModel;
|
||||||
import org.keycloak.models.UserModel.RequiredAction;
|
import org.keycloak.models.UserModel.RequiredAction;
|
||||||
import org.keycloak.offlineconfig.AdminRecovery;
|
import org.keycloak.offlineconfig.AdminRecovery;
|
||||||
import org.keycloak.offlineconfig.OfflineConfigException;
|
import org.keycloak.offlineconfig.OfflineConfigException;
|
||||||
|
import org.keycloak.services.managers.RealmManager;
|
||||||
import org.keycloak.testsuite.rule.KeycloakRule;
|
import org.keycloak.testsuite.rule.KeycloakRule;
|
||||||
import org.keycloak.testsuite.rule.WebRule;
|
import org.keycloak.testsuite.rule.WebRule;
|
||||||
|
|
||||||
|
@ -39,7 +41,27 @@ import org.keycloak.testsuite.rule.WebRule;
|
||||||
*/
|
*/
|
||||||
public class AdminRecoveryTest {
|
public class AdminRecoveryTest {
|
||||||
@ClassRule
|
@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
|
@Rule
|
||||||
public WebRule webRule = new WebRule(this);
|
public WebRule webRule = new WebRule(this);
|
||||||
|
|
Loading…
Reference in a new issue