Skip to content

Commit 32c8258

Browse files
committed
More changes (missed a prev. commit) Error reporting clarified: CRITICAL level for unexpected conditions in saml2test; ERROR and lower for conditions in the test target; various documentation improvements
1 parent a2a4698 commit 32c8258

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/sp_test/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from saml2test import CheckError
2020
from saml2test import ContextFilter
2121
from saml2test import exception_trace
22+
from saml2test.check import CRITICAL
2223

2324
__author__ = 'rolandh'
2425

@@ -201,11 +202,17 @@ def run(self):
201202
tsum = self.test_summation(self.args.oper)
202203
except Exception, err:
203204
if conv:
205+
conv.test_output.append({"status": CRITICAL,
206+
"name": "test driver error",
207+
"id": "critial exception"})
204208
self.test_log = conv.test_output
205209
self.test_log.append(exception_trace("RUN", err))
206210
else:
207211
self.test_log = exception_trace("RUN", err)
208212
tsum = self.test_summation(self.args.oper)
213+
logger.error("Unexpected exception in test driver %s" %
214+
traceback.format_exception(*sys.exc_info()))
215+
209216

210217
if pp:
211218
pp.pprint(tsum)

src/sp_test/base.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, instance, config, interaction, json_config,
7575
self.start_page = json_config["start_page"]
7676

7777
def check_severity(self, stat):
78-
if stat["status"] >= 4:
78+
if stat["status"] >= 3:
7979
logger.error("WHERE: %s" % stat["id"])
8080
logger.error("STATUS:%s" % STATUSCODE[stat["status"]])
8181
try:
@@ -154,18 +154,12 @@ def wb_send_GET_startpage(self):
154154
self.last_response = self.instance.send(self.start_page)
155155
self._log_response(self.last_response)
156156

157-
def handle_result(self, response=None):
158-
#self.do_check(CheckHTTPResponse)
159-
if response:
160-
if isinstance(response(), VerifyEchopageContents):
157+
def handle_result(self, check_response=None):
158+
if check_response:
159+
if isinstance(check_response(), Check):
161160
if 300 < self.last_response.status_code <= 303:
162161
self._redirect(self.last_response)
163-
if self.last_response.status_code >= 400:
164-
raise FatalError("Did not expected SP redirecting to "
165-
"an error page")
166-
self.do_check(response)
167-
elif isinstance(response(), Check):
168-
self.do_check(response)
162+
self.do_check(check_response)
169163
else:
170164
# A HTTP redirect or HTTP Post
171165
if 300 < self.last_response.status_code <= 303:
@@ -334,6 +328,10 @@ def send_idp_response(self, req_flow, resp_flow):
334328
info["headers"] = {
335329
'Content-type': 'application/x-www-form-urlencoded'}
336330
self.last_response = self.instance.send(**info)
331+
try:
332+
self.last_content = self.last_response.content
333+
except AttributeError:
334+
self.last_content = None
337335

338336
self._log_response(self.last_response)
339337

src/sp_test/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from saml2 import BINDING_HTTP_REDIRECT
77
from saml2test.check import Check
8-
from saml2test.check import CRITICAL
8+
from saml2test.check import ERROR, INFORMATION, WARNING
99
from saml2test import check
1010
from saml2test.interaction import Interaction
1111

0 commit comments

Comments
 (0)