mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-17 20:44:50 -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 {
|
public enum ResourceOperationType {
|
||||||
|
|
||||||
USER_ADDED(List.of(OperationType.CREATE, EventType.REGISTER)),
|
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_ADDED(List.of(FederatedIdentityCreatedEvent.class), fedIdentityPredicate()),
|
||||||
USER_FEDERATED_IDENTITY_REMOVED(List.of(FederatedIdentityRemovedEvent.class), fedIdentityPredicate()),
|
USER_FEDERATED_IDENTITY_REMOVED(List.of(FederatedIdentityRemovedEvent.class), fedIdentityPredicate()),
|
||||||
USER_GROUP_MEMBERSHIP_ADDED(List.of(GroupMemberJoinEvent.class), groupMembershipPredicate()),
|
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 org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_ADDED;
|
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.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
@@ -133,7 +133,7 @@ public class BrokeredUserSessionRefreshTimeWorkflowTest extends AbstractWorkflow
|
|||||||
public void testInvalidateWorkflowOnIdentityProviderRemoval() {
|
public void testInvalidateWorkflowOnIdentityProviderRemoval() {
|
||||||
String workflowId;
|
String workflowId;
|
||||||
try (Response response = consumerRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
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)
|
.onCondition(IDP_CONDITION)
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(DeleteUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(DeleteUserStepProviderFactory.ID)
|
||||||
@@ -171,7 +171,7 @@ public class BrokeredUserSessionRefreshTimeWorkflowTest extends AbstractWorkflow
|
|||||||
@Test
|
@Test
|
||||||
public void tesRunStepOnFederatedUser() {
|
public void tesRunStepOnFederatedUser() {
|
||||||
consumerRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
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)
|
.onCondition(IDP_CONDITION)
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(DeleteUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(DeleteUserStepProviderFactory.ID)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class DeleteUserWorkflowStepTest extends AbstractWorkflowTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||||
.withSteps(builder.build()).build()).close();
|
.withSteps(builder.build()).build()).close();
|
||||||
|
|
||||||
String componentId = addDummyFederationProvider();
|
String componentId = addDummyFederationProvider();
|
||||||
@@ -167,7 +167,7 @@ public class DeleteUserWorkflowStepTest extends AbstractWorkflowTest {
|
|||||||
// create a couple of workflows that will activate for the test user
|
// 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
|
// the first one will run the delete user step before the second one runs its first step
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("workflow1")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("workflow1")
|
||||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
WorkflowStepRepresentation.create()
|
||||||
.of(DeleteUserStepProviderFactory.ID)
|
.of(DeleteUserStepProviderFactory.ID)
|
||||||
@@ -175,7 +175,7 @@ public class DeleteUserWorkflowStepTest extends AbstractWorkflowTest {
|
|||||||
.build()
|
.build()
|
||||||
).build()).close();
|
).build()).close();
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("workflow2")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("workflow2")
|
||||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
WorkflowStepRepresentation.create()
|
||||||
.of(SetUserAttributeStepProviderFactory.ID)
|
.of(SetUserAttributeStepProviderFactory.ID)
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ public class ExpressionConditionWorkflowTest extends AbstractWorkflowTest {
|
|||||||
|
|
||||||
private String createWorkflow(String expression, boolean creationExpectedToSucceed) {
|
private String createWorkflow(String expression, boolean creationExpectedToSucceed) {
|
||||||
WorkflowRepresentation expectedWorkflow = WorkflowRepresentation.withName("myworkflow")
|
WorkflowRepresentation expectedWorkflow = WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent("user-logged-in(test-app)")
|
.onEvent("user-authenticated(test-app)")
|
||||||
.onCondition(expression)
|
.onCondition(expression)
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
WorkflowStepRepresentation.create()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import org.awaitility.Awaitility;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_ADDED;
|
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.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
@@ -106,7 +106,7 @@ public class GroupMembershipJoinWorkflowTest extends AbstractWorkflowTest {
|
|||||||
|
|
||||||
String workflowId;
|
String workflowId;
|
||||||
try (Response response = managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
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)
|
.onCondition(GROUP_CONDITION)
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import org.keycloak.testframework.realm.UserConfigBuilder;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.keycloak.models.workflow.ResourceOperationType.USER_ADDED;
|
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.findEmailByRecipient;
|
||||||
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.findEmailsByRecipient;
|
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.findEmailsByRecipient;
|
||||||
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.verifyEmailContent;
|
import static org.keycloak.tests.admin.model.workflow.WorkflowManagementTest.verifyEmailContent;
|
||||||
@@ -63,7 +63,7 @@ public class UserSessionRefreshTimeWorkflowTest extends AbstractWorkflowTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testDisabledUserAfterInactivityPeriod() {
|
public void testDisabledUserAfterInactivityPeriod() {
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
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
|
.concurrency().restartInProgress("true") // this setting enables restarting the workflow
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||||
@@ -138,7 +138,7 @@ public class UserSessionRefreshTimeWorkflowTest extends AbstractWorkflowTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testMultipleWorkflows() {
|
public void testMultipleWorkflows() {
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||||
.after(Duration.ofDays(5))
|
.after(Duration.ofDays(5))
|
||||||
@@ -147,7 +147,7 @@ public class UserSessionRefreshTimeWorkflowTest extends AbstractWorkflowTest {
|
|||||||
.build())
|
.build())
|
||||||
.build()).close();
|
.build()).close();
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow_2")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow_2")
|
||||||
.onEvent(USER_ADDED.toString(), USER_LOGGED_IN.toString())
|
.onEvent(USER_ADDED.toString(), USER_AUTHENTICATED.toString())
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||||
.after(Duration.ofDays(10))
|
.after(Duration.ofDays(10))
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.keycloak.testframework.util.ApiUtil;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
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.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
@@ -45,7 +45,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
|||||||
public void testWorkflowIsRestartedOnSameEvent() {
|
public void testWorkflowIsRestartedOnSameEvent() {
|
||||||
// create a workflow that can be restarted on the same event - i.e. has concurrency setting with restart-in-progress=true
|
// 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")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(USER_LOGGED_IN.toString())
|
.onEvent(USER_AUTHENTICATED.toString())
|
||||||
.concurrency().restartInProgress("true")
|
.concurrency().restartInProgress("true")
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
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
|
// 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"
|
// 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")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(USER_LOGGED_IN.toString())
|
.onEvent(USER_AUTHENTICATED.toString())
|
||||||
.concurrency().restartInProgress("user-group-membership-added(testgroup)")
|
.concurrency().restartInProgress("user-group-membership-added(testgroup)")
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
WorkflowStepRepresentation.create()
|
||||||
@@ -110,7 +110,7 @@ public class WorkflowConcurrencyTest extends AbstractWorkflowTest {
|
|||||||
public void testWorkflowIsCancelledOnSameEvent() {
|
public void testWorkflowIsCancelledOnSameEvent() {
|
||||||
// create a workflow that can be cancelled on the same event - i.e. has concurrency setting with cancel-in-progress=true
|
// 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")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(USER_LOGGED_IN.toString())
|
.onEvent(USER_AUTHENTICATED.toString())
|
||||||
.concurrency().cancelInProgress("true")
|
.concurrency().cancelInProgress("true")
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
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
|
// 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"
|
// 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")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(USER_LOGGED_IN.toString())
|
.onEvent(USER_AUTHENTICATED.toString())
|
||||||
.concurrency().cancelInProgress("user-group-membership-added(testgroup)")
|
.concurrency().cancelInProgress("user-group-membership-added(testgroup)")
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create()
|
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
|
// create workflow with both settings - restart-in-progress on same event, cancel-in-progress on different event
|
||||||
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
managedRealm.admin().workflows().create(WorkflowRepresentation.withName("myworkflow")
|
||||||
.onEvent(USER_LOGGED_IN.toString())
|
.onEvent(USER_AUTHENTICATED.toString())
|
||||||
.concurrency().restartInProgress("true")
|
.concurrency().restartInProgress("true")
|
||||||
.cancelInProgress("user-group-membership-added(testgroup)")
|
.cancelInProgress("user-group-membership-added(testgroup)")
|
||||||
.withSteps(
|
.withSteps(
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public class WorkflowManagementTest extends AbstractWorkflowTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workflows.create(WorkflowRepresentation.withName("another-workflow")
|
workflows.create(WorkflowRepresentation.withName("another-workflow")
|
||||||
.onEvent(ResourceOperationType.USER_LOGGED_IN.toString())
|
.onEvent(ResourceOperationType.USER_AUTHENTICATED.toString())
|
||||||
.withSteps(
|
.withSteps(
|
||||||
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
WorkflowStepRepresentation.create().of(NotifyUserStepProviderFactory.ID)
|
||||||
.after(Duration.ofDays(5))
|
.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
|
// 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.setName("changed");
|
||||||
workflow.setConditions(IdentityProviderWorkflowConditionFactory.ID + "(someidp)");
|
workflow.setConditions(IdentityProviderWorkflowConditionFactory.ID + "(someidp)");
|
||||||
workflow.setOn("user-logged-in");
|
workflow.setOn("user-authenticated");
|
||||||
|
|
||||||
managedRealm.admin().workflows().workflow(workflow.getId()).update(workflow).close();
|
managedRealm.admin().workflows().workflow(workflow.getId()).update(workflow).close();
|
||||||
workflow = workflows.workflow(workflow.getId()).toRepresentation();
|
workflow = workflows.workflow(workflow.getId()).toRepresentation();
|
||||||
assertThat(workflow.getName(), is("changed"));
|
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)"));
|
assertThat(workflow.getConditions(), is(IdentityProviderWorkflowConditionFactory.ID + "(someidp)"));
|
||||||
|
|
||||||
// even adding or removing steps should be allowed
|
// even adding or removing steps should be allowed
|
||||||
|
|||||||
Reference in New Issue
Block a user