Fixed tests

This commit is contained in:
Roland Hedberg
2012-11-27 14:14:45 +01:00
parent aabb20132b
commit 8a0370f5cd
3 changed files with 63 additions and 69 deletions

View File

@@ -70,17 +70,17 @@ class TestMgmtData:
class TestSPKISexp:
def setup_class(self):
self.spki_sexp = ds.SPKIDataType_SPKISexp()
self.spki_sexp = ds.SPKISexp()
def testAccessors(self):
"""Test for SPKISexp accessors"""
self.spki_sexp.text = "spki sexp"
new_spki_sexp = ds.spki_data_type__spki_sexp_from_string(self.spki_sexp.to_string())
new_spki_sexp = ds.spki_sexp_from_string(self.spki_sexp.to_string())
assert new_spki_sexp.text.strip() == "spki sexp"
def testUsingTestData(self):
"""Test for spki_sexp_from_string() using test data"""
new_spki_sexp = ds.spki_data_type__spki_sexp_from_string(ds_data.TEST_SPKI_SEXP)
new_spki_sexp = ds.spki_sexp_from_string(ds_data.TEST_SPKI_SEXP)
assert new_spki_sexp.text.strip() == "spki sexp"
@@ -92,7 +92,7 @@ class TestSPKIData:
def testAccessors(self):
"""Test for SPKIData accessors"""
self.spki_data.spki_sexp.append(
ds.spki_data_type__spki_sexp_from_string(ds_data.TEST_SPKI_SEXP))
ds.spki_sexp_from_string(ds_data.TEST_SPKI_SEXP))
new_spki_data = ds.spki_data_from_string(self.spki_data.to_string())
assert new_spki_data.spki_sexp[0].text.strip() == "spki sexp"
@@ -111,19 +111,19 @@ class TestPGPData:
def testAccessors(self):
"""Test for PGPData accessors"""
self.pgp_data.pgp_key_id = ds.PGPDataType_PGPKeyID(text="pgp key id")
self.pgp_data.pgp_key_packet = ds.PGPDataType_PGPKeyPacket(text="pgp key packet")
self.pgp_data.pgp_key_id = ds.PGPKeyID(text="pgp key id")
self.pgp_data.pgp_key_packet = ds.PGPKeyPacket(text="pgp key packet")
new_pgp_data = ds.pgp_data_from_string(self.pgp_data.to_string())
assert isinstance(new_pgp_data.pgp_key_id, ds.PGPDataType_PGPKeyID)
assert isinstance(new_pgp_data.pgp_key_packet, ds.PGPDataType_PGPKeyPacket)
assert isinstance(new_pgp_data.pgp_key_id, ds.PGPKeyID)
assert isinstance(new_pgp_data.pgp_key_packet, ds.PGPKeyPacket)
assert new_pgp_data.pgp_key_id.text.strip() == "pgp key id"
assert new_pgp_data.pgp_key_packet.text.strip() == "pgp key packet"
def testUsingTestData(self):
"""Test for pgp_data_from_string() using test data"""
new_pgp_data = ds.pgp_data_from_string(ds_data.TEST_PGP_DATA)
assert isinstance(new_pgp_data.pgp_key_id, ds.PGPDataType_PGPKeyID)
assert isinstance(new_pgp_data.pgp_key_packet, ds.PGPDataType_PGPKeyPacket)
assert isinstance(new_pgp_data.pgp_key_id, ds.PGPKeyID)
assert isinstance(new_pgp_data.pgp_key_packet, ds.PGPKeyPacket)
assert new_pgp_data.pgp_key_id.text.strip() == "pgp key id"
assert new_pgp_data.pgp_key_packet.text.strip() == "pgp key packet"
@@ -135,9 +135,9 @@ class TestX509IssuerSerial:
def testAccessors(self):
"""Test for X509SerialNumber accessors"""
self.x509_issuer_serial.x509_issuer_name = ds.X509IssuerSerialType_X509IssuerName(
self.x509_issuer_serial.x509_issuer_name = ds.X509IssuerName(
text="issuer name")
self.x509_issuer_serial.x509_serial_number = ds.X509IssuerSerialType_X509SerialNumber(text="1")
self.x509_issuer_serial.x509_serial_number = ds.X509SerialNumber(text="1")
new_x509_issuer_serial = ds.x509_issuer_serial_type__from_string(
self.x509_issuer_serial.to_string())
assert new_x509_issuer_serial.x509_issuer_name.text.strip() == \
@@ -146,7 +146,7 @@ class TestX509IssuerSerial:
def testUsingTestData(self):
"""Test for x509_issuer_serial_from_string() using test data"""
new_x509_issuer_serial = ds.x509_data_type__x509_issuer_serial_from_string(
new_x509_issuer_serial = ds.x509_issuer_serial_from_string(
ds_data.TEST_X509_ISSUER_SERIAL)
assert new_x509_issuer_serial.x509_issuer_name.text.strip() == \
"issuer name"
@@ -160,52 +160,46 @@ class TestX509Data:
def testAccessors(self):
"""Test for X509Data accessors"""
st = ds.x509_data_type__x509_issuer_serial_from_string(ds_data.TEST_X509_ISSUER_SERIAL)
st = ds.x509_issuer_serial_from_string(ds_data.TEST_X509_ISSUER_SERIAL)
print st
self.x509_data.x509_issuer_serial= st
self.x509_data.x509_ski = ds.X509DataType_X509SKI(text="x509 ski")
self.x509_data.x509_subject_name = ds.X509DataType_X509SubjectName(
self.x509_data.x509_ski = ds.X509SKI(text="x509 ski")
self.x509_data.x509_subject_name = ds.X509SubjectName(
text="x509 subject name")
self.x509_data.x509_certificate = ds.X509DataType_X509Certificate(
self.x509_data.x509_certificate = ds.X509Certificate(
text="x509 certificate")
self.x509_data.x509_crl = ds.X509DataType_X509CRL(text="x509 crl")
self.x509_data.x509_crl = ds.X509CRL(text="x509 crl")
new_x509_data = ds.x509_data_from_string(self.x509_data.to_string())
print new_x509_data.keyswv()
print new_x509_data.__dict__.keys()
assert new_x509_data.x509_issuer_serial
assert isinstance(new_x509_data.x509_issuer_serial,
ds.X509DataType_X509IssuerSerial)
assert isinstance(new_x509_data.x509_issuer_serial, ds.X509IssuerSerial)
assert new_x509_data.x509_ski.text.strip() == "x509 ski"
assert isinstance(new_x509_data.x509_ski, ds.X509DataType_X509SKI)
assert isinstance(new_x509_data.x509_ski, ds.X509SKI)
assert new_x509_data.x509_subject_name.text.strip() == \
"x509 subject name"
assert isinstance(new_x509_data.x509_subject_name,
ds.X509DataType_X509SubjectName)
assert isinstance(new_x509_data.x509_subject_name, ds.X509SubjectName)
assert new_x509_data.x509_certificate.text.strip() == \
"x509 certificate"
assert isinstance(new_x509_data.x509_certificate,
ds.X509DataType_X509Certificate)
assert isinstance(new_x509_data.x509_certificate, ds.X509Certificate)
assert new_x509_data.x509_crl.text.strip() == "x509 crl"
assert isinstance(new_x509_data.x509_crl,ds.X509DataType_X509CRL)
assert isinstance(new_x509_data.x509_crl,ds.X509CRL)
def testUsingTestData(self):
"""Test for x509_data_from_string() using test data"""
new_x509_data = ds.x509_data_from_string(ds_data.TEST_X509_DATA)
assert isinstance(new_x509_data.x509_issuer_serial,
ds.X509DataType_X509IssuerSerial)
assert isinstance(new_x509_data.x509_issuer_serial, ds.X509IssuerSerial)
assert new_x509_data.x509_ski.text.strip() == "x509 ski"
assert isinstance(new_x509_data.x509_ski, ds.X509DataType_X509SKI)
assert isinstance(new_x509_data.x509_ski, ds.X509SKI)
assert new_x509_data.x509_subject_name.text.strip() == \
"x509 subject name"
assert isinstance(new_x509_data.x509_subject_name,
ds.X509DataType_X509SubjectName)
assert isinstance(new_x509_data.x509_subject_name, ds.X509SubjectName)
assert new_x509_data.x509_certificate.text.strip() == \
"x509 certificate"
assert isinstance(new_x509_data.x509_certificate,
ds.X509DataType_X509Certificate)
assert isinstance(new_x509_data.x509_certificate, ds.X509Certificate)
assert new_x509_data.x509_crl.text.strip() == "x509 crl"
assert isinstance(new_x509_data.x509_crl,ds.X509DataType_X509CRL)
assert isinstance(new_x509_data.x509_crl,ds.X509CRL)
class TestTransform:
@@ -297,11 +291,11 @@ class TestRSAKeyValue:
def testAccessors(self):
"""Test for RSAKeyValue accessors"""
self.rsa_key_value.modulus = ds.RSAKeyValueType_Modulus(text="modulus")
self.rsa_key_value.exponent = ds.RSAKeyValueType_Exponent(text="exponent")
self.rsa_key_value.modulus = ds.Modulus(text="modulus")
self.rsa_key_value.exponent = ds.Exponent(text="exponent")
new_rsa_key_value = ds.rsa_key_value_from_string(self.rsa_key_value.to_string())
assert isinstance(new_rsa_key_value.modulus, ds.RSAKeyValueType_Modulus)
assert isinstance(new_rsa_key_value.exponent, ds.RSAKeyValueType_Exponent)
assert isinstance(new_rsa_key_value.modulus, ds.Modulus)
assert isinstance(new_rsa_key_value.exponent, ds.Exponent)
assert new_rsa_key_value.modulus.text.strip() == "modulus"
assert new_rsa_key_value.exponent.text.strip() == "exponent"
@@ -309,8 +303,8 @@ class TestRSAKeyValue:
"""Test for rsa_key_value_from_string() using test data"""
new_rsa_key_value = ds.rsa_key_value_from_string(
ds_data.TEST_RSA_KEY_VALUE)
assert isinstance(new_rsa_key_value.modulus, ds.RSAKeyValueType_Modulus)
assert isinstance(new_rsa_key_value.exponent, ds.RSAKeyValueType_Exponent)
assert isinstance(new_rsa_key_value.modulus, ds.Modulus)
assert isinstance(new_rsa_key_value.exponent, ds.Exponent)
assert new_rsa_key_value.modulus.text.strip() == "modulus"
assert new_rsa_key_value.exponent.text.strip() == "exponent"
@@ -322,21 +316,21 @@ class TestDSAKeyValue:
def testAccessors(self):
"""Test for DSAKeyValue accessors"""
self.dsa_key_value.p = ds.DSAKeyValueType_P(text="p")
self.dsa_key_value.q = ds.DSAKeyValueType_Q(text="q")
self.dsa_key_value.g = ds.DSAKeyValueType_G(text="g")
self.dsa_key_value.y = ds.DSAKeyValueType_Y(text="y")
self.dsa_key_value.j = ds.DSAKeyValueType_J(text="j")
self.dsa_key_value.seed = ds.DSAKeyValueType_Seed(text="seed")
self.dsa_key_value.pgen_counter = ds.DSAKeyValueType_PgenCounter(text="pgen counter")
self.dsa_key_value.p = ds.P(text="p")
self.dsa_key_value.q = ds.Q(text="q")
self.dsa_key_value.g = ds.G(text="g")
self.dsa_key_value.y = ds.Y(text="y")
self.dsa_key_value.j = ds.J(text="j")
self.dsa_key_value.seed = ds.Seed(text="seed")
self.dsa_key_value.pgen_counter = ds.PgenCounter(text="pgen counter")
new_dsa_key_value = ds.dsa_key_value_from_string(self.dsa_key_value.to_string())
assert isinstance(new_dsa_key_value.p, ds.DSAKeyValueType_P)
assert isinstance(new_dsa_key_value.q, ds.DSAKeyValueType_Q)
assert isinstance(new_dsa_key_value.g, ds.DSAKeyValueType_G)
assert isinstance(new_dsa_key_value.y, ds.DSAKeyValueType_Y)
assert isinstance(new_dsa_key_value.j, ds.DSAKeyValueType_J)
assert isinstance(new_dsa_key_value.seed, ds.DSAKeyValueType_Seed)
assert isinstance(new_dsa_key_value.pgen_counter, ds.DSAKeyValueType_PgenCounter)
assert isinstance(new_dsa_key_value.p, ds.P)
assert isinstance(new_dsa_key_value.q, ds.Q)
assert isinstance(new_dsa_key_value.g, ds.G)
assert isinstance(new_dsa_key_value.y, ds.Y)
assert isinstance(new_dsa_key_value.j, ds.J)
assert isinstance(new_dsa_key_value.seed, ds.Seed)
assert isinstance(new_dsa_key_value.pgen_counter, ds.PgenCounter)
assert new_dsa_key_value.p.text.strip() == "p"
assert new_dsa_key_value.q.text.strip() == "q"
assert new_dsa_key_value.g.text.strip() == "g"
@@ -349,13 +343,13 @@ class TestDSAKeyValue:
"""Test for dsa_key_value_from_string() using test data"""
new_dsa_key_value = ds.dsa_key_value_from_string(
ds_data.TEST_DSA_KEY_VALUE)
assert isinstance(new_dsa_key_value.p, ds.DSAKeyValueType_P)
assert isinstance(new_dsa_key_value.q, ds.DSAKeyValueType_Q)
assert isinstance(new_dsa_key_value.g, ds.DSAKeyValueType_G)
assert isinstance(new_dsa_key_value.y, ds.DSAKeyValueType_Y)
assert isinstance(new_dsa_key_value.j, ds.DSAKeyValueType_J)
assert isinstance(new_dsa_key_value.seed, ds.DSAKeyValueType_Seed)
assert isinstance(new_dsa_key_value.pgen_counter, ds.DSAKeyValueType_PgenCounter)
assert isinstance(new_dsa_key_value.p, ds.P)
assert isinstance(new_dsa_key_value.q, ds.Q)
assert isinstance(new_dsa_key_value.g, ds.G)
assert isinstance(new_dsa_key_value.y, ds.Y)
assert isinstance(new_dsa_key_value.j, ds.J)
assert isinstance(new_dsa_key_value.seed, ds.Seed)
assert isinstance(new_dsa_key_value.pgen_counter, ds.PgenCounter)
assert new_dsa_key_value.p.text.strip() == "p"
assert new_dsa_key_value.q.text.strip() == "q"
assert new_dsa_key_value.g.text.strip() == "g"
@@ -536,20 +530,20 @@ class TestSignatureMethod:
def testAccessors(self):
"""Test for SignatureMethod accessors"""
self.signature_method.algorithm = ds.SIG_RSA_SHA1
self.signature_method.hmac_output_length = ds.SignatureMethodType_HMACOutputLength(text="8")
self.signature_method.hmac_output_length = ds.HMACOutputLength(text="8")
new_signature_method = ds.signature_method_from_string(
self.signature_method.to_string())
assert isinstance(new_signature_method.hmac_output_length,
ds.SignatureMethodType_HMACOutputLength)
ds.HMACOutputLength)
assert new_signature_method.hmac_output_length.text.strip() == "8"
assert new_signature_method.algorithm == ds.SIG_RSA_SHA1
def testUsingTestData(self):
"""Test for signature_method_from_string() using test data"""
new_signature_method = ds.signature_method_from_string(
ds_data.TEST_SIGNATURE_METHOD)
ds_data.TEST_SIGNATURE_METHOD)
assert isinstance(new_signature_method.hmac_output_length,
ds.SignatureMethodType_HMACOutputLength)
ds.HMACOutputLength)
assert new_signature_method.hmac_output_length.text.strip() == "8"
assert new_signature_method.algorithm == ds.SIG_RSA_SHA1

View File

@@ -270,7 +270,7 @@ class TestClient:
resp_str = base64.encodestring(resp_str)
authn_response = self.client.response({"SAMLResponse":resp_str},
authn_response = self.client.authn_request_response({"SAMLResponse":resp_str},
{"id1":"http://foo.example.com/service"})
assert authn_response is not None
@@ -309,7 +309,7 @@ class TestClient:
resp_str = base64.encodestring(resp_str)
self.client.response({"SAMLResponse":resp_str},
self.client.authn_request_response({"SAMLResponse":resp_str},
{"id2":"http://foo.example.com/service"})
# Two persons in the cache
@@ -579,7 +579,8 @@ class TestClient:
resp_str = base64.encodestring(resp_str)
self.client.allow_unsolicited = True
authn_response = self.client.response({"SAMLResponse":resp_str}, ())
authn_response = self.client.authn_request_response(
{"SAMLResponse":resp_str}, ())
assert authn_response is not None
assert authn_response.issuer() == IDP

View File

@@ -6,7 +6,6 @@ from saml2.saml import NAMEID_FORMAT_TRANSIENT
from saml2.samlp import NameIDPolicy
from s2repoze.plugins.sp import make_plugin
from saml2.server import Server
from saml2 import make_instance, samlp, saml
ENV1 = {'SERVER_SOFTWARE': 'CherryPy/3.1.2 WSGI Server',
'SCRIPT_NAME': '',