Allow running the tests from the pysaml2 root directory.

This improves previous work for running the tests via the
command "python setup.py test" from a fresh clone.

This can be very useful to integrate pysaml2 in a continuous
integration system such as Jenkins or Travis.
This commit is contained in:
Lorenzo Gil Sanchez
2013-04-02 17:07:54 +02:00
parent ca6afd92fc
commit 2ae12290b0
29 changed files with 205 additions and 2356 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -18,20 +18,22 @@
# #
import sys import sys
from distutils.core import Command
from setuptools import setup from setuptools import setup
from setuptools.command.test import test as TestCommand
class PyTest(Command): class PyTest(TestCommand):
user_options = []
def initialize_options(self):
pass
def finalize_options(self): def finalize_options(self):
pass TestCommand.finalize_options(self)
def run(self): self.test_args = []
import sys, subprocess self.test_suite = True
errno = subprocess.call([sys.executable, 'runtests.py'])
raise SystemExit(errno) def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
install_requires=[ install_requires=[
@@ -86,5 +88,6 @@ setup(
'mongodict': ['mongodict'] 'mongodict': ['mongodict']
}, },
zip_safe=False, zip_safe=False,
test_suite='tests',
cmdclass={'test': PyTest}, cmdclass={'test': PyTest},
) )

View File

@@ -2,11 +2,8 @@
from saml2 import BINDING_SOAP, BINDING_HTTP_REDIRECT, NAME_FORMAT_URI from saml2 import BINDING_SOAP, BINDING_HTTP_REDIRECT, NAME_FORMAT_URI
BASE = "http://localhost:8089/" BASE = "http://localhost:8089/"
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG={ CONFIG={
"service":{ "service":{
@@ -22,19 +19,19 @@ CONFIG={
"name_form": NAME_FORMAT_URI, "name_form": NAME_FORMAT_URI,
}, },
}, },
"subject_data": "aa.db", "subject_data": full_path("aa.db"),
} }
}, },
"entityid" : BASE+ "aa", "entityid" : BASE+ "aa",
"name" : "Rolands AA", "name" : "Rolands AA",
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
#"xmlsec_binary" : xmlsec_path, #"xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["metadata.xml", "vo_metadata.xml"], "local": [full_path("metadata.xml"), full_path("vo_metadata.xml")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel AB","se"),("Example Co.","en")],

View File

