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 saml2test.interaction import InteractionNeeded
|
||||||
|
|
||||||
from sp_test.tests import ErrorResponse
|
from sp_test.tests import ErrorResponse
|
||||||
|
from sp_test.check import VerifyEchopageContents
|
||||||
|
|
||||||
__author__ = 'rolandh'
|
__author__ = 'rolandh'
|
||||||
|
|
||||||
@@ -91,6 +92,10 @@ class Conversation():
|
|||||||
chk = self.check_factory(test)(**kwargs)
|
chk = self.check_factory(test)(**kwargs)
|
||||||
else:
|
else:
|
||||||
chk = test(**kwargs)
|
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)
|
stat = chk(self, self.test_output)
|
||||||
self.check_severity(stat)
|
self.check_severity(stat)
|
||||||
|
|
||||||
@@ -140,7 +145,7 @@ class Conversation():
|
|||||||
logger.info("<-- Status: %s" % response.status_code)
|
logger.info("<-- Status: %s" % response.status_code)
|
||||||
logger.info("<-- Content: %s" % response.content)
|
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
|
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):
|
def handle_result(self, response=None):
|
||||||
#self.do_check(CheckHTTPResponse)
|
#self.do_check(CheckHTTPResponse)
|
||||||
if response:
|
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)
|
self.do_check(response)
|
||||||
else:
|
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
|
# A HTTP redirect or HTTP Post
|
||||||
if 300 < self.last_response.status_code <= 303:
|
if 300 < self.last_response.status_code <= 303:
|
||||||
self._redirect(self.last_response)
|
self._redirect(self.last_response)
|
||||||
@@ -170,7 +187,7 @@ class Conversation():
|
|||||||
if self.last_response.status_code >= 400:
|
if self.last_response.status_code >= 400:
|
||||||
raise FatalError("Did not expected error")
|
raise FatalError("Did not expected error")
|
||||||
|
|
||||||
def handle_redirect(self):
|
def parse_saml_message(self):
|
||||||
try:
|
try:
|
||||||
url, query = self.last_response.headers["location"].split("?")
|
url, query = self.last_response.headers["location"].split("?")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -315,16 +332,16 @@ class Conversation():
|
|||||||
Un-solicited starts with the IDP sending something.
|
Un-solicited starts with the IDP sending something.
|
||||||
"""
|
"""
|
||||||
if len(flow) >= 3:
|
if len(flow) >= 3:
|
||||||
self.wb_send()
|
self.wb_send_GET_startpage()
|
||||||
self.intermit(flow[0]._interaction)
|
self.intermit(flow[0]._interaction)
|
||||||
self.handle_redirect()
|
self.parse_saml_message()
|
||||||
self.send_idp_response(flow[1], flow[2])
|
self.send_idp_response(flow[1], flow[2])
|
||||||
if len(flow) == 4:
|
if len(flow) == 4:
|
||||||
self.handle_result(flow[3])
|
self.handle_result(flow[3])
|
||||||
else:
|
else:
|
||||||
self.handle_result()
|
self.handle_result()
|
||||||
|
|
||||||
def do_sequence(self, oper, tests=None):
|
def do_sequence_and_tests(self, oper, tests=None):
|
||||||
try:
|
try:
|
||||||
self.test_sequence(tests["pre"])
|
self.test_sequence(tests["pre"])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -352,6 +369,11 @@ class Conversation():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def intermit(self, page_types):
|
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
|
_response = self.last_response
|
||||||
_last_action = None
|
_last_action = None
|
||||||
_same_actions = 0
|
_same_actions = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user