Fix ResetOtpTest

closes #32615

Signed-off-by: mposolda <mposolda@gmail.com>
This commit is contained in:
mposolda 2024-09-06 20:22:14 +02:00 committed by Marek Posolda
parent b88ecc0237
commit 03e0fb0601

View file

@ -3,10 +3,12 @@ package org.keycloak.testsuite.forms;
import static org.wildfly.common.Assert.assertTrue;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.After;
import org.junit.Test;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.utils.DefaultAuthenticationFlows;
import org.keycloak.representations.idm.AuthenticationExecutionRepresentation;
import org.keycloak.representations.idm.AuthenticationFlowRepresentation;
import org.keycloak.representations.idm.AuthenticatorConfigRepresentation;
@ -37,6 +39,7 @@ public class ResetOtpTest extends AbstractTestRealmKeycloakTest {
private static String resetOtpExecutionId;
private static String resetOtpConfigId;
private static String flowId;
private static String origResetCredentialsFlowId;
private static final String FLOW_ALIAS = "otpResetTestFlow";
private static final String RESET_OTP_TEST_USER_REMOVE_NONE = "reset-otp-test-user-remove-none";
@ -106,6 +109,17 @@ public class ResetOtpTest extends AbstractTestRealmKeycloakTest {
realmResource = adminClient.realm(testRealm.getRealm());
}
@After
public void afterTest() {
var realmRep = realmResource.toRepresentation();
realmRep.setResetCredentialsFlow(DefaultAuthenticationFlows.RESET_CREDENTIALS_FLOW);
realmResource.update(realmRep);
flowId = null;
resetOtpExecutionId = null;
resetOtpConfigId = null;
}
@Test
public void noOtpIsRemovedOnResetWithoutConfig_LegacyBehaviour() {
createOrChangeResetOtpFlowConfig(null);
@ -273,5 +287,7 @@ public class ResetOtpTest extends AbstractTestRealmKeycloakTest {
else {
realmResource.flows().updateAuthenticatorConfig(resetOtpConfigId, resetOtpAuthConfigRep);
}
getCleanup().addAuthenticationFlowId(flowId);
}
}