@@ -1,14 +1,6 @@
from saml2.extension.idpdisc import BINDING_DISCO from saml2.extension.idpdisc import BINDING_DISCO
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
except ImportError:
get_xmlsec_binary = None
if get_xmlsec_binary:
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
else:
xmlsec_path = '/usr/bin/xmlsec1'
BASE = "http://localhost:8088" BASE = "http://localhost:8088"
@@ -27,6 +19,6 @@ CONFIG = {
"debug" : 1, "debug" : 1,
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["servera.xml"], "local": [full_path("servera.xml")],
}, },
} }

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from saml2 import BINDING_SOAP, BINDING_URI from saml2 import BINDING_SOAP, BINDING_URI
from saml2 import BINDING_HTTP_REDIRECT from saml2 import BINDING_HTTP_REDIRECT
from saml2 import BINDING_HTTP_POST from saml2 import BINDING_HTTP_POST
@@ -8,15 +7,7 @@ from saml2 import BINDING_HTTP_ARTIFACT
from saml2.saml import NAMEID_FORMAT_PERSISTENT from saml2.saml import NAMEID_FORMAT_PERSISTENT
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
except ImportError:
get_xmlsec_binary = None
if get_xmlsec_binary:
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
else:
xmlsec_path = '/usr/bin/xmlsec1'
BASE = "http://localhost:8088" BASE = "http://localhost:8088"
@@ -92,13 +83,14 @@ CONFIG = {
}, },
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["servera.xml", "vo_metadata.xml"], "local": [full_path("servera.xml"),
full_path("vo_metadata.xml")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel ÄB","se"),("Example Co.","en")], "display_name": [("Exempel ÄB","se"),("Example Co.","en")],

View File

@@ -2,11 +2,7 @@ from saml2 import BINDING_SOAP, BINDING_HTTP_REDIRECT, BINDING_HTTP_POST
from saml2.saml import NAMEID_FORMAT_PERSISTENT from saml2.saml import NAMEID_FORMAT_PERSISTENT
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
BASE = "http://localhost:8088" BASE = "http://localhost:8088"
@@ -37,19 +33,20 @@ CONFIG = {
# } # }
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
#"domain": "umu.se", #"domain": "umu.se",
#"name_qualifier": "" #"name_qualifier": ""
}, },
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["metadata_sp_1.xml", "vo_metadata.xml"], "local": [full_path("metadata_sp_1.xml"),
full_path("vo_metadata.xml")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel AB","se"),("Example Co.","en")],

View File

@@ -2,11 +2,7 @@ from saml2 import BINDING_HTTP_REDIRECT
from saml2.saml import NAMEID_FORMAT_PERSISTENT from saml2.saml import NAMEID_FORMAT_PERSISTENT
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:idp", "entityid" : "urn:mace:example.com:saml:roland:idp",
@@ -30,17 +26,17 @@ CONFIG = {
"nameid_format": NAMEID_FORMAT_PERSISTENT, "nameid_format": NAMEID_FORMAT_PERSISTENT,
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["sp_slo_redirect.xml"], "local": [full_path("sp_slo_redirect.xml")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel AB","se"),("Example Co.","en")],

View File

@@ -2,11 +2,7 @@ from saml2 import BINDING_SOAP, BINDING_HTTP_REDIRECT
from saml2.saml import NAMEID_FORMAT_PERSISTENT from saml2.saml import NAMEID_FORMAT_PERSISTENT
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
try: from pathutils import full_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG={ CONFIG={
"entityid" : "urn:mace:example.com:saml:roland:idp", "entityid" : "urn:mace:example.com:saml:roland:idp",
@@ -34,17 +30,17 @@ CONFIG={
# } # }
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
#"xmlsec_binary" : xmlsec_path, #"xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["metadata.xml", "vo_metadata.xml"], "local": [full_path("metadata.xml"), full_path("vo_metadata.xml")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel AB","se"),("Example Co.","en")],

View File

@@ -6,11 +6,7 @@ from saml2.saml import NAME_FORMAT_URI
BASE = "http://localhost:8088/" BASE = "http://localhost:8088/"
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:idp", "entityid" : "urn:mace:example.com:saml:roland:idp",
@@ -39,7 +35,7 @@ CONFIG = {
# } # }
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
}, },
"sp": { "sp": {
"endpoints":{ "endpoints":{
@@ -51,13 +47,13 @@ CONFIG = {
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["metadata.xml", "vo_metadata.xml"], "local": [full_path("metadata.xml"), full_path("vo_metadata.xml")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel AB","se"),("Example Co.","en")],

19
tests/pathutils.py Normal file
View File

@@ -0,0 +1,19 @@
import os.path
BASEDIR = os.path.abspath(os.path.dirname(__file__))
def full_path(local_file):
return os.path.join(BASEDIR, local_file)
try:
from saml2.sigver import get_xmlsec_binary
except ImportError:
get_xmlsec_binary = None
if get_xmlsec_binary:
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
else:
xmlsec_path = '/usr/bin/xmlsec1'

View File

@@ -3,11 +3,7 @@ from saml2.saml import NAME_FORMAT_URI
BASE = "http://localhost:8089/" BASE = "http://localhost:8089/"
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:idpr", "entityid" : "urn:mace:example.com:saml:roland:idpr",
@@ -35,14 +31,14 @@ CONFIG = {
} }
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
} }
}, },
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["sp_0.metadata"], "local": [full_path("sp_0.metadata")],
}, },
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
} }

View File

@@ -1,9 +1,4 @@
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:sp", "entityid" : "urn:mace:example.com:saml:roland:sp",
@@ -21,11 +16,11 @@ CONFIG = {
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp_soap.xml", "vo_metadata.xml"], "local": [full_path("idp_soap.xml"), full_path("vo_metadata.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -34,7 +29,7 @@ CONFIG = {
} }
}, },
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
"display_name": ("AB Exempel", "se"), "display_name": ("AB Exempel", "se"),

View File

@@ -1,8 +1,4 @@
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:sp", "entityid" : "urn:mace:example.com:saml:roland:sp",
@@ -16,15 +12,15 @@ CONFIG = {
"required_attributes": ["surName", "givenName", "mail"], "required_attributes": ["surName", "givenName", "mail"],
"optional_attributes": ["title"], "optional_attributes": ["title"],
"idp":["urn:mace:example.com:saml:roland:idp"], "idp":["urn:mace:example.com:saml:roland:idp"],
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp_aa.xml", "vo_metadata.xml"], "local": [full_path("idp_aa.xml"), full_path("vo_metadata.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -33,7 +29,7 @@ CONFIG = {
} }
}, },
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
"display_name": ("AB Exempel", "se"), "display_name": ("AB Exempel", "se"),

View File

