Skip to content

Commit 61def46

Browse files
committed
Added SATOSABackendNotFoundError exception
1 parent dade6c3 commit 61def46

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/satosa/exception.py

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class SATOSAUnknownError(SATOSAError):
3838
pass
3939

4040

41+
class SATOSABackendNotFoundError(SATOSAError):
42+
"""
43+
SATOSA Backend not existent/not found
44+
"""
45+
pass
46+
47+
4148
class SATOSAAuthenticationError(SATOSAError):
4249
"""
4350
SATOSA authentication error.

src/satosa/micro_services/custom_routing.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
from satosa.logging_util import satosa_logging
66

77
from .base import RequestMicroService
8-
from ..exception import SATOSAConfigurationError
9-
from ..exception import SATOSAError
8+
from ..exception import (SATOSAConfigurationError,
9+
SATOSAError,
10+
SATOSABackendNotFoundError)
11+
1012

1113

1214
logger = logging.getLogger(__name__)
@@ -43,12 +45,19 @@ def get_backend_by_endpoint_path(self, context, native_backend,
4345
:return: tuple or None
4446
"""
4547
entity_id = context.request.get('entityID')
48+
tr_backend = self.target_mapping.get(entity_id)
49+
4650
if not entity_id:
4751
return
4852
if entity_id not in self.target_mapping.keys():
4953
return
54+
if not tr_backend:
55+
return
56+
57+
if not backends.get(tr_backend):
58+
raise SATOSABackendNotFoundError("'{}' not found in "
59+
"proxy_conf.yaml".format(tr_backend))
5060

51-
tr_backend = self.target_mapping[entity_id]
5261
tr_path = context.path.replace(native_backend, tr_backend)
5362
for endpoint in backends[tr_backend]['endpoints']:
5463
# remove regex trailing chars

0 commit comments

Comments
 (0)