Ensure that the flow tested to be deleted is a built in flow

Closes https://github.com/keycloak/keycloak/issues/20763
This commit is contained in:
rmartinc 2023-07-18 14:26:13 +02:00 committed by Marek Posolda
parent ebe6e6c965
commit ed1934d73a

View file

@ -104,13 +104,14 @@ public class FlowTest extends AbstractAuthenticationTest {
// test that built-in flow cannot be deleted
List<AuthenticationFlowRepresentation> flows = authMgmtResource.getFlows();
for (AuthenticationFlowRepresentation flow : flows) {
AuthenticationFlowRepresentation builtInFlow = flows.stream().filter(AuthenticationFlowRepresentation::isBuiltIn).findAny().orElse(null);
Assert.assertNotNull("No built in flow in the realm", builtInFlow);
try {
authMgmtResource.deleteFlow(flow.getId());
authMgmtResource.deleteFlow(builtInFlow.getId());
Assert.fail("deleteFlow should fail for built in flow");
} catch (BadRequestException e) {
break;
}
OAuth2ErrorRepresentation error = e.getResponse().readEntity(OAuth2ErrorRepresentation.class);
Assert.assertEquals("Can't delete built in flow", error.getError());
}
// try create new flow using alias of already existing flow