Skip to content

Commit

Permalink
add support for trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
vzickner committed Dec 2, 2024
1 parent 1321e1c commit aea9da1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions external-worker/flowable/external_worker_client/restclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(
customize_session: Callable[[Session], None] = lambda session: None
) -> None:
self.flowable_host: str = flowable_host
if self.flowable_host.endswith('/'):
self.flowable_host = flowable_host[:-1]
self.worker_id: str = worker_id
self.request_session: Session = requests.Session()
if auth is not None:
Expand Down
31 changes: 31 additions & 0 deletions external-worker/tests/test_restclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,34 @@ def test_job_with_cmmn_terminate(self):

finally:
self.remove_deployment()

# this test is a bit special since it requires a context path.
# without context path this test will also succeed with a trailing slash
def test_with_trailing_slash_for_url(self):
try:
client = restclient.FlowableExternalWorkerRestClient(
base_url + "/flowable-work/",
auth=auth,
worker_id='test-worker'
)
with self.assertRaises(restclient.FlowableRestException) as context:
client.list_jobs()

self.assertEqual("Failed to call Flowable with status code 404", context.exception.args[0])
finally:
self.remove_deployment()

# this test is a bit special since it requires a context path.
# without context path this test will also succeed with a trailing slash
def test_with_trailing_slash_for_url_with_200_as_result(self):
try:
client = restclient.FlowableExternalWorkerRestClient(
base_url + "/",
auth=auth,
worker_id='test-worker'
)

jobs = client.list_jobs()
self.assertEqual(0, jobs.total)
finally:
self.remove_deployment()

0 comments on commit aea9da1

Please sign in to comment.