Skip to content

Commit 1b79163

Browse files
committed
tinfojson -> discojson_sp
1 parent f4d45bf commit 1b79163

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

examples/edugain-discojson_sp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
- load:
22
- "../src/pyff/test/data/metadata/edugain-trustinfo-2.0.xml"
33
- select
4-
- tinfojson
4+
- discojson_sp
55
- publish:
6-
output: "./tinfo.json"
6+
output: "./disco_sp.json"
77
raw: true
88
update_store: false

src/pyff/builtins.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
set_pubinfo,
4141
set_reginfo,
4242
sort_entities,
43-
tinfojson_t,
43+
discojson_sp_t,
4444
)
4545
from pyff.utils import (
4646
datetime2iso,
@@ -983,14 +983,14 @@ def _discojson(req: Plumbing.Request, *opts):
983983
return json.dumps(res)
984984

985985

986-
@pipe(name='tinfojson')
987-
def _tinfojson(req, *opts):
986+
@pipe(name='discojson_sp')
987+
def _discojson_sp(req, *opts):
988988
"""
989989
990990
Return a json representation of the trust information
991991
992992
.. code-block:: yaml
993-
tinfojson:
993+
discojson_sp:
994994
995995
The returned json doc will have the following structure.
996996
@@ -1039,7 +1039,7 @@ def _tinfojson(req, *opts):
10391039
if req.t is None:
10401040
raise PipeException("Your pipeline is missing a select statement.")
10411041

1042-
res = tinfojson_t(req.t)
1042+
res = discojson_sp_t(req.t)
10431043

10441044
return json.dumps(res)
10451045

src/pyff/samlmd.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -880,58 +880,58 @@ def fetch_mdjson(urls):
880880
return entities_json
881881

882882

883-
def tinfojson(e):
884-
tinfo = {}
883+
def discojson_sp(e):
884+
sp = {}
885885

886886
tinfo_el = e.find('.//{%s}TrustInfo' % NS['ti'])
887887
if tinfo_el is None:
888888
return None
889889

890-
tinfo['entityID'] = e.get('entityID', None)
890+
sp['entityID'] = e.get('entityID', None)
891891

892892
# grab metadata sources, download metadata, and translate to json
893893
md_source_urls = [el.text for el in tinfo_el.findall('.//{%s}MetadataSource' % NS['ti'])]
894894
if len(md_source_urls) > 0:
895895
try:
896-
tinfo['extra_md'] = fetch_mdjson(md_source_urls)
896+
sp['extra_md'] = fetch_mdjson(md_source_urls)
897897
except Exception as e:
898898
raise ValueError(f"Problem interpreting metadata at {md_source_urls}: {e}")
899899

900-
tinfo['profiles'] = {}
900+
sp['profiles'] = {}
901901
# Grab trust profile emements, and translate to json
902902
for profile_el in tinfo_el.findall('.//{%s}TrustProfile' % NS['ti']):
903903
name = profile_el.attrib['name']
904-
tinfo['profiles'][name] = {'entity': [], 'entities': []}
904+
sp['profiles'][name] = {'entity': [], 'entities': []}
905905

906906
fallback_handler = tinfo_el.find('.//{%s}FallbackHandler' % NS['ti'])
907907
if fallback_handler is not None:
908908
prof = fallback_handler.attrib.get('profile', 'href')
909909
handler = fallback_handler.text
910-
tinfo['profiles'][name]['fallback_handler'] = {'profile': prof, 'handler': handler}
910+
sp['profiles'][name]['fallback_handler'] = {'profile': prof, 'handler': handler}
911911

912912
for entity_el in profile_el.findall('.//{%s}TrustedEntity' % NS['ti']):
913913
entity_id = entity_el.text
914914
include = entity_el.attrib.get('include', True)
915915
include = include if type(include) is bool else include in ('t', 'T', 'true', 'True')
916-
tinfo['profiles'][name]['entity'].append({'entity_id': entity_id, 'include': include})
916+
sp['profiles'][name]['entity'].append({'entity_id': entity_id, 'include': include})
917917

918918
for entities_el in profile_el.findall('.//{%s}TrustedEntities' % NS['ti']):
919919
select = entities_el.text
920920
match = entities_el.attrib.get('match', 'registrationAuthority')
921921
include = entities_el.attrib.get('include', True)
922922
include = include if type(include) is bool else include in ('t', 'T', 'true', 'True')
923-
tinfo['profiles'][name]['entities'].append({'select': select, 'match': match, 'include': include})
923+
sp['profiles'][name]['entities'].append({'select': select, 'match': match, 'include': include})
924924

925-
return tinfo
925+
return sp
926926

927927

928-
def tinfojson_t(t):
928+
def discojson_sp_t(t):
929929
d = []
930930

931931
for e in iter_entities(t):
932-
tinfo = tinfojson(e)
933-
if tinfo is not None:
934-
d.append(tinfo)
932+
sp = discojson_sp(e)
933+
if sp is not None:
934+
d.append(sp)
935935

936936
return d
937937

src/pyff/test/test_pipeline.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def test_parsecopy_(self):
726726
assert "Expected exception from bad namespace in"
727727
assert md.lookup(entity)
728728

729-
def test_tinfojson(self):
729+
def test_discojson_sp(self):
730730
with patch.multiple("sys", exit=self.sys_exit):
731731
tmpdir = tempfile.mkdtemp()
732732
os.rmdir(tmpdir) # lets make sure 'store' can recreate it
@@ -735,21 +735,21 @@ def test_tinfojson(self):
735735
- load:
736736
- file://%s/metadata/test02-sp.xml
737737
- select
738-
- tinfojson
738+
- discojson_sp
739739
- publish:
740-
output: %s/tinfo.json
740+
output: %s/disco_sp.json
741741
raw: true
742742
update_store: false
743743
""" % (self.datadir, tmpdir))
744-
fn = "%s/tinfo.json" % tmpdir
744+
fn = "%s/disco_sp.json" % tmpdir
745745
assert os.path.exists(fn)
746746
with open(fn, 'r') as f:
747-
tinfo_json = json.load(f)
747+
sp_json = json.load(f)
748748

749-
assert 'https://example.com.com/shibboleth' in str(tinfo_json)
750-
example_tinfo = tinfo_json[0]
751-
assert 'customer' in example_tinfo['profiles']
752-
customer_tinfo = example_tinfo['profiles']['customer']
749+
assert 'https://example.com.com/shibboleth' in str(sp_json)
750+
example_sp_json = sp_json[0]
751+
assert 'customer' in example_sp_json['profiles']
752+
customer_tinfo = example_sp_json['profiles']['customer']
753753
assert customer_tinfo['entity'][0] == {'entity_id': 'https://example.org/idp.xml', 'include': True}
754754
assert customer_tinfo['entities'][0] == {'select': 'http://www.swamid.se/', 'match': 'registrationAuthority', 'include': True}
755755
assert customer_tinfo['fallback_handler'] == {'profile': 'href', 'handler': 'https://www.example.org/about'}

0 commit comments

Comments
 (0)