Skip to content

Commit bd44fc0

Browse files
ReeceReece
authored andcommitted
Fix unit tests by passing conf we already had, not sure why get_config fails there otherwise.
1 parent 4c259f8 commit bd44fc0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

djangosaml2/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ def available_idps(config, langpref=None):
3838
return dict([(idp, config.metadata.name(idp, langpref)) for idp in idps])
3939

4040

41-
def get_idp_sso_supported_bindings(idp_entity_id=None):
41+
def get_idp_sso_supported_bindings(idp_entity_id=None, config=None):
4242
"""Returns the list of bindings supported by an IDP
4343
This is not clear in the pysaml2 code, so wrapping it in a util"""
44-
# avoid circular import
45-
from djangosaml2.conf import get_config
44+
if config is None:
45+
# avoid circular import
46+
from djangosaml2.conf import get_config
47+
config = get_config()
4648
# load metadata store from config
47-
config = get_config()
4849
meta = getattr(config, 'metadata', {})
4950
# if idp is None, assume only one exists so just use that
50-
idp_entity_id = available_idps(config).keys().pop()
51+
if idp_entity_id is None:
52+
idp_entity_id = available_idps(config).keys().pop()
5153
try:
5254
return meta.service(idp_entity_id, 'idpsso_descriptor', 'single_sign_on_service').keys()
5355
except UnknownSystemEntity:

djangosaml2/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def login(request,
161161
binding = BINDING_HTTP_POST if sign_requests else BINDING_HTTP_REDIRECT
162162

163163
# ensure our selected binding is supported by the IDP
164-
supported_bindings = get_idp_sso_supported_bindings(selected_idp)
164+
supported_bindings = get_idp_sso_supported_bindings(selected_idp, config=conf)
165165
if binding not in supported_bindings:
166166
logger.debug('Binding %s not in IDP %s supported bindings: %s',
167167
binding, selected_idp, supported_bindings)

0 commit comments

Comments
 (0)