Skip to content

Commit 8b4873e

Browse files
committed
Added SATOSABackendNotFoundError exception
1 parent dade6c3 commit 8b4873e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-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

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
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)
1011

1112

1213
logger = logging.getLogger(__name__)
@@ -43,12 +44,16 @@ def get_backend_by_endpoint_path(self, context, native_backend,
4344
:return: tuple or None
4445
"""
4546
entity_id = context.request.get('entityID')
47+
tr_backend = self.target_mapping[entity_id]
48+
4649
if not entity_id:
4750
return
4851
if entity_id not in self.target_mapping.keys():
4952
return
53+
if not backends.get(tr_backend):
54+
raise SATOSABackendNotFoundError("'{}' not found in "
55+
"proxy_conf.yaml".format(tr_backend))
5056

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

0 commit comments

Comments
 (0)