Improved operations error handling

This commit is contained in:
Roland Hedberg
2013-08-27 14:43:05 +02:00
parent 324b638559
commit 79d78079cd
3 changed files with 29 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ from saml2.config import SPConfig
from saml2.mdstore import MetadataStore, ToOld
from saml2.mdstore import MetaData
from saml2test import FatalError
from saml2test import FatalError, OperationError
from saml2test import exception_trace
from saml2test import ContextFilter
@@ -327,6 +327,9 @@ class SAML2client(object):
self.test_log = conv.test_output
tsum = self.test_summation(self.args.oper)
err = None
except OperationError, err:
self.test_log = conv.test_output
tsum = self.test_summation(self.args.oper)
except FatalError, err:
if conv:
self.test_log = conv.test_output

View File

@@ -28,6 +28,10 @@ class Unknown(Exception):
pass
class OperationError(Exception):
pass
# class Trace(object):
# def __init__(self):
# self.trace = []

View File

@@ -6,12 +6,13 @@ from urlparse import parse_qs
from saml2test.opfunc import Operation
from saml2test import FatalError
from saml2test.check import ExpectedError
from saml2test.check import ExpectedError, ERROR
from saml2test.check import INTERACTION
from saml2test.interaction import Interaction
from saml2test.interaction import Action
from saml2test.interaction import InteractionNeeded
from saml2test.status import STATUSCODE
from saml2test import OperationError
__author__ = 'rolandh'
@@ -181,7 +182,13 @@ class Conversation(object):
if _spec == _last_action:
_same_actions += 1
if _same_actions >= 3:
raise InteractionNeeded("Interaction loop detection")
self.test_output.append(
{"status": ERROR,
"message": "Interaction loop detection",
#"id": "exception",
#"name": "interaction needed",
"url": self.position})
raise OperationError()
else:
_last_action = _spec
@@ -205,10 +212,17 @@ class Conversation(object):
self.response = _response
if _response.status_code >= 400:
logger.error("Got status code '%s', error: %s" % (
_response.status_code, content))
raise FatalError()
except (FatalError, InteractionNeeded):
txt = "Got status code '%s', error: %s" % (
_response.status_code, content)
logger.error(txt)
self.test_output.append(
{"status": ERROR,
"message": txt,
#"id": "exception",
#"name": "interaction needed",
"url": self.position})
raise OperationError()
except (FatalError, InteractionNeeded, OperationError):
raise
except Exception, err:
self.err_check("exception", err, False)
@@ -284,7 +298,7 @@ class Conversation(object):
"name": "interaction needed",
"url": self.position})
break
except FatalError:
except (FatalError, OperationError):
raise
except Exception, err:
#self.err_check("exception", err)