added VerifyEchoPage; renamed wb_send and handle_redirect for readbility;
This commit is contained in:
@@ -21,6 +21,7 @@ from saml2test.interaction import Interaction
|
||||
from saml2test.interaction import InteractionNeeded
|
||||
|
||||
from sp_test.tests import ErrorResponse
|
||||
from sp_test.check import VerifyEchopageContents
|
||||
|
||||
__author__ = 'rolandh'
|
||||
|
||||
@@ -91,6 +92,10 @@ class Conversation():
|
||||
chk = self.check_factory(test)(**kwargs)
|
||||
else:
|
||||
chk = test(**kwargs)
|
||||
if not chk.call_on_redirect() and \
|
||||
300 < self.last_response.status_code <= 303:
|
||||
pass
|
||||
else:
|
||||
stat = chk(self, self.test_output)
|
||||
self.check_severity(stat)
|
||||
|
||||
@@ -140,7 +145,7 @@ class Conversation():
|
||||
logger.info("<-- Status: %s" % response.status_code)
|
||||
logger.info("<-- Content: %s" % response.content)
|
||||
|
||||
def wb_send(self):
|
||||
def wb_send_GET_startpage(self):
|
||||
"""
|
||||
The action that starts the whole sequence, a HTTP GET on a web page
|
||||
"""
|
||||
@@ -150,9 +155,21 @@ class Conversation():
|
||||
def handle_result(self, response=None):
|
||||
#self.do_check(CheckHTTPResponse)
|
||||
if response:
|
||||
if isinstance(response(), Check):
|
||||
if isinstance(response(), VerifyEchopageContents):
|
||||
if 300 < self.last_response.status_code <= 303:
|
||||
self._redirect(self.last_response)
|
||||
if self.last_response.status_code >= 400:
|
||||
raise FatalError("Did not expected SP redirecting to "
|
||||
"an error page")
|
||||
self.do_check(response)
|
||||
elif isinstance(response(), Check):
|
||||
self.do_check(response)
|
||||
else:
|
||||
# rhoerbe: I guess that this branch is never used, therefore
|
||||
# I am proposing this exception:
|
||||
#raise FatalError("can't use " + response.__class__.__name__ +
|
||||
# ", because it is not a subclass of 'Check'")
|
||||
#
|
||||
# A HTTP redirect or HTTP Post
|
||||
if 300 < self.last_response.status_code <= 303:
|
||||
self._redirect(self.last_response)
|
||||
@@ -170,7 +187,7 @@ class Conversation():
|
||||
if self.last_response.status_code >= 400:
|
||||
raise FatalError("Did not expected error")
|
||||
|
||||
def handle_redirect(self):
|
||||
def parse_saml_message(self):
|
||||
try:
|
||||
url, query = self.last_response.headers["location"].split("?")
|
||||
except KeyError:
|
||||
@@ -315,16 +332,16 @@ class Conversation():
|
||||
Un-solicited starts with the IDP sending something.
|
||||
"""
|
||||
if len(flow) >= 3:
|
||||
self.wb_send()
|
||||
self.wb_send_GET_startpage()
|
||||
self.intermit(flow[0]._interaction)
|
||||
self.handle_redirect()
|
||||
self.parse_saml_message()
|
||||
self.send_idp_response(flow[1], flow[2])
|
||||
if len(flow) == 4:
|
||||
self.handle_result(flow[3])
|
||||
else:
|
||||
self.handle_result()
|
||||
|
||||
def do_sequence(self, oper, tests=None):
|
||||
def do_sequence_and_tests(self, oper, tests=None):
|
||||
try:
|
||||
self.test_sequence(tests["pre"])
|
||||
except KeyError:
|
||||
@@ -352,6 +369,11 @@ class Conversation():
|
||||
pass
|
||||
|
||||
def intermit(self, page_types):
|
||||
"""
|
||||
Currently handles only SP-issued redirects
|
||||
|
||||
:param page_types: not used (could be used to implement wayf, disco)
|
||||
"""
|
||||
_response = self.last_response
|
||||
_last_action = None
|
||||
_same_actions = 0
|
||||
|
||||
Reference in New Issue
Block a user