summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2013-04-28 10:21:57 +0200
committerRoland Hedberg <roland.hedberg@adm.umu.se>2013-04-28 10:21:57 +0200
commitff1b92f07191a208beb9035d72979e489298545d (patch)
treef72afc72a03ebe912f222e3767b4acc4f2ce29f6
parent1f3dd5de31a3de5da1160de26db40c2a17e8c971 (diff)
downloadpysaml2-ff1b92f07191a208beb9035d72979e489298545d.tar.gz
Fixed handling of 'better'.
-rw-r--r--src/saml2/authn_context/__init__.py8
-rw-r--r--tests/test_77_authn_context.py15
2 files changed, 20 insertions, 3 deletions
diff --git a/src/saml2/authn_context/__init__.py b/src/saml2/authn_context/__init__.py
index f2c01b96..1c0c3b40 100644
--- a/src/saml2/authn_context/__init__.py
+++ b/src/saml2/authn_context/__init__.py
@@ -127,10 +127,14 @@ class AuthnBroker(object):
else:
_item = self.db["info"][_refs[0]]
_level = _item["level"]
- if _item["method"]:
- res = [(_item["method"], _refs[0])]
+ if comparision_type != "better":
+ if _item["method"]:
+ res = [(_item["method"], _refs[0])]
+ else:
+ res = []
else:
res = []
+
for ref in _refs[1:]:
item = self.db[ref]
res.append((item["method"], ref))
diff --git a/tests/test_77_authn_context.py b/tests/test_77_authn_context.py
index c98c3bc6..9ab058eb 100644
--- a/tests/test_77_authn_context.py
+++ b/tests/test_77_authn_context.py
@@ -135,5 +135,18 @@ def test_authn_3():
method, ref = info[0]
assert REF2METHOD[AL4] == method
+ rac = requested_authn_context(AL1, "exact")
+
+ info = authn.pick(rac)
+ assert len(info) == 1
+ method, ref = info[0]
+ assert REF2METHOD[AL1] == method
+
+ rac = requested_authn_context(AL1, "better")
+
+ info = authn.pick(rac)
+ assert len(info) == 3
+
+
if __name__ == "__main__":
- test_authn_2() \ No newline at end of file
+ test_authn_3() \ No newline at end of file