@@ -1,8 +1,4 @@
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG={ CONFIG={
"entityid" : "urn:mace:example.com:saml:roland:sp", "entityid" : "urn:mace:example.com:saml:roland:sp",
@@ -19,12 +15,12 @@ CONFIG={
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"ca_certs": "cacerts.txt", "ca_certs": full_path("cacerts.txt"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp.xml", "vo_metadata.xml"], "local": [full_path("idp.xml"), full_path("vo_metadata.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -34,7 +30,7 @@ CONFIG={
}, },
"subject_data": "subject_data.db", "subject_data": "subject_data.db",
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"valid_for": 6, "valid_for": 6,
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
@@ -51,7 +47,7 @@ CONFIG={
], ],
"logger": { "logger": {
"rotating": { "rotating": {
"filename": "sp.log", "filename": full_path("sp.log"),
"maxBytes": 100000, "maxBytes": 100000,
"backupCount": 5, "backupCount": 5,
}, },

View File

@@ -1,10 +1,7 @@
__author__ = 'rolandh' __author__ = 'rolandh'
try: from pathutils import full_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG={ CONFIG={
"entityid" : "urn:mace:example.com:saml:roland:sp", "entityid" : "urn:mace:example.com:saml:roland:sp",
@@ -21,11 +18,11 @@ CONFIG={
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
#"xmlsec_binary" : xmlsec_path, #"xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp.xml", "vo_metadata.xml"], "local": [full_path("idp.xml"), full_path("vo_metadata.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -33,9 +30,9 @@ CONFIG={
"common_identifier": "umuselin", "common_identifier": "umuselin",
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
"display_name": ("AB Exempel", "se"), "display_name": ("AB Exempel", "se"),

View File

@@ -7,12 +7,7 @@ from saml2 import BINDING_HTTP_ARTIFACT
from saml2.saml import NAMEID_FORMAT_TRANSIENT from saml2.saml import NAMEID_FORMAT_TRANSIENT
from saml2.saml import NAMEID_FORMAT_PERSISTENT from saml2.saml import NAMEID_FORMAT_PERSISTENT
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
BASE = "http://lingon.catalogix.se:8087" BASE = "http://lingon.catalogix.se:8087"
@@ -50,12 +45,12 @@ CONFIG={
} }
}, },
"debug": 1, "debug": 1,
"key_file": "test.key", "key_file": full_path("test.key"),
"cert_file": "test.pem", "cert_file": full_path("test.pem"),
"ca_certs": "cacerts.txt", "ca_certs": full_path("cacerts.txt"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp_all.xml", "vo_metadata.xml"], "local": [full_path("idp_all.xml"), full_path("vo_metadata.xml")],
}, },
"virtual_organization": { "virtual_organization": {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -65,7 +60,7 @@ CONFIG={
}, },
"subject_data": "subject_data.db", "subject_data": "subject_data.db",
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir": "attributemaps", "attribute_map_dir": full_path("attributemaps"),
#"valid_for": 6, #"valid_for": 6,
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),

View File

@@ -1,8 +1,5 @@
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:sp", "entityid" : "urn:mace:example.com:saml:roland:sp",
@@ -19,11 +16,11 @@ CONFIG = {
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp.xml", "vo_metadata.xml"], "local": [full_path("idp.xml"), full_path("vo_metadata.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -31,9 +28,9 @@ CONFIG = {
"common_identifier": "umuselin", "common_identifier": "umuselin",
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
"display_name": ("AB Exempel", "se"), "display_name": ("AB Exempel", "se"),

View File

@@ -1,8 +1,4 @@
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
CONFIG = { CONFIG = {
"entityid" : "urn:mace:example.com:saml:roland:sp", "entityid" : "urn:mace:example.com:saml:roland:sp",
@@ -19,11 +15,11 @@ CONFIG = {
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp_2.xml"], "local": [full_path("idp_2.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -31,9 +27,9 @@ CONFIG = {
"common_identifier": "umuselin", "common_identifier": "umuselin",
} }
}, },
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
"display_name": ("AB Exempel", "se"), "display_name": ("AB Exempel", "se"),

View File

@@ -2,11 +2,7 @@ from saml2 import BINDING_HTTP_REDIRECT
from saml2.saml import NAMEID_FORMAT_PERSISTENT from saml2.saml import NAMEID_FORMAT_PERSISTENT
from saml2.saml import NAME_FORMAT_URI from saml2.saml import NAME_FORMAT_URI
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
HOME = "http://lingon.catalogix.se:8087/" HOME = "http://lingon.catalogix.se:8087/"
CONFIG = { CONFIG = {
@@ -24,15 +20,15 @@ CONFIG = {
"required_attributes": ["surName", "givenName", "mail"], "required_attributes": ["surName", "givenName", "mail"],
"optional_attributes": ["title"], "optional_attributes": ["title"],
"idp": ["urn:mace:example.com:saml:roland:idp"], "idp": ["urn:mace:example.com:saml:roland:idp"],
"subject_data": "subject_data.db", "subject_data": full_path("subject_data.db"),
} }
}, },
"debug" : 1, "debug" : 1,
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"xmlsec_binary" : xmlsec_path, "xmlsec_binary" : xmlsec_path,
"metadata": { "metadata": {
"local": ["idp_slo_redirect.xml"], "local": [full_path("idp_slo_redirect.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"urn:mace:example.com:it:tek":{ "urn:mace:example.com:it:tek":{
@@ -41,7 +37,7 @@ CONFIG = {
} }
}, },
"accepted_time_diff": 60, "accepted_time_diff": 60,
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : full_path("attributemaps"),
"organization": { "organization": {
"name": ("AB Exempel", "se"), "name": ("AB Exempel", "se"),
"display_name": ("AB Exempel", "se"), "display_name": ("AB Exempel", "se"),

View File

@@ -19,6 +19,8 @@ from saml2.saml import Attribute, NAME_FORMAT_URI, AttributeValue
from py.test import raises from py.test import raises
from pathutils import full_path
SUCCESS_STATUS = """<?xml version=\'1.0\' encoding=\'UTF-8\'?> SUCCESS_STATUS = """<?xml version=\'1.0\' encoding=\'UTF-8\'?>
<ns0:Status xmlns:ns0="urn:oasis:names:tc:SAML:2.0:protocol"><ns0:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" /></ns0:Status>""" <ns0:Status xmlns:ns0="urn:oasis:names:tc:SAML:2.0:protocol"><ns0:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" /></ns0:Status>"""
@@ -273,7 +275,7 @@ def test_subject():
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
def test_parse_attribute_map(): def test_parse_attribute_map():
(forward, backward) = utils.parse_attribute_map(["attribute.map"]) (forward, backward) = utils.parse_attribute_map([full_path("attribute.map")])
assert _eq(forward.keys(), backward.values()) assert _eq(forward.keys(), backward.values())
assert _eq(forward.values(), backward.keys()) assert _eq(forward.values(), backward.keys())
@@ -300,7 +302,7 @@ def test_parse_attribute_map():
def test_identity_attribute_0(): def test_identity_attribute_0():
(forward, backward) = utils.parse_attribute_map(["attribute.map"]) (forward, backward) = utils.parse_attribute_map([full_path("attribute.map")])
a = Attribute(name="urn:oid:2.5.4.4", name_format=NAME_FORMAT_URI, a = Attribute(name="urn:oid:2.5.4.4", name_format=NAME_FORMAT_URI,
friendly_name="surName") friendly_name="surName")
@@ -308,14 +310,14 @@ def test_identity_attribute_0():
assert utils.identity_attribute("friendly",a,forward) == "surName" assert utils.identity_attribute("friendly",a,forward) == "surName"
def test_identity_attribute_1(): def test_identity_attribute_1():
(forward, backward) = utils.parse_attribute_map(["attribute.map"]) (forward, backward) = utils.parse_attribute_map([full_path("attribute.map")])
a = Attribute(name="urn:oid:2.5.4.4", name_format=NAME_FORMAT_URI) a = Attribute(name="urn:oid:2.5.4.4", name_format=NAME_FORMAT_URI)
assert utils.identity_attribute("name",a,forward) == "urn:oid:2.5.4.4" assert utils.identity_attribute("name",a,forward) == "urn:oid:2.5.4.4"
assert utils.identity_attribute("friendly",a,forward) == "surName" assert utils.identity_attribute("friendly",a,forward) == "surName"
def test_identity_attribute_2(): def test_identity_attribute_2():
(forward, backward) = utils.parse_attribute_map(["attribute.map"]) (forward, backward) = utils.parse_attribute_map([full_path("attribute.map")])
a = Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI) a = Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI)
assert utils.identity_attribute("name",a,forward) == "urn:oid:2.5.4.5" assert utils.identity_attribute("name",a,forward) == "urn:oid:2.5.4.5"
@@ -450,4 +452,4 @@ def test_signature():
assert utils.verify_signature("abcdef", arr) assert utils.verify_signature("abcdef", arr)

View File

@@ -18,6 +18,8 @@ from saml2 import saml
import xmldsig import xmldsig
import xmlenc import xmlenc
from pathutils import full_path
ONTS = [saml, mdui, mdattr, dri, ui, idpdisc, md, xmldsig, xmlenc] ONTS = [saml, mdui, mdattr, dri, ui, idpdisc, md, xmldsig, xmlenc]
def _eq(l1,l2): def _eq(l1,l2):
@@ -283,7 +285,7 @@ def test_assertion_2():
}) })
ava = ava.apply_policy( "", policy ) ava = ava.apply_policy( "", policy )
acs = ac_factory("attributemaps") acs = ac_factory(full_path("attributemaps"))
attribute=from_local(acs, ava, policy.get_name_form("")) attribute=from_local(acs, ava, policy.get_name_form(""))
assert len(attribute) == 4 assert len(attribute) == 4
@@ -418,7 +420,7 @@ def test_filter_values_req_opt_4():
name="urn:oid:2.5.4.12", name="urn:oid:2.5.4.12",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")] name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")]
acs = attribute_converter.ac_factory("attributemaps") acs = attribute_converter.ac_factory(full_path("attributemaps"))
rava = attribute_converter.ava_fro(acs, r) rava = attribute_converter.ava_fro(acs, r)
oava = attribute_converter.ava_fro(acs, o) oava = attribute_converter.ava_fro(acs, o)
@@ -589,7 +591,7 @@ def test_filter_on_wire_representation_1():
name="urn:oid:2.5.4.12", name="urn:oid:2.5.4.12",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")] name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")]
acs = attribute_converter.ac_factory("attributemaps") acs = attribute_converter.ac_factory(full_path("attributemaps"))
ava = { "sn":["Hedberg"], "givenname":["Roland"], ava = { "sn":["Hedberg"], "givenname":["Roland"],
"edupersonaffiliation":["staff"],"uid":["rohe0002"]} "edupersonaffiliation":["staff"],"uid":["rohe0002"]}
@@ -608,10 +610,10 @@ def test_filter_on_wire_representation_2():
name="urn:oid:2.5.4.12", name="urn:oid:2.5.4.12",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")] name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")]
acs = attribute_converter.ac_factory("attributemaps") acs = attribute_converter.ac_factory(full_path("attributemaps"))
ava = { "sn":["Hedberg"], "givenname":["Roland"], ava = { "sn":["Hedberg"], "givenname":["Roland"],
"title":["Master"],"uid":["rohe0002"]} "title":["Master"],"uid":["rohe0002"]}
ava = assertion.filter_on_wire_representation(ava, acs, r, o) ava = assertion.filter_on_wire_representation(ava, acs, r, o)
assert _eq(ava.keys(), ["sn", "givenname", "title"]) assert _eq(ava.keys(), ["sn", "givenname", "title"])

