Compare commits
2 Commits
37453e724b
...
e2309f6945
Author | SHA1 | Date |
---|---|---|
Frédéric Péters | e2309f6945 | |
Frédéric Péters | e420298ded |
|
@ -65,7 +65,7 @@ class ClicRdv(BaseResource):
|
|||
}
|
||||
return response.json()
|
||||
|
||||
@endpoint(name='interventionsets')
|
||||
@endpoint(name='interventionsets', perm='OPEN')
|
||||
def get_interventionsets(self, request, **kwargs):
|
||||
response = self.request('interventionsets')
|
||||
if 'error' in response:
|
||||
|
@ -78,7 +78,7 @@ class ClicRdv(BaseResource):
|
|||
ret.append({'id': record['id'], 'text': record['publicname'], 'details': record})
|
||||
return {'data': ret}
|
||||
|
||||
@endpoint(name='interventionsets', pattern=r'(?P<set>\d+)/')
|
||||
@endpoint(name='interventionsets', pattern=r'(?P<set>\d+)/', perm='OPEN')
|
||||
def get_interventions(self, request, set, **kwargs):
|
||||
ret = []
|
||||
response = self.request('interventions?interventionset_id=%s' % set)
|
||||
|
|
|
@ -369,7 +369,7 @@ class GenericFamily(BaseResource):
|
|||
invoices.append(format_invoice(i))
|
||||
return invoices
|
||||
|
||||
@endpoint(name='regie', pattern='^invoices/$')
|
||||
@endpoint(name='regie', perm='OPEN', pattern='^invoices/$')
|
||||
def active_invoices(self, request, NameID):
|
||||
return {'data': self.get_invoices(NameID)}
|
||||
|
||||
|
|
|
@ -209,23 +209,23 @@ class FakeConnectorBase:
|
|||
def get_connector_slug(self):
|
||||
return 'fake'
|
||||
|
||||
@endpoint()
|
||||
@endpoint(perm='OPEN')
|
||||
def foo1(self, request):
|
||||
pass
|
||||
|
||||
@endpoint(name='bar')
|
||||
@endpoint(name='bar', perm='OPEN')
|
||||
def foo2(self, request, param1):
|
||||
pass
|
||||
|
||||
@endpoint()
|
||||
@endpoint(perm='OPEN')
|
||||
def foo3(self, request, param1, param2):
|
||||
pass
|
||||
|
||||
@endpoint()
|
||||
@endpoint(perm='OPEN')
|
||||
def foo4(self, request, param1, param2='a', param3='b'):
|
||||
pass
|
||||
|
||||
@endpoint(pattern='^test/$', example_pattern='test/')
|
||||
@endpoint(pattern='^test/$', example_pattern='test/', perm='OPEN')
|
||||
def foo5(self, request, param1='a', param2='b', param3='c'):
|
||||
pass
|
||||
|
||||
|
@ -233,6 +233,7 @@ class FakeConnectorBase:
|
|||
pattern=r'^(?P<param1>\w+)/?$',
|
||||
example_pattern='{param1}/',
|
||||
parameters={'param1': {'description': 'param 1', 'example_value': 'bar'}},
|
||||
perm='OPEN',
|
||||
)
|
||||
def foo6(self, request, param1, param2='a'):
|
||||
pass
|
||||
|
@ -242,6 +243,7 @@ class FakeConnectorBase:
|
|||
description_post='foo7 post',
|
||||
description_put='foo7 put',
|
||||
methods=['get', 'post', 'put'],
|
||||
perm='OPEN',
|
||||
)
|
||||
def foo7(self, request, param1='a', param2='b', param3='c'):
|
||||
pass
|
||||
|
@ -251,6 +253,7 @@ class FakeConnectorBase:
|
|||
long_description_post='foo7 post',
|
||||
long_description_put='foo7 put',
|
||||
methods=['get', 'post', 'put'],
|
||||
perm='OPEN',
|
||||
)
|
||||
def foo7b(self, request, param1='a', param2='b', param3='c'):
|
||||
pass
|
||||
|
@ -259,7 +262,8 @@ class FakeConnectorBase:
|
|||
parameters={
|
||||
'test': {'description': 'test', 'example_value': 'test'},
|
||||
'reg': {'description': 'test', 'example_value': 'test'},
|
||||
}
|
||||
},
|
||||
perm='OPEN',
|
||||
)
|
||||
def foo8(self, request, test, reg):
|
||||
pass
|
||||
|
@ -267,12 +271,13 @@ class FakeConnectorBase:
|
|||
@endpoint(
|
||||
post={
|
||||
'long_description': 'foo9 post',
|
||||
}
|
||||
},
|
||||
perm='OPEN',
|
||||
)
|
||||
def foo9(self, request):
|
||||
pass
|
||||
|
||||
@endpoint(cache_duration=10)
|
||||
@endpoint(cache_duration=10, perm='OPEN')
|
||||
def cached_endpoint(self, request):
|
||||
pass
|
||||
|
||||
|
@ -391,12 +396,12 @@ class FakeJSONConnector:
|
|||
|
||||
BAR_SCHEMA['pre_process'] = pre_process
|
||||
|
||||
@endpoint(post={'request_body': {'schema': {'application/json': FOO_SCHEMA}}})
|
||||
@endpoint(perm='OPEN', post={'request_body': {'schema': {'application/json': FOO_SCHEMA}}})
|
||||
# pylint: disable=disallowed-name
|
||||
def foo(self, request, post_data):
|
||||
return {'data': post_data}
|
||||
|
||||
@endpoint(post={'request_body': {'schema': {'application/json': BAR_SCHEMA}}})
|
||||
@endpoint(perm='OPEN', post={'request_body': {'schema': {'application/json': BAR_SCHEMA}}})
|
||||
# pylint: disable=disallowed-name
|
||||
def bar(self, request, post_data):
|
||||
return {'data': post_data}
|
||||
|
@ -481,31 +486,31 @@ class FakeConnectorDatasource:
|
|||
def down(self):
|
||||
return False
|
||||
|
||||
@endpoint()
|
||||
@endpoint(perm='OPEN')
|
||||
def a(self, request):
|
||||
return copy.deepcopy(self.payload)
|
||||
|
||||
@endpoint(datasource=True)
|
||||
@endpoint(datasource=True, perm='OPEN')
|
||||
def b(self, request):
|
||||
return copy.deepcopy(self.payload)
|
||||
|
||||
@endpoint(datasource=True, cache_duration=10)
|
||||
@endpoint(datasource=True, cache_duration=10, perm='OPEN')
|
||||
def cached_b(self, request):
|
||||
return copy.deepcopy(self.payload)
|
||||
|
||||
@endpoint(datasource=True)
|
||||
@endpoint(datasource=True, perm='OPEN')
|
||||
def bb(self, request, id=None, q=None):
|
||||
return copy.deepcopy(self.payload)
|
||||
|
||||
@endpoint(datasource=True)
|
||||
@endpoint(datasource=True, perm='OPEN')
|
||||
def c(self, request):
|
||||
return {}
|
||||
|
||||
@endpoint(datasource=True)
|
||||
@endpoint(datasource=True, perm='OPEN')
|
||||
def d(self, request):
|
||||
return {'data': 'foobar'}
|
||||
|
||||
@endpoint(datasource=True)
|
||||
@endpoint(datasource=True, perm='OPEN')
|
||||
def e(self, request):
|
||||
return {'data': ['foobar']}
|
||||
|
||||
|
@ -620,7 +625,7 @@ def test_endpoint_description_in_template(app, db):
|
|||
|
||||
|
||||
def test_endpoint_cache(app, db, monkeypatch):
|
||||
@endpoint(cache_duration=10, methods=['get', 'post'], pattern=r'^(?P<url_param>\w+)/$')
|
||||
@endpoint(cache_duration=10, perm='OPEN', methods=['get', 'post'], pattern=r'^(?P<url_param>\w+)/$')
|
||||
def randominvoice(obj, request, url_param, get_param=None):
|
||||
return {'data': random.randint(0, pow(10, 12))}
|
||||
|
||||
|
@ -685,7 +690,7 @@ def test_endpoint_cache(app, db, monkeypatch):
|
|||
|
||||
|
||||
def test_endpoint_cookies(app, db, monkeypatch):
|
||||
@endpoint(methods=['get'])
|
||||
@endpoint(methods=['get'], perm='OPEN')
|
||||
def httpcall(obj, request):
|
||||
with responses.RequestsMock() as rsps:
|
||||
rsps.get('https://foo.invalid/set-cookie', json={}, headers={"set-cookie": "foo=bar;"})
|
||||
|
@ -745,6 +750,7 @@ def test_endpoint_typed_params(app, db, monkeypatch):
|
|||
'type': 'date',
|
||||
},
|
||||
},
|
||||
perm='OPEN',
|
||||
)
|
||||
def httpcall(obj, request, boolean=False, integer=1, floating=1.1, date=None):
|
||||
return {'boolean': boolean, 'integer': integer, 'floating': floating, 'date': date}
|
||||
|
@ -822,6 +828,7 @@ def test_endpoint_params_type_detection(app, db, monkeypatch):
|
|||
'example_value': '1970-01-01',
|
||||
},
|
||||
},
|
||||
perm='OPEN',
|
||||
)
|
||||
def httpcall(
|
||||
obj,
|
||||
|
|
|
@ -282,7 +282,7 @@ def test_proxy_logger_context(db, connector):
|
|||
def test_logged_requests_and_responses_max_size(app, db, monkeypatch, settings):
|
||||
URL = 'http://whatever.invalid'
|
||||
|
||||
@endpoint(methods=['post'])
|
||||
@endpoint(methods=['post'], perm='OPEN')
|
||||
def httpcall(self, request):
|
||||
connector_payload = {'connector_query_var': '2' * 20}
|
||||
self.requests.post(URL, connector_payload)
|
||||
|
@ -368,7 +368,7 @@ def test_proxy_logger_email_traceback(app, db, email_handler, settings, mailoutb
|
|||
settings.ADMINS = [('admin', 'admin@example.net')]
|
||||
endpoint_url = tests.utils.generic_endpoint_url('feeds', 'json', slug=connector.slug)
|
||||
|
||||
@endpoint()
|
||||
@endpoint(perm='OPEN')
|
||||
def json(self, request):
|
||||
raise requests.ConnectionError('timeout')
|
||||
|
||||
|
|
Loading…
Reference in New Issue