Skip to content

Commit 8dcee5f

Browse files
committed
Add test for unauthorized resume step
1 parent 342539d commit 8dcee5f

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

test/unit_tests/api/test_processes.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,14 @@ def authorized_resume(state):
623623
user_input = yield ConfirmForm
624624
return user_input.model_dump()
625625

626-
@step("next_step")
627-
def next_step(state):
628-
return {}
626+
@inputstep("unauthorized_resume", assignee=Assignee.SYSTEM, resume_auth_callback=disallow)
627+
def unauthorized_resume(state):
628+
user_input = yield ConfirmForm
629+
return user_input.model_dump()
629630

630631
@workflow("test_auth_workflow", target=Target.CREATE, authorize_callback=allow, retry_auth_callback=disallow)
631632
def test_auth_workflow():
632-
return init >> authorized_resume >> next_step >> done
633+
return init >> authorized_resume >> unauthorized_resume >> done
633634

634635
with WorkflowInstanceForTests(test_auth_workflow, "test_auth_workflow") as wf:
635636
yield wf
@@ -673,16 +674,34 @@ def process_on_retry(authorize_resume_workflow):
673674
return process_id
674675

675676

677+
@pytest.fixture
678+
def process_on_unauthorize_resume(process_on_resume):
679+
authorize_resume_step = ProcessStepTable(
680+
process_id=process_on_resume, name="authorized_resume", status=StepStatus.SUCCESS, state={"confirm": True}
681+
)
682+
683+
db.session.add(authorize_resume_step)
684+
db.session.commit()
685+
686+
return process_on_resume
687+
688+
676689
def test_authorized_resume_input_step(test_client, process_on_resume):
677690
response = test_client.put(f"/api/processes/{process_on_resume}/resume", json=[{"confirm": True}])
678691
assert HTTPStatus.NO_CONTENT == response.status_code
679692

680693

681-
def test_unauthorized_resume_input_step_retry(test_client, process_on_retry):
694+
def xtest_unauthorized_resume_input_step_retry(test_client, process_on_retry):
682695
response = test_client.put(f"/api/processes/{process_on_retry}/resume", json=[{"confirm": True}])
683696
assert HTTPStatus.FORBIDDEN == response.status_code
684697

685698

699+
def test_unauthorized_resume_input_step(test_client, process_on_unauthorize_resume):
700+
response = test_client.put(f"/api/processes/{process_on_unauthorize_resume}/resume", json=[{"confirm": True}])
701+
assert HTTPStatus.FORBIDDEN == response.status_code
702+
assert 1 == 0
703+
704+
686705
def _A(_: OIDCUserModel) -> bool:
687706
return True
688707

0 commit comments

Comments
 (0)