View File

@@ -4,6 +4,8 @@ from saml2 import attribute_converter, saml
from attribute_statement_data import * from attribute_statement_data import *
from pathutils import full_path
def _eq(l1,l2): def _eq(l1,l2):
return set(l1) == set(l2) return set(l1) == set(l2)
@@ -17,7 +19,7 @@ def test_default():
class TestAC(): class TestAC():
def setup_class(self): def setup_class(self):
self.acs = attribute_converter.ac_factory("attributemaps") self.acs = attribute_converter.ac_factory(full_path("attributemaps"))
def test_setup(self): def test_setup(self):
print self.acs print self.acs
@@ -157,4 +159,4 @@ class TestAC():
oava = basic_ac.fro(attr_state) oava = basic_ac.fro(attr_state)
assert _eq(ava.keys(), oava.keys()) assert _eq(ava.keys(), oava.keys())

View File

@@ -24,11 +24,7 @@ from saml2.s_utils import UnknownPrincipal
import xmldsig import xmldsig
import xmlenc import xmlenc
try: from pathutils import full_path, xmlsec_path
from saml2.sigver import get_xmlsec_binary
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
except ImportError:
xmlsec_path = '/usr/bin/xmlsec1'
ONTS = { ONTS = {
@@ -43,32 +39,33 @@ ONTS = {
xmlenc.NAMESPACE: xmlenc xmlenc.NAMESPACE: xmlenc
} }
ATTRCONV = ac_factory("attributemaps") ATTRCONV = ac_factory(full_path("attributemaps"))
METADATACONF = { METADATACONF = {
"1": { "1": {
"local": ["swamid-1.0.xml"] "local": [full_path("swamid-1.0.xml")]
}, },
"2": { "2": {
"local": ["InCommon-metadata.xml"] "local": [full_path("InCommon-metadata.xml")]
}, },
"3": { "3": {
"local": ["extended.xml"] "local": [full_path("extended.xml")]
}, },
"7": { "7": {
"local": ["metadata_sp_1.xml", "InCommon-metadata.xml"], "local": [full_path("metadata_sp_1.xml"),
full_path("InCommon-metadata.xml")],
"remote": [ "remote": [
{"url": "https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2", {"url": "https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
"cert": "kalmar2.pem"}] "cert": full_path("kalmar2.pem")}]
}, },
"4": { "4": {
"local": ["metadata_example.xml"] "local": [full_path("metadata_example.xml")]
}, },
"5": { "5": {
"local": ["metadata.aaitest.xml"] "local": [full_path("metadata.aaitest.xml")]
}, },
"6": { "6": {
"local": ["metasp.xml"] "local": [full_path("metasp.xml")]
} }
} }

View File

@@ -11,6 +11,8 @@ from py.test import raises
from saml2 import root_logger from saml2 import root_logger
from pathutils import full_path
sp1 = { sp1 = {
"entityid" : "urn:mace:umu.se:saml:roland:sp", "entityid" : "urn:mace:umu.se:saml:roland:sp",
"service": { "service": {
@@ -26,12 +28,12 @@ sp1 = {
} }
} }
}, },
"key_file" : "mykey.pem", "key_file" : full_path("mykey.pem"),
"cert_file" : "mycert.pem", "cert_file" : full_path("mycert.pem"),
#"xmlsec_binary" : "/opt/local/bin/xmlsec1", #"xmlsec_binary" : "/opt/local/bin/xmlsec1",
"metadata": { "metadata": {
"local": ["metadata.xml", "local": [full_path("metadata.xml"),
"urn-mace-swami.se-swamid-test-1.0-metadata.xml"], full_path("urn-mace-swami.se-swamid-test-1.0-metadata.xml")],
}, },
"virtual_organization" : { "virtual_organization" : {
"coip":{ "coip":{
@@ -42,7 +44,7 @@ sp1 = {
] ]
} }
}, },
"attribute_map_dir": "attributemaps", "attribute_map_dir": full_path("attributemaps"),
"only_use_keys_in_metadata": True, "only_use_keys_in_metadata": True,
} }
@@ -124,8 +126,8 @@ PDP = {
}, },
} }
}, },
"key_file" : "test.key", "key_file" : full_path("test.key"),
"cert_file" : "test.pem", "cert_file" : full_path("test.pem"),
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel AB","se"),("Example Co.","en")],
@@ -295,11 +297,11 @@ def test_conf_syslog():
#noinspection PyUnresolvedReferences #noinspection PyUnresolvedReferences
def test_3(): def test_3():
cnf = Config() cnf = Config()
cnf.load_file("sp_1_conf") cnf.load_file("tests.sp_1_conf")
assert cnf.entityid == "urn:mace:example.com:saml:roland:sp" assert cnf.entityid == "urn:mace:example.com:saml:roland:sp"
assert cnf.debug == 1 assert cnf.debug == 1
assert cnf.key_file == "test.key" assert cnf.key_file == full_path("test.key")
assert cnf.cert_file == "test.pem" assert cnf.cert_file == full_path("test.pem")
#assert cnf.xmlsec_binary == "/usr/local/bin/xmlsec1" #assert cnf.xmlsec_binary == "/usr/local/bin/xmlsec1"
assert cnf.accepted_time_diff == 60 assert cnf.accepted_time_diff == 60
assert cnf.secret == "0123456789" assert cnf.secret == "0123456789"
@@ -308,12 +310,12 @@ def test_3():
def test_sp(): def test_sp():
cnf = SPConfig() cnf = SPConfig()
cnf.load_file("sp_1_conf") cnf.load_file("tests.sp_1_conf")
assert cnf.endpoint("assertion_consumer_service") == \ assert cnf.endpoint("assertion_consumer_service") == \
["http://lingon.catalogix.se:8087/"] ["http://lingon.catalogix.se:8087/"]
def test_dual(): def test_dual():
cnf = Config().load_file("idp_sp_conf") cnf = Config().load_file("tests.idp_sp_conf")
spe = cnf.getattr("endpoints", "sp") spe = cnf.getattr("endpoints", "sp")
idpe = cnf.getattr("endpoints", "idp") idpe = cnf.getattr("endpoints", "idp")
@@ -333,10 +335,10 @@ def test_ecp():
def test_assertion_consumer_service(): def test_assertion_consumer_service():
c = IdPConfig() c = IdPConfig()
c.load_file("idp_conf") c.load_file("tests.idp_conf")
c.context = "idp" c.context = "idp"
c.metadata.load("local", "InCommon-metadata.xml") c.metadata.load("local", full_path("InCommon-metadata.xml"))
entity_id = "https://www.zimride.com/shibboleth" entity_id = "https://www.zimride.com/shibboleth"
acs = c.metadata.assertion_consumer_service(entity_id) acs = c.metadata.assertion_consumer_service(entity_id)

