diff --git a/sams_classes/sams_proxy.py b/sams_classes/sams_proxy.py index b78c9d2cbf7324572b92077a0268ab79b4e7cfaa..009032742578668c155e2fd4327bb63874b245f0 100644 --- a/sams_classes/sams_proxy.py +++ b/sams_classes/sams_proxy.py @@ -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 diff --git a/test/test_sams_proxy.py b/test/test_sams_proxy.py index 737620ab6f12aa4968fb1485f0a2f146396863dc..8390ccffea162947ec9496c376a8dc4dce70cd5b 100644 --- a/test/test_sams_proxy.py +++ b/test/test_sams_proxy.py @@ -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