mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 23:12:06 -03:30
Rename bind endpoint to activate
Closes #44155 Signed-off-by: vramik <vramik@redhat.com>
This commit is contained in:
parent
0876ca9aa1
commit
d2697232b9
@ -27,15 +27,15 @@ public interface WorkflowResource {
|
||||
@Produces(APPLICATION_JSON)
|
||||
WorkflowRepresentation toRepresentation();
|
||||
|
||||
@Path("bind/{type}/{resourceId}")
|
||||
@Path("activate/{type}/{resourceId}")
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
void bind(@PathParam("type") String type, @PathParam("resourceId") String resourceId);
|
||||
void activate(@PathParam("type") String type, @PathParam("resourceId") String resourceId);
|
||||
|
||||
@Path("bind/{type}/{resourceId}")
|
||||
@Path("activate/{type}/{resourceId}")
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
void bind(@PathParam("type") String type, @PathParam("resourceId") String resourceId, String notBefore);
|
||||
void activate(@PathParam("type") String type, @PathParam("resourceId") String resourceId, String notBefore);
|
||||
|
||||
@Path("deactivate/{type}/{resourceId}")
|
||||
@POST
|
||||
|
||||
@ -129,7 +129,7 @@ public class DefaultWorkflowProvider implements WorkflowProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(Workflow workflow, ResourceType type, String resourceId) {
|
||||
public void activate(Workflow workflow, ResourceType type, String resourceId) {
|
||||
processEvent(Stream.of(workflow), new AdhocWorkflowEvent(type, resourceId));
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ public class DefaultWorkflowProvider implements WorkflowProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindToAllEligibleResources(Workflow workflow) {
|
||||
public void activateForAllEligibleResources(Workflow workflow) {
|
||||
if (workflow.isEnabled()) {
|
||||
WorkflowProvider provider = getWorkflowProvider(workflow);
|
||||
ResourceTypeSelector selector = provider.getResourceTypeSelector(ResourceType.USERS);
|
||||
|
||||
@ -57,7 +57,7 @@ public interface WorkflowProvider extends Provider {
|
||||
|
||||
void updateWorkflow(Workflow workflow, WorkflowRepresentation rep);
|
||||
|
||||
void bind(Workflow workflow, ResourceType type, String resourceId);
|
||||
void activate(Workflow workflow, ResourceType type, String resourceId);
|
||||
|
||||
void deactivate(Workflow workflow, String resourceId);
|
||||
|
||||
@ -65,5 +65,5 @@ public interface WorkflowProvider extends Provider {
|
||||
|
||||
void runScheduledSteps();
|
||||
|
||||
void bindToAllEligibleResources(Workflow workflow);
|
||||
void activateForAllEligibleResources(Workflow workflow);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class WorkflowResource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind the workflow to the resource.
|
||||
* Activate the workflow for the resource.
|
||||
*
|
||||
* @param type the resource type
|
||||
* @param resourceId the resource id
|
||||
@ -67,8 +67,8 @@ public class WorkflowResource {
|
||||
*/
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Path("bind/{type}/{resourceId}")
|
||||
public void bind(@PathParam("type") ResourceType type, @PathParam("resourceId") String resourceId, String notBefore) {
|
||||
@Path("activate/{type}/{resourceId}")
|
||||
public void activate(@PathParam("type") ResourceType type, @PathParam("resourceId") String resourceId, String notBefore) {
|
||||
Object resource = provider.getResourceTypeSelector(type).resolveResource(resourceId);
|
||||
|
||||
if (resource == null) {
|
||||
@ -79,7 +79,7 @@ public class WorkflowResource {
|
||||
workflow.setNotBefore(notBefore);
|
||||
}
|
||||
|
||||
provider.bind(workflow, type, resourceId);
|
||||
provider.activate(workflow, type, resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -65,7 +65,7 @@ public class AdhocWorkflowTest extends AbstractWorkflowTest {
|
||||
try (Response response = managedRealm.admin().users().create(getUserRepresentation("alice", "Alice", "Wonderland", "alice@wornderland.org"))) {
|
||||
String id = ApiUtil.getCreatedId(response);
|
||||
try {
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).bind(ResourceType.USERS.name(), id, "5D");
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).activate(ResourceType.USERS.name(), id, "5D");
|
||||
} catch (Exception e) {
|
||||
assertThat(e, instanceOf(BadRequestException.class));
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class AdhocWorkflowTest extends AbstractWorkflowTest {
|
||||
|
||||
try (Response response = managedRealm.admin().users().create(getUserRepresentation("alice", "Alice", "Wonderland", "alice@wornderland.org"))) {
|
||||
String id = ApiUtil.getCreatedId(response);
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).bind(ResourceType.USERS.name(), id);
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).activate(ResourceType.USERS.name(), id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class AdhocWorkflowTest extends AbstractWorkflowTest {
|
||||
|
||||
try (Response response = managedRealm.admin().users().create(getUserRepresentation("alice", "Alice", "Wonderland", "alice@wornderland.org"))) {
|
||||
String id = ApiUtil.getCreatedId(response);
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).bind(ResourceType.USERS.name(), id);
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).activate(ResourceType.USERS.name(), id);
|
||||
}
|
||||
|
||||
runScheduledSteps(Duration.ZERO);
|
||||
@ -135,7 +135,7 @@ public class AdhocWorkflowTest extends AbstractWorkflowTest {
|
||||
|
||||
try (Response response = managedRealm.admin().users().create(getUserRepresentation("alice", "Alice", "Wonderland", "alice@wornderland.org"))) {
|
||||
id = ApiUtil.getCreatedId(response);
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).bind(ResourceType.USERS.name(), id, "5D");
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).activate(ResourceType.USERS.name(), id, "5D");
|
||||
}
|
||||
|
||||
runScheduledSteps(Duration.ZERO);
|
||||
@ -159,7 +159,7 @@ public class AdhocWorkflowTest extends AbstractWorkflowTest {
|
||||
}));
|
||||
|
||||
// using seconds as the notBefore parameter just to check if this format is also working properly
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).bind(ResourceType.USERS.name(), id, String.valueOf(Duration.ofDays(10).toSeconds()));
|
||||
managedRealm.admin().workflows().workflow(workflow.getId()).activate(ResourceType.USERS.name(), id, String.valueOf(Duration.ofDays(10).toSeconds()));
|
||||
|
||||
runScheduledSteps(Duration.ZERO);
|
||||
|
||||
|
||||
@ -466,8 +466,8 @@ public class WorkflowManagementTest extends AbstractWorkflowTest {
|
||||
List<Workflow> registeredWorkflows = provider.getWorkflows().toList();
|
||||
assertEquals(1, registeredWorkflows.size());
|
||||
Workflow workflow = registeredWorkflows.get(0);
|
||||
// assign the workflow to the eligible users - i.e. only users from the same idp who are not yet assigned to the workflow.
|
||||
provider.bindToAllEligibleResources(workflow);
|
||||
// activate the workflow for all eligible users - i.e. only users from the same idp who are not yet assigned to the workflow.
|
||||
provider.activateForAllEligibleResources(workflow);
|
||||
});
|
||||
runOnServer.run((RunOnServer) session -> {
|
||||
RealmModel realm = session.getContext().getRealm();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user