diff --git a/src/__init__.py b/src/__init__.py index 2ca430b..3b031d2 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,3 +1 @@ __author__ = 'rolandh' - -JSON_DUMPS_ARGS = {"ident": 4, "sort_keys": True} \ No newline at end of file diff --git a/src/idp_test/__init__.py b/src/idp_test/__init__.py index 8964a1a..379c5e3 100644 --- a/src/idp_test/__init__.py +++ b/src/idp_test/__init__.py @@ -19,6 +19,7 @@ from saml2.mdstore import MetaData from saml2test import FatalError, OperationError from saml2test import exception_trace from saml2test import ContextFilter +from saml2test import JSON_DUMPS_ARGS from idp_test.base import Conversation from idp_test.check import CheckSaml2IntMetaData @@ -34,7 +35,6 @@ from saml2.extension import mdattr from saml2.extension import ui from saml2.metadata import entity_descriptor from saml2.saml import NAME_FORMAT_UNSPECIFIED -from src import JSON_DUMPS_ARGS SCHEMA = [dri, idpdisc, md, mdattr, mdui, saml, ui, xmldsig, xmlenc] @@ -141,6 +141,7 @@ class SAML2client(object): self.constraints = {} self.operations = None self.args = None + self.client = None def json_config_file(self): if self.args.json_config_file == "-": @@ -285,15 +286,34 @@ class SAML2client(object): self.setup() except (AttributeError, ToOld), err: print >> sys.stdout, "Configuration Error: %s" % err - - self.client = Saml2Client(self.sp_config) - conv = None + return if self.args.pretty: pp = pprint.PrettyPrinter(indent=4) else: pp = None + conv = None + + try: + self.client = Saml2Client(self.sp_config) + except Exception, err: + if conv: + self.test_log = conv.test_output + self.test_log.append(exception_trace("RUN", err)) + else: + self.test_log = exception_trace("RUN", err) + tsum = self.test_summation(self.args.oper) + + if pp: + pp.pprint(tsum) + else: + print >> sys.stdout, json.dumps(tsum, **JSON_DUMPS_ARGS) + + if tsum["status"] > 1 or self.args.debug or err: + self.output_log(memoryhandler, streamhandler) + return + try: try: oper = self.operations.OPERATIONS[self.args.oper] diff --git a/src/idp_test/interaction.py b/src/idp_test/interaction.py index be11ae8..b725f54 100644 --- a/src/idp_test/interaction.py +++ b/src/idp_test/interaction.py @@ -1,4 +1,4 @@ -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rohe0002' diff --git a/src/saml2test/__init__.py b/src/saml2test/__init__.py index a4812f9..b58f807 100644 --- a/src/saml2test/__init__.py +++ b/src/saml2test/__init__.py @@ -12,6 +12,7 @@ logger = logging.getLogger(__name__) __author__ = 'rolandh' +JSON_DUMPS_ARGS = {"ident": 4, "sort_keys": True} class FatalError(Exception): pass diff --git a/src/saml2test/interaction.py b/src/saml2test/interaction.py index baca25d..e20282f 100644 --- a/src/saml2test/interaction.py +++ b/src/saml2test/interaction.py @@ -1,4 +1,4 @@ -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rohe0002' diff --git a/src/saml2test/opfunc.py b/src/saml2test/opfunc.py index 8e4a5e6..59c1e42 100644 --- a/src/saml2test/opfunc.py +++ b/src/saml2test/opfunc.py @@ -6,7 +6,7 @@ from urlparse import urlparse from mechanize import ParseResponseEx from mechanize._form import ControlNotFoundError, AmbiguityError from mechanize._form import ListControl -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rohe0002' diff --git a/src/sp_test/__init__.py b/src/sp_test/__init__.py index 20c5f36..b47cea7 100644 --- a/src/sp_test/__init__.py +++ b/src/sp_test/__init__.py @@ -19,7 +19,7 @@ from saml2test import FatalError from saml2test import CheckError from saml2test import ContextFilter from saml2test import exception_trace -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rolandh' diff --git a/tests/idp_test/target_idp.py b/tests/idp_test/target_idp.py index b6ea0ee..6953098 100755 --- a/tests/idp_test/target_idp.py +++ b/tests/idp_test/target_idp.py @@ -1,6 +1,6 @@ #!/usr/bin/env python from saml2.saml import NAME_FORMAT_URI -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rolandh' diff --git a/tests/localhost.py b/tests/localhost.py index 77a0dba..9d2149d 100755 --- a/tests/localhost.py +++ b/tests/localhost.py @@ -1,6 +1,6 @@ #!/usr/bin/env python from saml2.saml import NAME_FORMAT_URI -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rolandh' diff --git a/tests/sp_test/targetsp.py b/tests/sp_test/targetsp.py index ecf6cd8..17c5c78 100755 --- a/tests/sp_test/targetsp.py +++ b/tests/sp_test/targetsp.py @@ -1,6 +1,6 @@ #!/usr/bin/env python from saml2.saml import AUTHN_PASSWORD -from src import JSON_DUMPS_ARGS +from saml2test import JSON_DUMPS_ARGS __author__ = 'rolandh'