Skip to content

Commit

Permalink
chore: report metadata 19%
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelinux committed Jul 31, 2021
1 parent 92f65b6 commit 238f0b4
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/spid_sp_test/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_Signature(self):
test_id = "",
description = ''.join(desc)[:128] or "",
references = ["TR pag. 19"],
method = f"{self.__class__.__name__}.test_Signature"
method = _method
)

self._assertTrue(
Expand Down Expand Up @@ -681,11 +681,16 @@ def test_Organization(self):
orgs = self.doc.xpath("//EntityDescriptor/Organization")

desc = [etree.tostring(ent).decode() for ent in orgs if orgs]
error_kwargs = dict(description=desc) if desc else {}
_method = f"{self.__class__.__name__}.test_Organization"
_data = dict(
description = desc or "",
references = ["TR pag. 20"],
method = _method
)

self._assertTrue(
(len(orgs) == 1),
"Only one Organization element can be present - TR pag. 20",
"Only one Organization element can be present", **_data
)

enames = ["OrganizationName", "OrganizationDisplayName", "OrganizationURL"]
Expand All @@ -697,8 +702,8 @@ def test_Organization(self):
elements = org.xpath(f"./{ename}")
self._assertTrue(
len(elements) > 0,
f"One or more {ename} elements MUST be present - TR pag. 20",
**error_kwargs,
f"One or more {ename} elements MUST be present",
**_data,
)

for element in elements:
Expand All @@ -707,8 +712,8 @@ def test_Organization(self):
"{http://www.w3.org/XML/1998/namespace}lang"
in element.attrib
), # noqa
f"The lang attribute in {ename} element MUST be present - TR pag. 20", # noqa
**error_kwargs,
f"The lang attribute in {ename} element MUST be present", # noqa
**_data,
)

lang = element.attrib.items()[0][1]
Expand All @@ -719,8 +724,7 @@ def test_Organization(self):

self._assertTrue(
element.text,
f"The {ename} element MUST have a value - TR pag. 20",
**error_kwargs,
f"The {ename} element MUST have a value", **_data,
)

if ename == "OrganizationURL" and self.production:
Expand All @@ -732,8 +736,8 @@ def test_Organization(self):
OrganizationURLvalue = f"https://{OrganizationURLvalue}"
self._assertIsValidHttpUrl(
OrganizationURLvalue,
f"The {ename} -element MUST be a valid URL - TR pag. 20",
**error_kwargs,
f"The {ename} -element MUST be a valid URL",
**_data,
)

# lang counter check
Expand All @@ -745,7 +749,7 @@ def test_Organization(self):
"The elements OrganizationName, OrganizationDisplayName and OrganizationURL "
"MUST have the same number of lang attributes"
), # noqa
**error_kwargs,
**_data,
)

self._assertTrue(
Expand All @@ -754,10 +758,10 @@ def test_Organization(self):
"The elements OrganizationName, OrganizationDisplayName and OrganizationURL "
"MUST have at least an it language enabled"
), # noqa
**error_kwargs,
**_data,
)

return self.is_ok(f"{self.__class__.__name__}.test_Organization")
return self.is_ok(_method)

def test_profile_saml2core(self):
self.xsd_check(xsds_files=["saml-schema-metadata-2.0.xsd"])
Expand Down

0 comments on commit 238f0b4

Please sign in to comment.