diff --git a/README.md b/README.md index 398569c..a1ff1e2 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,10 @@ Generally it's: ![Command line with more flag demoed](gallery/more-flags.gif) +### Full test set with metadata, authn request and responses + +![Command line with test responses](gallery/responses.gif) + ## Profiles Each profile loads a set of test. Use `--profile $profile-name` diff --git a/gallery/responses.gif b/gallery/responses.gif new file mode 100644 index 0000000..ff62e55 Binary files /dev/null and b/gallery/responses.gif differ diff --git a/setup.py b/setup.py index 9543ffb..0010a12 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +import re + from glob import glob from setuptools import setup @@ -8,10 +10,14 @@ def readme(): _src_folder = 'src' _pkg_name = 'spid_sp_test' +with open(f'src/{_pkg_name}/__init__.py', 'r') as fd: + VERSION = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + setup( name=_pkg_name, - version='0.9.13', - description="SAML2 SPID Service Provider validation tool that can be run from the command line", + version=VERSION, + description="SAML2 SPID/CIE Service Provider validation tool that can be run from the command line", long_description=readme(), long_description_content_type='text/markdown', classifiers=['Development Status :: 5 - Production/Stable', @@ -21,7 +27,7 @@ def readme(): author='Giuseppe De Marco', author_email='giuseppe.demarco@tamdigitale.governo.it', license='License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)', - scripts=['src/spid_sp_test/spid_sp_test'], + scripts=['src/spid_sp_test/bin/spid_sp_test'], packages=[f"{_pkg_name}"], package_dir={f"{_pkg_name}": f"{_src_folder}/{_pkg_name}"}, diff --git a/src/spid_sp_test/__init__.py b/src/spid_sp_test/__init__.py index e427429..e89bcab 100644 --- a/src/spid_sp_test/__init__.py +++ b/src/spid_sp_test/__init__.py @@ -6,6 +6,7 @@ BASE_DIR = Path(__file__).resolve().parent +__version__ = '0.9.14' logger = logging.getLogger(__name__) diff --git a/src/spid_sp_test/spid_sp_test b/src/spid_sp_test/bin/spid_sp_test similarity index 97% rename from src/spid_sp_test/spid_sp_test rename to src/spid_sp_test/bin/spid_sp_test index 1a13e51..35ee165 100644 --- a/src/spid_sp_test/spid_sp_test +++ b/src/spid_sp_test/bin/spid_sp_test @@ -4,11 +4,11 @@ import json import logging import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) +sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) from saml2.metadata import entity_descriptor from saml2.server import Server -from spid_sp_test import BASE_DIR +from spid_sp_test import BASE_DIR, __version__ from spid_sp_test.metadata import SpidSpMetadataCheck from spid_sp_test.metadata_extra import SpidSpMetadataCheckExtra from spid_sp_test.authn_request import SpidSpAuthnReqCheck @@ -34,7 +34,7 @@ def selective_run(obj, profile, meth_list): if __name__ == '__main__': _desc = (f'{__file__} -h for help') - _epilog = f"""examples: + _epilog = f"""spid_sp_test {__version__} usage examples: {__file__} --metadata-url file://metadata.xml {__file__} --metadata-url http://localhost:8000/spid/metadata --extra {__file__} --metadata-url http://localhost:8000/spid/metadata -l test_Organization test_Signature @@ -255,12 +255,22 @@ if __name__ == '__main__': help='print out the default user attributes used in automatic responses' ) + parser.add_argument( + '-v', '--version', + required=False, action="store_true", + help='print out spid-sp-test version' + ) + + args = parser.parse_args() logging.basicConfig(level=getattr(logging, args.debug)) if len(sys.argv) == 1: parser.print_help(sys.stderr) sys.exit(1) + elif args.version: + print(__version__) + sys.exit(0) profile = f"test_profile_{args.profile.replace('-', '_')}" diff --git a/src/spid_sp_test/metadata.py b/src/spid_sp_test/metadata.py index 2c3b328..7a71e7b 100644 --- a/src/spid_sp_test/metadata.py +++ b/src/spid_sp_test/metadata.py @@ -179,7 +179,7 @@ def test_SPSSODescriptor_SPID(self): else: self._assertTrue( False, - f"SPSSODescriptor element not found", + "SPSSODescriptor element not found", test_id=[""], **_data, ) diff --git a/src/spid_sp_test/metadata_extra.py b/src/spid_sp_test/metadata_extra.py index 4a63950..603ea61 100644 --- a/src/spid_sp_test/metadata_extra.py +++ b/src/spid_sp_test/metadata_extra.py @@ -129,7 +129,7 @@ def test_SPSSODescriptor_extra(self): else: self._assertTrue( False, - f"SPSSODescriptor element not found", + "SPSSODescriptor element not found", test_id=[""], **_data, ) @@ -137,7 +137,7 @@ def test_SPSSODescriptor_extra(self): for attr in ["protocolSupportEnumeration", "WantAssertionsSigned"]: self._assertTrue( - (attr in spsso[0].attrib), + (attr in _spsso.attrib), f"The {attr} attribute MUST be present", description=spsso[0].attrib, test_id=["1.6.1", "1.6.7"], @@ -145,7 +145,7 @@ def test_SPSSODescriptor_extra(self): ) if attr == "protocolSupportEnumeration": - a = spsso[0].get(attr) + a = _spsso.get(attr) self._assertTrue( a, f"The {attr} attribute MUST have a value", description=a, **_data ) @@ -160,7 +160,7 @@ def test_SPSSODescriptor_extra(self): ) if attr == "WantAssertionsSigned": - a = spsso[0].get(attr) + a = _spsso.get(attr) self._assertTrue( a, f"The {attr} attribute MUST have a value", diff --git a/tests/test_01_metadata.py b/tests/test_01_metadata.py index 392fd3c..8aff974 100644 --- a/tests/test_01_metadata.py +++ b/tests/test_01_metadata.py @@ -1,7 +1,7 @@ import os DIR='metadata' -CMD = "python3 src/spid_sp_test/spid_sp_test --metadata-url file://tests/{} --extra --debug ERROR" +CMD = "python3 src/spid_sp_test/bin/spid_sp_test --metadata-url file://tests/{} --extra --debug ERROR" def run_cmd(mfname) -> int: diff --git a/tests/test_02_authn.py b/tests/test_02_authn.py index 4179707..ddc14e0 100644 --- a/tests/test_02_authn.py +++ b/tests/test_02_authn.py @@ -1,6 +1,6 @@ import os -BASE_CMD = "python3 src/spid_sp_test/spid_sp_test" +BASE_CMD = "python3 src/spid_sp_test/bin/spid_sp_test" BASE_METADATA = "spid-django-other.xml" CMD = BASE_CMD + " --extra --metadata-url file://tests/metadata/{} --authn-url file://tests/authn/{} --debug ERROR" diff --git a/tests/test_03_responses.py b/tests/test_03_responses.py index 6236d96..d036cbf 100644 --- a/tests/test_03_responses.py +++ b/tests/test_03_responses.py @@ -1,9 +1,8 @@ import os -CMD = "python3 src/spid_sp_test/spid_sp_test --metadata-url file://tests/metadata/spid-django-other.xml --authn-url file://tests/authn/spid_django_post.html --extra --debug ERROR -tr -nsr" +CMD = "python3 src/spid_sp_test/bin/spid_sp_test --metadata-url file://tests/metadata/spid-django-other.xml --authn-url file://tests/authn/spid_django_post.html --extra --debug ERROR -tr -nsr" def test_all_default_responses(): es = os.system(CMD) assert es == 0 -