mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-16 20:15:46 -06:00
Rename workflow event USER_LOGGED_IN to USER_AUTHENTICATED
Closes #44717 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
committed by
Pedro Igor
parent
93812a6e14
commit
21eeb95fbc
@@ -23,7 +23,7 @@ import static org.keycloak.models.utils.KeycloakModelUtils.GROUP_PATH_SEPARATOR;
|
||||
public enum ResourceOperationType {
|
||||
|
||||
USER_ADDED(List.of(OperationType.CREATE, EventType.REGISTER)),
|
||||
USER_LOGGED_IN(List.of(EventType.LOGIN), userLoginPredicate()),
|
||||
USER_AUTHENTICATED(List.of(EventType.LOGIN), userLoginPredicate()),
|
||||
USER_FEDERATED_IDENTITY_ADDED(List.of(FederatedIdentityCreatedEvent.class), fedIdentityPredicate()),
|
||||
USER_FEDERATED_IDENTITY_REMOVED(List.of(FederatedIdentityRemovedEvent.class), fedIdentityPredicate()),
|
||||
USER_GROUP_MEMBERSHIP_ADDED(List.of(GroupMemberJoinEvent.class), groupMembershipPredicate()),
|
||||
|
||||
@@ -70,7 +70,7 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_ADDED;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_LOGGED_IN;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_AUTHENTICATED;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
@@ -133,7 +133,7 @@ public class BrokeredUserSessionRefreshTimeWorkflowTest extends AbstractWorkflow
|
||||
public void testInvalidateWorkflowOnIdentityProviderRemoval() {
|
||||
String workflowId;
|
||||
try (Response response = consumerRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||
.onCondition(IDP_CONDITION)
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(DeleteUserStepProviderFactory.ID)
|
||||
@@ -171,7 +171,7 @@ public class BrokeredUserSessionRefreshTimeWorkflowTest extends AbstractWorkflow
|
||||
@Test
|
||||
public void tesRunStepOnFederatedUser() {
|
||||
consumerRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||
.onCondition(IDP_CONDITION)
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(DeleteUserStepProviderFactory.ID)
|
||||
|
||||
@@ -107,7 +107,7 @@ public class DeleteUserWorkflowStepTest extends AbstractWorkflowTest {
|
||||
}
|
||||
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
||||
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||
.withSteps(builder.build()).build()).close();
|
||||
|
||||
String componentId = addDummyFederationProvider();
|
||||
@@ -167,7 +167,7 @@ public class DeleteUserWorkflowStepTest extends AbstractWorkflowTest {
|
||||
// create a couple of workflows that will activate for the test user
|
||||
// the first one will run the delete user step before the second one runs its first step
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("workflow1")
|
||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
||||
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
.of(DeleteUserStepProviderFactory.ID)
|
||||
@@ -175,7 +175,7 @@ public class DeleteUserWorkflowStepTest extends AbstractWorkflowTest {
|
||||
.build()
|
||||
).build()).close();
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("workflow2")
|
||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
||||
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
.of(SetUserAttributeStepProviderFactory.ID)
|
||||
|
||||
@@ -174,7 +174,7 @@ public class ExpressionConditionWorkflowTest extends AbstractWorkflowTest {
|
||||
|
||||
private String createWorkflow(String expression, boolean creationExpectedToSucceed) {
|
||||
WorkflowRepresentation expectedWorkflow = WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent("user-logged-in(test-app)")
|
||||
.onEvent("user-authenticated(test-app)")
|
||||
.onCondition(expression)
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_ADDED;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_LOGGED_IN;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_AUTHENTICATED;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
@@ -106,7 +106,7 @@ public class GroupMembershipJoinWorkflowTest extends AbstractWorkflowTest {
|
||||
|
||||
String workflowId;
|
||||
try (Response response = managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||
.onCondition(GROUP_CONDITION)
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.keycloak.testframework.realm.UserConfigBuilder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_ADDED;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_LOGGED_IN;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_AUTHENTICATED;
|
||||
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.findEmailByRecipient;
|
||||
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.findEmailsByRecipient;
|
||||
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.verifyEmailContent;
|
||||
@@ -63,7 +63,7 @@ public class UserSessionRefreshTimeWorkflowTest extends AbstractWorkflowTest {
|
||||
@Test
|
||||
public void testDisabledUserAfterInactivityPeriod() {
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||
.concurrency().restartInProgress("true") // this setting enables restarting the workflow
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||
@@ -138,7 +138,7 @@ public class UserSessionRefreshTimeWorkflowTest extends AbstractWorkflowTest {
|
||||
@Test
|
||||
public void testMultipleWorkflows() {
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||
.after(Duration.ofDays(5))
|
||||
@@ -147,7 +147,7 @@ public class UserSessionRefreshTimeWorkflowTest extends AbstractWorkflowTest {
|
||||
.build())
|
||||
.build()).close();
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow_2")
|
||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||
.after(Duration.ofDays(10))
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.keycloak.testframework.util.ApiUtil;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_LOGGED_IN;
|
||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_AUTHENTICATED;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@@ -45,7 +45,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
||||
public void testWorkflowIsRestartedOnSameEvent() {
|
||||
// create a workflow that can be restarted on the same event - i.e. has concurrency setting with restart-in-progress=true
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_AUTHENTICATED.toString())
|
||||
.concurrency().restartInProgress("true")
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
@@ -87,7 +87,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
||||
// create a workflow that can be restarted on a different event - i.e. restart-in-progress is set to an event expression
|
||||
// in this case we will use user-group-membership-added event to restart the workflow when user joins the group "testgroup"
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_AUTHENTICATED.toString())
|
||||
.concurrency().restartInProgress("user-group-membership-added(testgroup)")
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
@@ -110,7 +110,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
||||
public void testWorkflowIsCancelledOnSameEvent() {
|
||||
// create a workflow that can be cancelled on the same event - i.e. has concurrency setting with cancel-in-progress=true
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_AUTHENTICATED.toString())
|
||||
.concurrency().cancelInProgress("true")
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
@@ -152,7 +152,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
||||
// create a workflow that can be cancelled on a different event - i.e. cancel-in-progress is set to an event expression
|
||||
// in this case we will use user-group-membership-added event to cancel the workflow when user joins the group "testgroup"
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_AUTHENTICATED.toString())
|
||||
.concurrency().cancelInProgress("user-group-membership-added(testgroup)")
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create()
|
||||
@@ -187,7 +187,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
||||
|
||||
// create workflow with both settings - restart-in-progress on same event, cancel-in-progress on different event
|
||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||
.onEvent(USER_LOGGED_IN.toString())
|
||||
.onEvent(USER_AUTHENTICATED.toString())
|
||||
.concurrency().restartInProgress("true")
|
||||
.cancelInProgress("user-group-membership-added(testgroup)")
|
||||
.withSteps(
|
||||
|
||||
@@ -197,7 +197,7 @@ public class WorkflowManagementTest extends AbstractWorkflowTest {
|
||||
}
|
||||
|
||||
workflows.create(WorkflowRepresentation.withName("another-workflow")
|
||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
||||
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||
.withSteps(
|
||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||
.after(Duration.ofDays(5))
|
||||
@@ -255,12 +255,12 @@ public class WorkflowManagementTest extends AbstractWorkflowTest {
|
||||
// while the workflow has no scheduled steps - i.e. no resource is currently going through the workflow - we can update any property
|
||||
workflow.setName("changed");
|
||||
workflow.setConditions(IdentityProviderWorkflowConditionFactory.ID + "(someidp)");
|
||||
workflow.setOn("user-logged-in");
|
||||
workflow.setOn("user-authenticated");
|
||||
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).update(workflow).close();
|
||||
workflow = workflows.workflow(workflow.getId()).toRepresentation();
|
||||
assertThat(workflow.getName(), is("changed"));
|
||||
assertThat(workflow.getOn(), is("user-logged-in"));
|
||||
assertThat(workflow.getOn(), is("user-authenticated"));
|
||||
assertThat(workflow.getConditions(), is(IdentityProviderWorkflowConditionFactory.ID + "(someidp)"));
|
||||
|
||||
// even adding or removing steps should be allowed
|
||||
|
||||
Reference in New Issue
Block a user