Skip to content

Commit aea9da1

Browse files
committed
add support for trailing slash
1 parent 1321e1c commit aea9da1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

external-worker/flowable/external_worker_client/restclient.py

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def __init__(
2929
customize_session: Callable[[Session], None] = lambda session: None
3030
) -> None:
3131
self.flowable_host: str = flowable_host
32+
if self.flowable_host.endswith('/'):
33+
self.flowable_host = flowable_host[:-1]
3234
self.worker_id: str = worker_id
3335
self.request_session: Session = requests.Session()
3436
if auth is not None:

external-worker/tests/test_restclient.py

+31
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,34 @@ def test_job_with_cmmn_terminate(self):
293293

294294
finally:
295295
self.remove_deployment()
296+
297+
# this test is a bit special since it requires a context path.
298+
# without context path this test will also succeed with a trailing slash
299+
def test_with_trailing_slash_for_url(self):
300+
try:
301+
client = restclient.FlowableExternalWorkerRestClient(
302+
base_url + "/flowable-work/",
303+
auth=auth,
304+
worker_id='test-worker'
305+
)
306+
with self.assertRaises(restclient.FlowableRestException) as context:
307+
client.list_jobs()
308+
309+
self.assertEqual("Failed to call Flowable with status code 404", context.exception.args[0])
310+
finally:
311+
self.remove_deployment()
312+
313+
# this test is a bit special since it requires a context path.
314+
# without context path this test will also succeed with a trailing slash
315+
def test_with_trailing_slash_for_url_with_200_as_result(self):
316+
try:
317+
client = restclient.FlowableExternalWorkerRestClient(
318+
base_url + "/",
319+
auth=auth,
320+
worker_id='test-worker'
321+
)
322+
323+
jobs = client.list_jobs()
324+
self.assertEqual(0, jobs.total)
325+
finally:
326+
self.remove_deployment()

0 commit comments

Comments
 (0)