14 |
14 |
from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
|
15 |
15 |
from wcs.wf.remove import RemoveWorkflowStatusItem
|
16 |
16 |
from wcs.wf.roles import AddRoleWorkflowStatusItem, RemoveRoleWorkflowStatusItem
|
|
17 |
from wcs.wf.wscall import WebserviceCallStatusItem
|
17 |
18 |
|
18 |
|
from utilities import create_temporary_pub, MockSubstitutionVariables, emails
|
|
19 |
from utilities import (create_temporary_pub, MockSubstitutionVariables, emails,
|
|
20 |
http_requests)
|
19 |
21 |
|
20 |
22 |
def setup_module(module):
|
21 |
23 |
cleanup()
|
... | ... | |
325 |
327 |
item.perform(formdata)
|
326 |
328 |
assert emails.count() == 1
|
327 |
329 |
assert emails.get('foobar')['kwargs']['email_rcpt'] == ['xyz@localhost']
|
|
330 |
|
|
331 |
def test_webservice_call():
|
|
332 |
pub.substitutions.feed(MockSubstitutionVariables())
|
|
333 |
|
|
334 |
formdef = FormDef()
|
|
335 |
formdef.name = 'baz'
|
|
336 |
formdef.fields = []
|
|
337 |
formdef.store()
|
|
338 |
|
|
339 |
formdata = formdef.data_class()()
|
|
340 |
formdata.just_created()
|
|
341 |
formdata.store()
|
|
342 |
|
|
343 |
item = WebserviceCallStatusItem()
|
|
344 |
item.url = 'http://remote.example.net'
|
|
345 |
item.perform(formdata)
|
|
346 |
assert http_requests.get_last('url') == 'http://remote.example.net'
|
|
347 |
assert http_requests.get_last('method') == 'POST'
|
|
348 |
|
|
349 |
item = WebserviceCallStatusItem()
|
|
350 |
item.url = 'http://remote.example.net'
|
|
351 |
item.post = False
|
|
352 |
item.perform(formdata)
|
|
353 |
assert http_requests.get_last('url') == 'http://remote.example.net'
|
|
354 |
assert http_requests.get_last('method') == 'GET'
|
|
355 |
|
|
356 |
item = WebserviceCallStatusItem()
|
|
357 |
item.url = 'http://remote.example.net'
|
|
358 |
item.post = False
|
|
359 |
item.request_signature_key = 'xxx'
|
|
360 |
item.perform(formdata)
|
|
361 |
assert 'signature=' in http_requests.get_last('url')
|
|
362 |
assert http_requests.get_last('method') == 'GET'
|
|
363 |
|
|
364 |
item = WebserviceCallStatusItem()
|
|
365 |
item.url = 'http://remote.example.net'
|
|
366 |
item.post = False
|
|
367 |
item.request_signature_key = '[empty]'
|
|
368 |
item.perform(formdata)
|
|
369 |
assert not 'signature=' in http_requests.get_last('url')
|
|
370 |
|
|
371 |
item = WebserviceCallStatusItem()
|
|
372 |
item.url = 'http://remote.example.net'
|
|
373 |
item.post = False
|
|
374 |
item.request_signature_key = '[bar]'
|
|
375 |
item.perform(formdata)
|
|
376 |
assert 'signature=' in http_requests.get_last('url')
|