0002-general-add-autodiscovery-of-webservice-signature-ke.patch
tests/test_wscall.py | ||
---|---|---|
60 | 60 |
pub.substitutions.feed(NamedWsCall) |
61 | 61 |
variables = pub.substitutions.get_context_variables() |
62 | 62 |
assert variables['webservice'].hello_world == {'foo': 'bar'} |
63 | ||
64 |
def test_webservice_auto_sign(pub): |
|
65 |
NamedWsCall.wipe() |
|
66 | ||
67 |
wscall = NamedWsCall() |
|
68 |
wscall.name = 'Hello world' |
|
69 |
wscall.request = {'url': 'http://blah.example.net'} |
|
70 |
try: |
|
71 |
wscall.call() |
|
72 |
except: |
|
73 |
pass |
|
74 |
assert not 'signature=' in http_requests.get_last('url') |
|
75 | ||
76 |
wscall.request = {'url': 'http://idp.example.net'} |
|
77 |
try: |
|
78 |
wscall.call() |
|
79 |
except: |
|
80 |
pass |
|
81 |
assert 'orig=example.net' in http_requests.get_last('url') |
|
82 |
assert 'signature=' in http_requests.get_last('url') |
|
83 | ||
84 |
wscall.request['request_signature_key'] = 'blah' |
|
85 |
try: |
|
86 |
wscall.call() |
|
87 |
except: |
|
88 |
pass |
|
89 |
assert not 'orig=example.net' in http_requests.get_last('url') |
|
90 |
assert 'signature=' in http_requests.get_last('url') |
wcs/wscalls.py | ||
---|---|---|
29 | 29 |
from qommon.form import (CompositeWidget, StringWidget, WidgetDict, |
30 | 30 |
ComputedExpressionWidget, RadiobuttonsWidget, CheckboxWidget) |
31 | 31 | |
32 |
from wcs.api_utils import sign_url |
|
32 |
from wcs.api_utils import sign_url, get_secret_and_orig, MissingSecret
|
|
33 | 33 |
from wcs.workflows import WorkflowStatusItem |
34 | 34 | |
35 | 35 |
TIMEOUT = 30 |
... | ... | |
42 | 42 |
variables = get_publisher().substitutions.get_context_variables() |
43 | 43 |
url = get_variadic_url(url, variables) |
44 | 44 | |
45 |
if not request_signature_key: |
|
46 |
try: |
|
47 |
request_signature_key, orig = get_secret_and_orig(url) |
|
48 |
except MissingSecret: |
|
49 |
pass |
|
50 |
else: |
|
51 |
if not qs_data: |
|
52 |
qs_data = {} |
|
53 |
qs_data['orig'] = orig |
|
54 | ||
45 | 55 |
if qs_data: # merge qs_data into url |
46 | 56 |
publisher = get_publisher() |
47 | 57 |
parsed = urlparse.urlparse(url) |
48 |
- |