View File

@@ -14,13 +14,15 @@ from saml2.sigver import xmlsec_version, get_xmlsec_cryptobackend, get_xmlsec_bi
from py.test import raises from py.test import raises
SIGNED = "saml_signed.xml" from pathutils import full_path
UNSIGNED = "saml_unsigned.xml"
FALSE_SIGNED = "saml_false_signed.xml"
SIMPLE_SAML_PHP_RESPONSE = "simplesamlphp_authnresponse.xml"
PUB_KEY = "test.pem" SIGNED = full_path("saml_signed.xml")
PRIV_KEY = "test.key" UNSIGNED = full_path("saml_unsigned.xml")
FALSE_SIGNED = full_path("saml_false_signed.xml")
SIMPLE_SAML_PHP_RESPONSE = full_path("simplesamlphp_authnresponse.xml")
PUB_KEY = full_path("test.pem")
PRIV_KEY = full_path("test.key")
def _eq(l1,l2): def _eq(l1,l2):
@@ -360,7 +362,7 @@ class TestSecurityMetadata():
def setup_class(self): def setup_class(self):
xmlexec = get_xmlsec_binary() xmlexec = get_xmlsec_binary()
md = MetadataStore([saml, samlp], None, xmlexec) md = MetadataStore([saml, samlp], None, xmlexec)
md.load("local", "metadata_cert.xml") md.load("local", full_path("metadata_cert.xml"))
crypto = get_xmlsec_cryptobackend() crypto = get_xmlsec_cryptobackend()
self.sec = sigver.SecurityContext(crypto, key_file=PRIV_KEY, self.sec = sigver.SecurityContext(crypto, key_file=PRIV_KEY,

View File

@@ -7,8 +7,10 @@ from saml2.server import Server
from saml2.response import authn_response from saml2.response import authn_response
from saml2.config import config_factory from saml2.config import config_factory
XML_RESPONSE_FILE = "saml_signed.xml" from pathutils import full_path
XML_RESPONSE_FILE2 = "saml2_response.xml"
XML_RESPONSE_FILE = full_path("saml_signed.xml")
XML_RESPONSE_FILE2 = full_path("saml2_response.xml")
def _eq(l1,l2): def _eq(l1,l2):
return set(l1) == set(l2) return set(l1) == set(l2)
@@ -20,7 +22,7 @@ IDENTITY = {"eduPersonAffiliation": ["staff", "member"],
class TestAuthnResponse: class TestAuthnResponse:
def setup_class(self): def setup_class(self):
server = Server("idp_conf") server = Server("tests.idp_conf")
name_id = server.ident.transient_nameid( name_id = server.ident.transient_nameid(
"urn:mace:example.com:saml:roland:sp","id12") "urn:mace:example.com:saml:roland:sp","id12")
authn = (AUTHN_PASSWORD, "http://www.example.com/login") authn = (AUTHN_PASSWORD, "http://www.example.com/login")
@@ -49,7 +51,7 @@ class TestAuthnResponse:
name_id = name_id, name_id = name_id,
authn=authn) authn=authn)
self.conf = config_factory("sp", "server_conf") self.conf = config_factory("sp", "tests.server_conf")
self.conf.only_use_keys_in_metadata = False self.conf.only_use_keys_in_metadata = False
self.ar = authn_response(self.conf, "http://lingon.catalogix.se:8087/") self.ar = authn_response(self.conf, "http://lingon.catalogix.se:8087/")

View File

@@ -14,6 +14,8 @@ from saml2 import create_class_from_xml_string
from saml2.profile import ecp as ecp_prof from saml2.profile import ecp as ecp_prof
from saml2.client import Saml2Client from saml2.client import Saml2Client
from pathutils import full_path, xmlsec_path
__author__ = 'rolandh' __author__ = 'rolandh'
@@ -23,26 +25,17 @@ def _eq(l1, l2):
else: else:
return len(l1) == len(l2) return len(l1) == len(l2)
try:
from saml2.sigver import get_xmlsec_binary
except ImportError:
get_xmlsec_binary = None
if get_xmlsec_binary:
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
else:
xmlsec_path = '/usr/bin/xmlsec1'
class DummyResponse(object): class DummyResponse(object):
def __init__(self, headers): def __init__(self, headers):
self.headers = headers self.headers = headers
def test_complete_flow(): def test_complete_flow():
client = ecp_client.Client("user", "password", metadata_file="idp_all.xml", client = ecp_client.Client("user", "password",
metadata_file=full_path("idp_all.xml"),
xmlsec_binary=xmlsec_path) xmlsec_binary=xmlsec_path)
sp = Saml2Client(config_file="servera_conf") sp = Saml2Client(config_file="tests.servera_conf")
idp = Server(config_file="idp_all_conf") idp = Server(config_file="tests.idp_all_conf")
IDP_ENTITY_ID = idp.config.entityid IDP_ENTITY_ID = idp.config.entityid
#SP_ENTITY_ID = sp.config.entityid #SP_ENTITY_ID = sp.config.entityid

View File

@@ -7,26 +7,26 @@ def _eq(l1,l2):
return set(l1) == set(l2) return set(l1) == set(l2)
def test_verify(): def test_verify():
ds = DiscoveryServer(config_file="disco_conf") ds = DiscoveryServer(config_file="tests.disco_conf")
assert ds assert ds
assert ds.verify_sp_in_metadata("urn:mace:example.com:saml:roland:sp") assert ds.verify_sp_in_metadata("urn:mace:example.com:saml:roland:sp")
def test_construct_0(): def test_construct_0():
sp = Saml2Client(config_file="servera_conf") sp = Saml2Client(config_file="tests.servera_conf")
url = sp.create_discovery_service_request("http://example.com/saml/disco", url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml") "https://example.com/saml/sp.xml")
assert url == "http://example.com/saml/disco?entityID=https%3A%2F%2Fexample.com%2Fsaml%2Fsp.xml" assert url == "http://example.com/saml/disco?entityID=https%3A%2F%2Fexample.com%2Fsaml%2Fsp.xml"
def test_construct_1(): def test_construct_1():
sp = Saml2Client(config_file="servera_conf") sp = Saml2Client(config_file="tests.servera_conf")
url = sp.create_discovery_service_request("http://example.com/saml/disco", url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml") "https://example.com/saml/sp.xml")
assert url == "http://example.com/saml/disco?entityID=https%3A%2F%2Fexample.com%2Fsaml%2Fsp.xml" assert url == "http://example.com/saml/disco?entityID=https%3A%2F%2Fexample.com%2Fsaml%2Fsp.xml"
def test_construct_deconstruct_request(): def test_construct_deconstruct_request():
sp = Saml2Client(config_file="servera_conf") sp = Saml2Client(config_file="tests.servera_conf")
url = sp.create_discovery_service_request("http://example.com/saml/disco", url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml", "https://example.com/saml/sp.xml",
is_passive=True, is_passive=True,
@@ -35,20 +35,20 @@ def test_construct_deconstruct_request():
print url print url
ds = DiscoveryServer(config_file="disco_conf") ds = DiscoveryServer(config_file="tests.disco_conf")
dsr = ds.parse_discovery_service_request(url) dsr = ds.parse_discovery_service_request(url)
# policy is added by the parsing and verifying method # policy is added by the parsing and verifying method
assert _eq(dsr.keys(),["return_url", "entityID", "returnIDParam", assert _eq(dsr.keys(),["return_url", "entityID", "returnIDParam",
"isPassive", "policy"]) "isPassive", "policy"])
def test_construct_deconstruct_response(): def test_construct_deconstruct_response():
sp = Saml2Client(config_file="servera_conf") sp = Saml2Client(config_file="tests.servera_conf")
url = sp.create_discovery_service_request("http://example.com/saml/disco", url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml", "https://example.com/saml/sp.xml",
is_passive=True, is_passive=True,
returnIDParam="foo", returnIDParam="foo",
return_url="https://example.com/saml/sp/disc") return_url="https://example.com/saml/sp/disc")
ds = DiscoveryServer(config_file="disco_conf") ds = DiscoveryServer(config_file="tests.disco_conf")
dsr = ds.parse_discovery_service_request(url) dsr = ds.parse_discovery_service_request(url)
args = dict([(key, dsr[key]) for key in ["returnIDParam", "return_url"]]) args = dict([(key, dsr[key]) for key in ["returnIDParam", "return_url"]])
url = ds.create_discovery_service_response( url = ds.create_discovery_service_response(
@@ -56,4 +56,4 @@ def test_construct_deconstruct_response():
**args) **args)
idp_id = sp.parse_discovery_service_response(url, returnIDParam="foo") idp_id = sp.parse_discovery_service_response(url, returnIDParam="foo")
assert idp_id == "https://example.com/saml/idp.xml" assert idp_id == "https://example.com/saml/idp.xml"

View File

@@ -10,10 +10,10 @@ from urlparse import parse_qs
__author__ = 'rolandh' __author__ = 'rolandh'
idp = Server(config_file="idp_all_conf") idp = Server(config_file="tests.idp_all_conf")
conf = SPConfig() conf = SPConfig()
conf.load_file("servera_conf") conf.load_file("tests.servera_conf")
sp = Saml2Client(conf) sp = Saml2Client(conf)
def test(): def test():
@@ -41,4 +41,4 @@ def test():
if verify_redirect_signature(_dict, cert): if verify_redirect_signature(_dict, cert):
verified_ok = True verified_ok = True
assert verified_ok assert verified_ok