Conflicts:
	src/__init__.py
	src/idp_test/__init__.py
	src/idp_test/interaction.py
	src/saml2test/interaction.py
	src/saml2test/opfunc.py
	src/sp_test/__init__.py
	tests/idp_test/target_idp.py
	tests/localhost.py
	tests/sp_test/targetsp.py

Merged code from upstream and fixed some problems that popped up
This commit is contained in:
rmokiem-topdesk
2014-02-12 19:39:52 +01:00
9 changed files with 55 additions and 20 deletions

View File

@@ -19,9 +19,10 @@ from saml2.mdstore import MetaData
from saml2test import FatalError, OperationError from saml2test import FatalError, OperationError
from saml2test import exception_trace from saml2test import exception_trace
from saml2test import ContextFilter from saml2test import ContextFilter
from saml2test import JSON_DUMPS_ARGS
from idp_test.base import Conversation from base import Conversation
from idp_test.check import CheckSaml2IntMetaData from check import CheckSaml2IntMetaData
# Schemas supported # Schemas supported
from saml2 import md from saml2 import md
@@ -34,7 +35,7 @@ from saml2.extension import mdattr
from saml2.extension import ui from saml2.extension import ui
from saml2.metadata import entity_descriptor from saml2.metadata import entity_descriptor
from saml2.saml import NAME_FORMAT_UNSPECIFIED from saml2.saml import NAME_FORMAT_UNSPECIFIED
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
SCHEMA = [dri, idpdisc, md, mdattr, mdui, saml, ui, xmldsig, xmlenc] SCHEMA = [dri, idpdisc, md, mdattr, mdui, saml, ui, xmldsig, xmlenc]
@@ -149,6 +150,7 @@ class SAML2client(object):
self.constraints = {} self.constraints = {}
self.operations = None self.operations = None
self.args = None self.args = None
self.client = None
def json_config_file(self): def json_config_file(self):
if self.args.json_config_file == "-": if self.args.json_config_file == "-":
@@ -293,15 +295,34 @@ class SAML2client(object):
self.setup() self.setup()
except (AttributeError, ToOld), err: except (AttributeError, ToOld), err:
print >> sys.stdout, "Configuration Error: %s" % err print >> sys.stdout, "Configuration Error: %s" % err
return
self.client = Saml2Client(self.sp_config)
conv = None
if self.args.pretty: if self.args.pretty:
pp = pprint.PrettyPrinter(indent=4) pp = pprint.PrettyPrinter(indent=4)
else: else:
pp = None 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:
try: try:
oper = self.operations.OPERATIONS[self.args.oper] oper = self.operations.OPERATIONS[self.args.oper]

View File

@@ -1,4 +1,5 @@
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rohe0002' __author__ = 'rohe0002'

View File

@@ -12,6 +12,8 @@ logger = logging.getLogger(__name__)
__author__ = 'rolandh' __author__ = 'rolandh'
JSON_DUMPS_ARGS = {"indent": 4, "sort_keys": True}
class FatalError(Exception): class FatalError(Exception):
pass pass
@@ -21,7 +23,7 @@ class CheckError(Exception):
pass pass
class HTTP_ERROR(Exception): class HttpError(Exception):
pass pass
@@ -38,11 +40,15 @@ class ContextFilter(logging.Filter):
This is a filter which injects time laps information into the log. This is a filter which injects time laps information into the log.
""" """
def __init__(self, name=""):
logging.Filter.__init__(self, name)
self.startTime = 0
def start(self): def start(self):
self.start = time.time() self.startTime = time.time()
def filter(self, record): def filter(self, record):
record.delta = time.time() - self.start record.delta = time.time() - self.startTime
return True return True
@@ -78,7 +84,7 @@ def get_page(url):
if resp.status_code == 200: if resp.status_code == 200:
return resp.text return resp.text
else: else:
raise HTTP_ERROR(resp.status) raise HttpError(resp.status)
def exception_trace(tag, exc, log=None): def exception_trace(tag, exc, log=None):

View File

@@ -1,4 +1,5 @@
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rohe0002' __author__ = 'rohe0002'

View File

@@ -6,7 +6,9 @@ from urlparse import urlparse
from mechanize import ParseResponseEx from mechanize import ParseResponseEx
from mechanize._form import ControlNotFoundError, AmbiguityError from mechanize._form import ControlNotFoundError, AmbiguityError
from mechanize._form import ListControl from mechanize._form import ListControl
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rohe0002' __author__ = 'rohe0002'

View File

@@ -13,13 +13,14 @@ from saml2.server import Server
from saml2.config import IdPConfig from saml2.config import IdPConfig
from saml2.config import logging from saml2.config import logging
from sp_test.base import Conversation from base import Conversation
from saml2test import FatalError from saml2test import FatalError
from saml2test import CheckError from saml2test import CheckError
from saml2test import ContextFilter from saml2test import ContextFilter
from saml2test import exception_trace from saml2test import exception_trace
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rolandh' __author__ = 'rolandh'
@@ -57,8 +58,8 @@ class Client(object):
help="Configuration file for the IdP") help="Configuration file for the IdP")
self._parser.add_argument( self._parser.add_argument(
'-C', dest="ca_certs", '-C', dest="ca_certs",
help=("CA certs to use to verify HTTPS server certificates, ", help=("CA certs to use to verify HTTPS server certificates, "
"if HTTPS is used and no server CA certs are defined then ", "if HTTPS is used and no server CA certs are defined then "
"no cert verification will be done")) "no cert verification will be done"))
self._parser.add_argument('-d', dest='debug', action='store_true', self._parser.add_argument('-d', dest='debug', action='store_true',
help="Print debug information") help="Print debug information")

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rolandh' __author__ = 'rolandh'

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rolandh' __author__ = 'rolandh'

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from saml2.saml import AUTHN_PASSWORD from saml2.saml import AUTHN_PASSWORD
from commonArgs import JSON_DUMPS_ARGS #from commonArgs import JSON_DUMPS_ARGS
from saml2test import JSON_DUMPS_ARGS
__author__ = 'rolandh' __author__ = 'rolandh'