Skip to content
Snippets Groups Projects
Commit 83ff9aa4 authored by Sebastian Lobinger's avatar Sebastian Lobinger
Browse files

update sams_hub.py to pass test_token_passthrough fixed issue #6

parent 455c017e
No related branches found
No related tags found
1 merge request!11Resolve "SAMSProxy entwickeln"
......@@ -38,6 +38,7 @@ class SAMSProxy:
def _pass_param(self, method, paramType, paramDict = {}):
paramDict.update(self._filter_session(method, paramType))
paramDict.update(self._filter_token(paramType))
return paramDict
def _filter_session(self, method, paramType):
......@@ -50,7 +51,13 @@ class SAMSProxy:
filteredSession[filteredParams[param]['name']] = str(session.get(param))
return filteredSession
def _get_first_dict(self, *possibleDicts)->dict:
def _filter_token(self, paramType: str) -> dict:
if paramType == self._proxySpec.get('token', {}).get('param-type'):
return {
self._proxySpec['token']['name']: self._proxySpec['token']['value']}
return {}
def _get_first_dict(self, *possibleDicts) -> dict:
for possibleDict in possibleDicts:
if isinstance(possibleDict, dict):
return possibleDict
......
......@@ -205,7 +205,7 @@ class TestSAMSHubWithThreadedAPI(unittest.TestCase):
proxySpec = {
'in': '/proxy', 'out': 'http://localhost:4711',
'token': {
'name': 'api-token', 'value': '53CUR34P170K3N',
'name': 'Api-Token', 'value': '53CUR34P170K3N',
'param-type': param_type
}
}
......@@ -222,4 +222,5 @@ class TestSAMSHubWithThreadedAPI(unittest.TestCase):
self.assertEqual(resDict['url']['u'], 'foo')
self.assertEqual(resDict['body']['g'], 'bar')
self.assertEqual(resDict['header']['Lang'], 'klingon')
self.assertEquals(resDict[param_type]['api-token'], '53CUR34P170K3N')
\ No newline at end of file
eprint(resDict[param_type])
self.assertEquals(resDict[param_type]['Api-Token'], '53CUR34P170K3N')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment