Allow running the tests inside the tests directory

This fix a regression after latest changes. In order
to run the tests from the tests directory you will
need to install the test_requires packages manually.
You can do so with a single command:

python setup.py develop easy_install pysaml2[testing]

That's why I restored the old extras_requires argument
to the setup function. Now it won't duplicate package
names but reuse the same ones as in test_requires.
This commit is contained in:
Lorenzo Gil Sanchez
2013-04-02 17:53:23 +02:00
parent d179bb012e
commit 49d563618a
7 changed files with 45 additions and 28 deletions

View File

@@ -46,6 +46,16 @@ install_requires=[
'm2crypto'
]
tests_require=[
'mongodict',
'pyasn1',
'pymongo',
'python-memcached',
'pytest',
#'pytest-coverage',
]
# only for Python 2.6
if sys.version_info < (2,7):
install_requires.append('importlib')
@@ -73,14 +83,10 @@ setup(
scripts=["tools/parse_xsd2.py", "tools/make_metadata.py"],
tests_require=[
'mongodict',
'pyasn1',
'pymongo',
'python-memcached',
'pytest',
#'pytest-coverage',
],
tests_require=tests_require,
extras_require={
'testing': tests_require,
},
install_requires=install_requires,
zip_safe=False,
test_suite='tests',

View File

@@ -7,6 +7,13 @@ def full_path(local_file):
return os.path.join(BASEDIR, local_file)
def dotname(module):
if not BASEDIR.endswith('tests'):
return 'tests.' + module
else:
return module
try:
from saml2.sigver import get_xmlsec_binary
except ImportError:

View File

@@ -11,7 +11,7 @@ from py.test import raises
from saml2 import root_logger
from pathutils import full_path
from pathutils import dotname, full_path
sp1 = {
"entityid" : "urn:mace:umu.se:saml:roland:sp",
@@ -297,7 +297,7 @@ def test_conf_syslog():
#noinspection PyUnresolvedReferences
def test_3():
cnf = Config()
cnf.load_file("tests.sp_1_conf")
cnf.load_file(dotname("sp_1_conf"))
assert cnf.entityid == "urn:mace:example.com:saml:roland:sp"
assert cnf.debug == 1
assert cnf.key_file == full_path("test.key")
@@ -310,12 +310,12 @@ def test_3():
def test_sp():
cnf = SPConfig()
cnf.load_file("tests.sp_1_conf")
cnf.load_file(dotname("sp_1_conf"))
assert cnf.endpoint("assertion_consumer_service") == \
["http://lingon.catalogix.se:8087/"]
def test_dual():
cnf = Config().load_file("tests.idp_sp_conf")
cnf = Config().load_file(dotname("idp_sp_conf"))
spe = cnf.getattr("endpoints", "sp")
idpe = cnf.getattr("endpoints", "idp")
@@ -335,7 +335,7 @@ def test_ecp():
def test_assertion_consumer_service():
c = IdPConfig()
c.load_file("tests.idp_conf")
c.load_file(dotname("idp_conf"))
c.context = "idp"
c.metadata.load("local", full_path("InCommon-metadata.xml"))

View File

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

View File

@@ -14,7 +14,7 @@ from saml2 import create_class_from_xml_string
from saml2.profile import ecp as ecp_prof
from saml2.client import Saml2Client
from pathutils import full_path, xmlsec_path
from pathutils import dotname, full_path, xmlsec_path
__author__ = 'rolandh'
@@ -34,8 +34,8 @@ def test_complete_flow():
metadata_file=full_path("idp_all.xml"),
xmlsec_binary=xmlsec_path)
sp = Saml2Client(config_file="tests.servera_conf")
idp = Server(config_file="tests.idp_all_conf")
sp = Saml2Client(config_file=dotname("servera_conf"))
idp = Server(config_file=dotname("idp_all_conf"))
IDP_ENTITY_ID = idp.config.entityid
#SP_ENTITY_ID = sp.config.entityid

View File

@@ -1,32 +1,34 @@
from saml2.client import Saml2Client
from saml2.discovery import DiscoveryServer
from pathutils import dotname
__author__ = 'rolandh'
def _eq(l1,l2):
return set(l1) == set(l2)
def test_verify():
ds = DiscoveryServer(config_file="tests.disco_conf")
ds = DiscoveryServer(config_file=dotname("disco_conf"))
assert ds
assert ds.verify_sp_in_metadata("urn:mace:example.com:saml:roland:sp")
def test_construct_0():
sp = Saml2Client(config_file="tests.servera_conf")
sp = Saml2Client(config_file=dotname("servera_conf"))
url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml")
assert url == "http://example.com/saml/disco?entityID=https%3A%2F%2Fexample.com%2Fsaml%2Fsp.xml"
def test_construct_1():
sp = Saml2Client(config_file="tests.servera_conf")
sp = Saml2Client(config_file=dotname("servera_conf"))
url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml")
assert url == "http://example.com/saml/disco?entityID=https%3A%2F%2Fexample.com%2Fsaml%2Fsp.xml"
def test_construct_deconstruct_request():
sp = Saml2Client(config_file="tests.servera_conf")
sp = Saml2Client(config_file=dotname("servera_conf"))
url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml",
is_passive=True,
@@ -35,20 +37,20 @@ def test_construct_deconstruct_request():
print url
ds = DiscoveryServer(config_file="tests.disco_conf")
ds = DiscoveryServer(config_file=dotname("disco_conf"))
dsr = ds.parse_discovery_service_request(url)
# policy is added by the parsing and verifying method
assert _eq(dsr.keys(),["return_url", "entityID", "returnIDParam",
"isPassive", "policy"])
def test_construct_deconstruct_response():
sp = Saml2Client(config_file="tests.servera_conf")
sp = Saml2Client(config_file=dotname("servera_conf"))
url = sp.create_discovery_service_request("http://example.com/saml/disco",
"https://example.com/saml/sp.xml",
is_passive=True,
returnIDParam="foo",
return_url="https://example.com/saml/sp/disc")
ds = DiscoveryServer(config_file="tests.disco_conf")
ds = DiscoveryServer(config_file=dotname("disco_conf"))
dsr = ds.parse_discovery_service_request(url)
args = dict([(key, dsr[key]) for key in ["returnIDParam", "return_url"]])
url = ds.create_discovery_service_response(

View File

@@ -8,12 +8,14 @@ from saml2.config import SPConfig
from saml2.sigver import rsa_load
from urlparse import parse_qs
from pathutils import dotname
__author__ = 'rolandh'
idp = Server(config_file="tests.idp_all_conf")
idp = Server(config_file=dotname("idp_all_conf"))
conf = SPConfig()
conf.load_file("tests.servera_conf")
conf.load_file(dotname("servera_conf"))
sp = Saml2Client(conf)
def test():