Skip to content

Commit 5144000

Browse files
authored
Merge pull request #266 from mikaelfrykholm/disco
Disco tests
2 parents 808c283 + ccd696e commit 5144000

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

NEWS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,6 @@ to sign using HSMs. The only mandatory non-python dependency now is lxml.
171171
* Fix random seeding
172172
* Fix for data handling related to non-Z timezones in metadata
173173

174+
2.1.3
175+
-----
176+
* Add DiscoveryResponse info to SPs in discojson

src/pyff/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
ser="http://eidas.europa.eu/metadata/servicelist",
3838
eidas="http://eidas.europa.eu/saml-extensions",
3939
ti="https://seamlessaccess.org/NS/trustinfo",
40+
idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol",
4041
)
4142

4243
#: These are the attribute aliases pyFF knows about. These are used to build URI paths, populate the index

src/pyff/samlmd.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,14 @@ def registration_authority(entity):
783783
return regauth_el.attrib.get('registrationAuthority')
784784

785785

786+
def discovery_responses(entity):
787+
responses = None
788+
responses_els = entity.findall(".//{%s}DiscoveryResponse" % NS['idpdisc'])
789+
if len(responses_els) > 0:
790+
responses = [el.attrib.get('Location') for el in responses_els]
791+
return responses
792+
793+
786794
def entity_extended_display(entity, langs=None):
787795
"""Utility-method for computing a displayable string for a given entity.
788796
@@ -875,6 +883,7 @@ def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store
875883
categories = entity_attribute(e, "http://macedir.org/entity-category")
876884
certifications = entity_attribute(e, "urn:oasis:names:tc:SAML:attribute:assurance-certification")
877885
cat_support = entity_attribute(e, "http://macedir.org/entity-category-support")
886+
disc_responses = discovery_responses(e)
878887

879888
d = dict(
880889
title=title,
@@ -900,6 +909,9 @@ def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store
900909
if sources is not None:
901910
d['md_source'] = sources
902911

912+
if disc_responses is not None:
913+
d["discovery_responses"] = disc_responses
914+
903915
eattr = entity_attribute_dict(e)
904916
if 'idp' in eattr[ATTRS['role']]:
905917
d['type'] = 'idp'

src/pyff/test/test_md_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ def test_load_and_query(self):
136136
assert info['title'] == 'NORDUnet'
137137
assert 'nordu.net' in info['scope']
138138

139+
# check that we get a discovery_responses where we expect one
140+
r = requests.get("{}/entities/%7Bsha1%7Dc3ba81cede254454b64ee9743df19201fe34adc9.json".format(url))
141+
assert r.status_code == 200
142+
data = r.json()
143+
info = data[0]
144+
assert 'https://box-idp.nordu.net/simplesaml/module.php/saml/sp/discoresp.php' in info['discovery_responses']
139145

140146
class PyFFAPITestResources(PipeLineTest):
141147
"""

0 commit comments

Comments
 (0)