remove obsolete swig binding csharp, php5, python.
java stays as long as alain coetmeur needs it php(4) will be superseded by the new bindings/php4 later.
This commit is contained in:
parent
1d35f289a8
commit
cab19f5814
|
@ -1,132 +0,0 @@
|
|||
.libs
|
||||
.deps
|
||||
lasso.dll
|
||||
lasso-sharp.pc
|
||||
liblassosharpglue.la
|
||||
liblassosharpglue_la-Lasso.lo
|
||||
liblassosharpglue_la-liblassosharpglue_wrap.lo
|
||||
liblassosharpglue_wrap.c
|
||||
Makefile
|
||||
Makefile.in
|
||||
Credentials.cs
|
||||
Defederation.cs
|
||||
Description.cs
|
||||
DiscoModify.cs
|
||||
DiscoModifyResponse.cs
|
||||
DiscoQuery.cs
|
||||
DiscoQueryResponse.cs
|
||||
Discovery.cs
|
||||
DstModification.cs
|
||||
DstModify.cs
|
||||
DstModifyResponse.cs
|
||||
DstQuery.cs
|
||||
DstQueryResponse.cs
|
||||
Federation.cs
|
||||
Identity.cs
|
||||
InsertEntry.cs
|
||||
LassoHttpMethod.cs
|
||||
LassoLoginProtocolProfile.cs
|
||||
LassoMessageType.cs
|
||||
LassoProviderRole.cs
|
||||
LassoRequestType.cs
|
||||
LassoSignatureMethod.cs
|
||||
Lecp.cs
|
||||
LibAssertion.cs
|
||||
LibAuthnRequest.cs
|
||||
LibAuthnResponse.cs
|
||||
LibFederationTerminationNotification.cs
|
||||
LibLogoutRequest.cs
|
||||
LibLogoutResponse.cs
|
||||
LibRegisterNameIdentifierRequest.cs
|
||||
LibRegisterNameIdentifierResponse.cs
|
||||
LibStatusResponse.cs
|
||||
Login.cs
|
||||
Logout.cs
|
||||
NameIdentifierMapping.cs
|
||||
NameRegistration.cs
|
||||
Node.cs
|
||||
NodeArray.cs
|
||||
Options.cs
|
||||
PPMsgContact.cs
|
||||
PersonalProfileService.cs
|
||||
Provider.cs
|
||||
QueryItem.cs
|
||||
RemoveEntry.cs
|
||||
ResourceID.cs
|
||||
ResourceOffering.cs
|
||||
SWIGTYPE_p_LassoDiscoEncryptedResourceID.cs
|
||||
SWIGTYPE_p_LassoDiscoRequestedServiceType.cs
|
||||
SWIGTYPE_p_LassoDstNewData.cs
|
||||
SWIGTYPE_p_LassoMdProtocolType.cs
|
||||
SWIGTYPE_p_LassoSignatureType.cs
|
||||
SWIGTYPE_p_void.cs
|
||||
SamlAdvice.cs
|
||||
SamlAssertion.cs
|
||||
SamlAttributeStatement.cs
|
||||
SamlAuthenticationStatement.cs
|
||||
SamlConditions.cs
|
||||
SamlNameIdentifier.cs
|
||||
SamlSubject.cs
|
||||
SamlSubjectConfirmation.cs
|
||||
SamlSubjectLocality.cs
|
||||
SamlSubjectStatement.cs
|
||||
SamlpRequest.cs
|
||||
SamlpResponse.cs
|
||||
SamlpStatus.cs
|
||||
SamlpStatusCode.cs
|
||||
Server.cs
|
||||
ServiceInstance.cs
|
||||
Session.cs
|
||||
Status.cs
|
||||
StringArray.cs
|
||||
lassoPINVOKE.cs
|
||||
lasso.cs
|
||||
StringList.cs
|
||||
SamlpResponseAbstract.cs
|
||||
SamlpRequestAbstract.cs
|
||||
SamlSubjectStatementAbstract.cs
|
||||
SamlStatementAbstract.cs
|
||||
SamlConditionAbstract.cs
|
||||
SamlAuthorityBinding.cs
|
||||
SamlAudienceRestrictionCondition.cs
|
||||
SamlAttributeDesignator.cs
|
||||
SamlAttribute.cs
|
||||
SamlAttributeValue.cs
|
||||
NodeList.cs
|
||||
LibRequestAuthnContext.cs
|
||||
DiscoCredentials.cs
|
||||
DiscoDescription.cs
|
||||
DiscoEncryptedResourceID.cs
|
||||
DiscoInsertEntry.cs
|
||||
DiscoOptions.cs
|
||||
DiscoRemoveEntry.cs
|
||||
DiscoRequestedServiceType.cs
|
||||
DiscoResourceID.cs
|
||||
DiscoResourceOffering.cs
|
||||
DiscoServiceInstance.cs
|
||||
DowncastableNode.cs
|
||||
DstData.cs
|
||||
DstNewData.cs
|
||||
DstQueryItem.cs
|
||||
InteractionProfileService.cs
|
||||
IsHelp.cs
|
||||
IsInquiry.cs
|
||||
IsInquiryElement.cs
|
||||
IsInteractionRequest.cs
|
||||
IsInteractionResponse.cs
|
||||
IsInteractionStatement.cs
|
||||
IsItem.cs
|
||||
IsParameter.cs
|
||||
IsRedirectRequest.cs
|
||||
IsSelect.cs
|
||||
IsText.cs
|
||||
IsUserInteraction.cs
|
||||
ProfileService.cs
|
||||
UtilityStatus.cs
|
||||
HttpMethod.cs
|
||||
LoginProtocolProfile.cs
|
||||
MessageType.cs
|
||||
ProviderRole.cs
|
||||
RequestType.cs
|
||||
SignatureMethod.cs
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly:AssemblyDelaySign(false)]
|
||||
[assembly:AssemblyKeyFile("lasso-sharp-build.snk")]
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
INCLUDES = -I$(top_builddir) -I$(top_srcdir)
|
||||
|
||||
lib_LTLIBRARIES = liblassosharpglue.la
|
||||
|
||||
liblassosharpglue_la_SOURCES = \
|
||||
liblassosharpglue_wrap.c
|
||||
|
||||
liblassosharpglue_la_CFLAGS = \
|
||||
$(LASSO_CORE_CFLAGS) \
|
||||
-DSWIG_COBJECT_TYPES
|
||||
|
||||
liblassosharpglue_la_LIBADD = \
|
||||
$(top_builddir)/lasso/liblasso.la \
|
||||
$(LASSO_LIBS)
|
||||
|
||||
liblassosharpglue_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
|
||||
liblassosharpglue_wrap.c: $(top_srcdir)/swig/Lasso.i $(top_srcdir)/swig/Lasso-wsf.i \
|
||||
$(top_srcdir)/swig/inheritance.h
|
||||
$(SWIG) -I$(top_builddir)/swig -v -csharp -namespace lasso -module lasso \
|
||||
-o liblassosharpglue_wrap.c $(top_srcdir)/swig/Lasso.i
|
||||
cp liblassosharpglue_wrap.c liblassosharpglue_wrap.c.bak
|
||||
sed -e 's/(char \*) "\(.*\)"/strdup("\1")/' \
|
||||
< liblassosharpglue_wrap.c.bak > liblassosharpglue_wrap.c
|
||||
|
||||
dotnetlibdir = $(datadir)/dotnet/lasso/
|
||||
dotnetlib_DATA = lasso.dll lasso.dll.config
|
||||
|
||||
lasso.dll: liblassosharpglue.la
|
||||
-$(LN_S) $(srcdir)/lasso-sharp.snk lasso-sharp-build.snk
|
||||
$(CSHARPCOMPILER) -out:lasso.dll -target:library $(srcdir)/*.cs
|
||||
rm -f lasso-sharp-build.snk
|
||||
|
||||
pkgconfig_DATA = lasso-sharp.pc
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
install-data-local:
|
||||
-$(GACUTIL) -i lasso.dll -f -package lasso -gacdir $(libdir)
|
||||
|
||||
clean-local:
|
||||
-rm lasso.dll lasso-sharp.pc liblassosharpglue_wrap.c.bak
|
||||
|
||||
SWIG_FILES = liblassosharpglue_wrap.c \
|
||||
Defederation.cs CheckVersionMode.cs \
|
||||
DowncastableNode.cs \
|
||||
Federation.cs Identity.cs \
|
||||
lasso.cs lassoPINVOKE.cs Lecp.cs LibAssertion.cs \
|
||||
LibAuthnRequest.cs \
|
||||
LibAuthnResponse.cs LibFederationTerminationNotification.cs \
|
||||
LibLogoutRequest.cs LibLogoutResponse.cs LibRegisterNameIdentifierRequest.cs \
|
||||
LibRegisterNameIdentifierResponse.cs LibRequestAuthnContext.cs \
|
||||
LibStatusResponse.cs Login.cs Logout.cs NameIdentifierMapping.cs \
|
||||
NameRegistration.cs Node.cs NodeList.cs Provider.cs \
|
||||
SamlAdvice.cs SamlAssertion.cs SamlAttribute.cs SamlAttributeDesignator.cs \
|
||||
SamlAttributeStatement.cs SamlAttributeValue.cs SamlAudienceRestrictionCondition.cs \
|
||||
SamlAuthenticationStatement.cs SamlAuthorityBinding.cs SamlConditionAbstract.cs \
|
||||
SamlConditions.cs SamlNameIdentifier.cs SamlpRequestAbstract.cs SamlpRequest.cs \
|
||||
SamlpResponseAbstract.cs SamlpResponse.cs SamlpStatusCode.cs SamlpStatus.cs \
|
||||
SamlStatementAbstract.cs SamlSubjectConfirmation.cs SamlSubject.cs \
|
||||
SamlSubjectLocality.cs SamlSubjectStatementAbstract.cs SamlSubjectStatement.cs \
|
||||
Server.cs Session.cs StringList.cs SWIGTYPE_p_LassoMdProtocolType.cs \
|
||||
SWIGTYPE_p_LassoSignatureType.cs SWIGTYPE_p_void.cs \
|
||||
HttpMethod.cs ProviderRole.cs SignatureMethod.cs LoginProtocolProfile.cs \
|
||||
RequestType.cs
|
||||
|
||||
if WSF_ENABLED
|
||||
SWIG_WSF_FILES = Authentication.cs \
|
||||
DiscoAuthenticateRequester.cs \
|
||||
DiscoAuthenticateSessionContext.cs \
|
||||
DiscoAuthorizeRequester.cs \
|
||||
DiscoCredentials.cs \
|
||||
DiscoDescription.cs \
|
||||
DiscoEncryptedResourceID.cs \
|
||||
DiscoEncryptResourceID.cs \
|
||||
DiscoGenerateBearerToken.cs \
|
||||
DiscoInsertEntry.cs \
|
||||
DiscoModify.cs \
|
||||
DiscoModifyResponse.cs \
|
||||
DiscoOptions.cs \
|
||||
DiscoQuery.cs \
|
||||
DiscoQueryResponse.cs \
|
||||
DiscoRemoveEntry.cs \
|
||||
DiscoRequestedServiceType.cs \
|
||||
DiscoResourceID.cs \
|
||||
DiscoResourceOffering.cs \
|
||||
DiscoSendSingleLogout.cs \
|
||||
DiscoServiceInstance.cs \
|
||||
Discovery.cs \
|
||||
DstData.cs \
|
||||
DstModification.cs \
|
||||
DstModify.cs \
|
||||
DstModifyResponse.cs \
|
||||
DstNewData.cs \
|
||||
DstQueryItem.cs \
|
||||
DstQuery.cs \
|
||||
DstQueryResponse.cs \
|
||||
InteractionProfileService.cs \
|
||||
IsHelp.cs \
|
||||
IsInquiryElement.cs \
|
||||
IsInquiry.cs \
|
||||
IsInteractionRequest.cs \
|
||||
IsInteractionResponse.cs \
|
||||
IsInteractionStatement.cs \
|
||||
IsItem.cs \
|
||||
IsParameter.cs \
|
||||
IsRedirectRequest.cs \
|
||||
IsSelect.cs \
|
||||
IsText.cs \
|
||||
IsUserInteraction.cs \
|
||||
lassoConstants.cs \
|
||||
ProfileService.cs \
|
||||
SaCredentials.cs \
|
||||
SaSASLRequest.cs \
|
||||
SaSASLResponse.cs \
|
||||
SoapBindingCorrelation.cs \
|
||||
SoapBody.cs \
|
||||
SoapEnvelope.cs \
|
||||
SoapHeader.cs \
|
||||
SWIGTYPE_p_LassoSoapBindingProvider.cs \
|
||||
UserAccount.cs \
|
||||
UtilityStatus.cs \
|
||||
WsfProfile.cs \
|
||||
WsseSecurity.cs
|
||||
endif
|
||||
|
||||
EXTRA_DIST = lasso-sharp.pc.in lasso.dll.config AssemblyInfo.cs lasso-sharp.snk \
|
||||
$(SWIG_FILES) $(SWIG_WSF_FILES)
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in $(SWIG_FILES) $(SWIG_WSF_FILES)
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* install lasso then compile with
|
||||
* mcs -g -nologo -pkg:lasso-sharp -out:perfs.exe perfs.cs
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class perfs
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
lasso.lasso.init();
|
||||
|
||||
lasso.Server server = new lasso.Server(
|
||||
"../../tests/data/sp1-la/metadata.xml",
|
||||
"../../tests/data/sp1-la/private-key-raw.pem",
|
||||
null,
|
||||
"../../tests/data/sp1-la/certificate.pem");
|
||||
|
||||
server.addProvider(lasso.LassoProviderRole.PROVIDER_ROLE_SP,
|
||||
"../../tests/data/idp1-la/metadata.xml",
|
||||
"../../tests/data/idp1-la/public-key.pem",
|
||||
"../../tests/data/ca1-la/certificate.pem");
|
||||
|
||||
lasso.Login login = new lasso.Login(server);
|
||||
|
||||
login.initAuthnRequest("https://idp1/metadata", (lasso.LassoHttpMethod)4);
|
||||
lasso.LibAuthnRequest request = (lasso.LibAuthnRequest)login.request;
|
||||
login.request.protocolProfile = lasso.lasso.LIB_PROTOCOL_PROFILE_BRWS_POST;
|
||||
login.buildAuthnRequestMsg();
|
||||
|
||||
Console.WriteLine(login.msgUrl);
|
||||
|
||||
lasso.lasso.shutdown();
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* install lasso then compile with
|
||||
* mcs -g -nologo -pkg:lasso-sharp -out:runme.exe runme.cs
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
lasso.lasso.init();
|
||||
|
||||
lasso.Server server = new lasso.Server(
|
||||
"../../tests/data/sp1-la/metadata.xml",
|
||||
"../../tests/data/sp1-la/private-key-raw.pem",
|
||||
null,
|
||||
"../../tests/data/sp1-la/certificate.pem");
|
||||
server.addProvider(lasso.LassoProviderRole.PROVIDER_ROLE_SP,
|
||||
"../../tests/data/idp1-la/metadata.xml",
|
||||
"../../tests/data/idp1-la/public-key.pem",
|
||||
"../../tests/data/ca1-la/certificate.pem");
|
||||
Console.WriteLine(server.dump());
|
||||
|
||||
lasso.lasso.shutdown();
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
prefix=@prefix@
|
||||
datadir=@datadir@
|
||||
|
||||
Name: Lasso#
|
||||
Version: @VERSION@
|
||||
Description: Lasso# - Lasso .NET Binding
|
||||
Libs: -r:${datadir}/dotnet/lasso/lasso.dll
|
||||
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
<configuration>
|
||||
<dllmap dll="lasso" target="liblassosharpglue.so"/>
|
||||
</configuration>
|
|
@ -1,306 +0,0 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* C# unit tests for Lasso library
|
||||
*
|
||||
* Copyright (C) 2004-2007 Entr'ouvert
|
||||
* http://lasso.entrouvert.org
|
||||
*
|
||||
* Authors: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* To run it, install Lasso then compile with:
|
||||
* export PKG_CONFIG_PATH=../
|
||||
* ln -s ../lasso.dll
|
||||
* ln -s ../lasso.dll.config
|
||||
* mcs -g -nologo -pkg:lasso-sharp -out:BindingTests.exe BindingTests.cs
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class BindingTests {
|
||||
static void assertEquals(int i1, int i2) {
|
||||
if (i1 != i2)
|
||||
Console.WriteLine("Assertion failed: %d != %d", i1, i2);
|
||||
}
|
||||
|
||||
static void assertEquals(String s1, String s2) {
|
||||
if (s1 != s2)
|
||||
Console.WriteLine("Assertion failed: %s != %s", s1, s2);
|
||||
}
|
||||
|
||||
static void assertNull(Object o) {
|
||||
if (o != null)
|
||||
Console.WriteLine("Assertion failed: %s is not null", o);
|
||||
}
|
||||
|
||||
static void assertNull(String s) {
|
||||
if (s != null)
|
||||
Console.WriteLine("Assertion failed: %s is not null", s);
|
||||
}
|
||||
|
||||
static void Main() {
|
||||
lasso.lasso.init();
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
test04();
|
||||
test05();
|
||||
test06();
|
||||
lasso.lasso.shutdown();
|
||||
}
|
||||
|
||||
static void test01() {
|
||||
Console.Write("Create and delete nodes.");
|
||||
|
||||
lasso.LibAuthnRequest authnRequest = new lasso.LibAuthnRequest();
|
||||
authnRequest = null;
|
||||
|
||||
Console.WriteLine(".. OK");
|
||||
}
|
||||
|
||||
static void test02() {
|
||||
Console.Write("Get & set simple attributes of nodes.");
|
||||
|
||||
lasso.LibAuthnRequest authnRequest = new lasso.LibAuthnRequest();
|
||||
|
||||
// Test a string attribute.
|
||||
assertNull(authnRequest.consent);
|
||||
authnRequest.consent = lasso.lasso.LIB_CONSENT_OBTAINED;
|
||||
assertEquals(authnRequest.consent, lasso.lasso.LIB_CONSENT_OBTAINED);
|
||||
authnRequest.consent = null;
|
||||
assertNull(authnRequest.consent);
|
||||
|
||||
// Test a renamed string attribute.
|
||||
assertNull(authnRequest.relayState);
|
||||
authnRequest.relayState = "Hello World!";
|
||||
assertEquals(authnRequest.relayState, "Hello World!");
|
||||
authnRequest.relayState = null;
|
||||
assertNull(authnRequest.relayState);
|
||||
|
||||
// Test an integer attribute.
|
||||
assertEquals(authnRequest.majorVersion, 0);
|
||||
authnRequest.majorVersion = 314;
|
||||
assertEquals(authnRequest.majorVersion, 314);
|
||||
|
||||
authnRequest = null;
|
||||
|
||||
Console.WriteLine(".. OK");
|
||||
}
|
||||
|
||||
static void test03() {
|
||||
Console.Write("Get & set attributes of nodes of type string list.");
|
||||
|
||||
lasso.LibAuthnRequest authnRequest = new lasso.LibAuthnRequest();
|
||||
|
||||
assertNull(authnRequest.respondWith);
|
||||
|
||||
lasso.StringList respondWith = new lasso.StringList();
|
||||
assertEquals(respondWith.length(), 0);
|
||||
respondWith.append("first string");
|
||||
assertEquals(respondWith.length(), 1);
|
||||
assertEquals(respondWith.getItem(0), "first string");
|
||||
assertEquals(respondWith.getItem(0), "first string");
|
||||
respondWith.append("second string");
|
||||
assertEquals(respondWith.length(), 2);
|
||||
assertEquals(respondWith.getItem(0), "first string");
|
||||
assertEquals(respondWith.getItem(1), "second string");
|
||||
respondWith.append("third string");
|
||||
assertEquals(respondWith.length(), 3);
|
||||
assertEquals(respondWith.getItem(0), "first string");
|
||||
assertEquals(respondWith.getItem(1), "second string");
|
||||
assertEquals(respondWith.getItem(2), "third string");
|
||||
authnRequest.respondWith = respondWith;
|
||||
assertEquals(authnRequest.respondWith.getItem(0), "first string");
|
||||
assertEquals(authnRequest.respondWith.getItem(1), "second string");
|
||||
assertEquals(authnRequest.respondWith.getItem(2), "third string");
|
||||
assertEquals(respondWith.getItem(0), "first string");
|
||||
assertEquals(respondWith.getItem(1), "second string");
|
||||
assertEquals(respondWith.getItem(2), "third string");
|
||||
respondWith = null;
|
||||
assertEquals(authnRequest.respondWith.getItem(0), "first string");
|
||||
assertEquals(authnRequest.respondWith.getItem(1), "second string");
|
||||
assertEquals(authnRequest.respondWith.getItem(2), "third string");
|
||||
respondWith = authnRequest.respondWith;
|
||||
assertEquals(respondWith.getItem(0), "first string");
|
||||
assertEquals(respondWith.getItem(1), "second string");
|
||||
assertEquals(respondWith.getItem(2), "third string");
|
||||
respondWith = null;
|
||||
assertEquals(authnRequest.respondWith.getItem(0), "first string");
|
||||
assertEquals(authnRequest.respondWith.getItem(1), "second string");
|
||||
assertEquals(authnRequest.respondWith.getItem(2), "third string");
|
||||
authnRequest.respondWith = null;
|
||||
assertNull(authnRequest.respondWith);
|
||||
|
||||
authnRequest = null;
|
||||
|
||||
Console.WriteLine(".. OK");
|
||||
}
|
||||
|
||||
static void test04() {
|
||||
Console.Write("Get & set attributes of nodes of type node list.");
|
||||
|
||||
lasso.SamlpResponse response = new lasso.SamlpResponse();
|
||||
|
||||
assertNull(response.assertion);
|
||||
lasso.NodeList assertions = new lasso.NodeList();
|
||||
assertEquals(assertions.length(), 0);
|
||||
lasso.SamlAssertion assertion1 = new lasso.SamlAssertion();
|
||||
assertion1.assertionId = "assertion 1";
|
||||
assertions.append(assertion1);
|
||||
assertEquals(assertions.length(), 1);
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
lasso.SamlAssertion assertion2 = new lasso.SamlAssertion();
|
||||
assertion2.assertionId = "assertion 2";
|
||||
assertions.append(assertion2);
|
||||
assertEquals(assertions.length(), 2);
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
lasso.SamlAssertion assertion3 = new lasso.SamlAssertion();
|
||||
assertion3.assertionId = "assertion 3";
|
||||
assertions.append(assertion3);
|
||||
assertEquals(assertions.length(), 3);
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(2)).assertionId,
|
||||
"assertion 3");
|
||||
response.assertion = assertions;
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(2)).assertionId,
|
||||
"assertion 3");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(2)).assertionId,
|
||||
"assertion 3");
|
||||
assertions = null;;
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(2)).assertionId,
|
||||
"assertion 3");
|
||||
assertions = response.assertion;
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
assertEquals(((lasso.SamlAssertion) assertions.getItem(2)).assertionId,
|
||||
"assertion 3");
|
||||
assertions = null;
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(0)).assertionId,
|
||||
"assertion 1");
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(1)).assertionId,
|
||||
"assertion 2");
|
||||
assertEquals(((lasso.SamlAssertion) response.assertion.getItem(2)).assertionId,
|
||||
"assertion 3");
|
||||
response.assertion = null;
|
||||
assertNull(response.assertion);
|
||||
|
||||
response = null;
|
||||
|
||||
Console.WriteLine(".. OK");
|
||||
}
|
||||
|
||||
static void test05() {
|
||||
Console.Write("Get & set attributes of nodes of type XML list.");
|
||||
|
||||
lasso.LibAuthnRequest authnRequest = new lasso.LibAuthnRequest();
|
||||
|
||||
assertNull(authnRequest.extension);
|
||||
|
||||
String actionString1 = "<lib:Extension xmlns:lib=\"urn:liberty:iff:2003-08\">\n"
|
||||
+ " <action>do 1</action>\n"
|
||||
+ "</lib:Extension>";
|
||||
String actionString2 = "<lib:Extension xmlns:lib=\"urn:liberty:iff:2003-08\">\n"
|
||||
+ " <action>do 2</action>\n"
|
||||
+ "</lib:Extension>";
|
||||
String actionString3 = "<lib:Extension xmlns:lib=\"urn:liberty:iff:2003-08\">\n"
|
||||
+ " <action>do 3</action>\n"
|
||||
+ "</lib:Extension>";
|
||||
lasso.StringList extension = new lasso.StringList();
|
||||
assertEquals(extension.length(), 0);
|
||||
extension.append(actionString1);
|
||||
assertEquals(extension.length(), 1);
|
||||
assertEquals(extension.getItem(0), actionString1);
|
||||
assertEquals(extension.getItem(0), actionString1);
|
||||
extension.append(actionString2);
|
||||
assertEquals(extension.length(), 2);
|
||||
assertEquals(extension.getItem(0), actionString1);
|
||||
assertEquals(extension.getItem(1), actionString2);
|
||||
extension.append(actionString3);
|
||||
assertEquals(extension.length(), 3);
|
||||
assertEquals(extension.getItem(0), actionString1);
|
||||
assertEquals(extension.getItem(1), actionString2);
|
||||
assertEquals(extension.getItem(2), actionString3);
|
||||
authnRequest.extension = extension;
|
||||
assertEquals(authnRequest.extension.getItem(0), actionString1);
|
||||
assertEquals(authnRequest.extension.getItem(1), actionString2);
|
||||
assertEquals(authnRequest.extension.getItem(2), actionString3);
|
||||
assertEquals(extension.getItem(0), actionString1);
|
||||
assertEquals(extension.getItem(1), actionString2);
|
||||
assertEquals(extension.getItem(2), actionString3);
|
||||
extension = null;
|
||||
assertEquals(authnRequest.extension.getItem(0), actionString1);
|
||||
assertEquals(authnRequest.extension.getItem(1), actionString2);
|
||||
assertEquals(authnRequest.extension.getItem(2), actionString3);
|
||||
extension = authnRequest.extension;
|
||||
assertEquals(extension.getItem(0), actionString1);
|
||||
assertEquals(extension.getItem(1), actionString2);
|
||||
assertEquals(extension.getItem(2), actionString3);
|
||||
extension = null;
|
||||
assertEquals(authnRequest.extension.getItem(0), actionString1);
|
||||
assertEquals(authnRequest.extension.getItem(1), actionString2);
|
||||
assertEquals(authnRequest.extension.getItem(2), actionString3);
|
||||
authnRequest.extension = null;
|
||||
assertNull(authnRequest.extension);
|
||||
|
||||
authnRequest = null;
|
||||
|
||||
Console.WriteLine(".. OK");
|
||||
}
|
||||
|
||||
static void test06() {
|
||||
Console.Write("Get & set attributes of nodes of type node.");
|
||||
|
||||
lasso.Login login = new lasso.Login(new lasso.Server(null, null, null, null));
|
||||
|
||||
assertNull(login.request);
|
||||
login.request = (lasso.SamlpRequestAbstract) new lasso.LibAuthnRequest();
|
||||
((lasso.LibAuthnRequest) login.request).consent = lasso.lasso.LIB_CONSENT_OBTAINED;
|
||||
assertEquals(((lasso.LibAuthnRequest) login.request).consent,
|
||||
lasso.lasso.LIB_CONSENT_OBTAINED);
|
||||
login.request = null;
|
||||
assertNull(login.request);
|
||||
|
||||
login = null;
|
||||
|
||||
Console.WriteLine(".. OK");
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
SWIG_OUTPUTS = lasso_wrap.c php_lasso.h lasso.php
|
||||
|
||||
php_extension_LTLIBRARIES = lasso.la
|
||||
lasso_la_CFLAGS = $(LASSO_CORE_CFLAGS) -I$(top_builddir) -I$(top_srcdir) $(PHP5_INCLUDES)
|
||||
lasso_la_LDFLAGS = -export-dynamic -prefer-pic -module -avoid-version
|
||||
lasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS) $(PHP5_LDFLAGS)
|
||||
lasso_la_SOURCES = lasso_wrap.c
|
||||
|
||||
php_extensiondir = ${prefix}@PHP5_UNPREFIXED_EXTENSION_DIR@
|
||||
|
||||
SWIG_I_FILES=$(shell find $(top_srcdir)/swig/ -name '*.[ih]')
|
||||
lasso_wrap.c php_lasso.h lasso.php: $(SWIG_I_FILES)
|
||||
$(SWIG) -v -php5 -module lasso -o lasso_wrap.c $(top_srcdir)/swig/Lasso.i
|
||||
|
||||
test-php: lasso.la lasso.php
|
||||
$(PHP5) -d extension_dir=.libs $(srcdir)/lasso.php
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in $(SWIG_OUTPUTS)
|
||||
EXTRA_DIST = $(SWIG_OUTPUTS)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
lasso.py
|
||||
lasso_wrap.c
|
||||
*.pyc
|
||||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
*.la
|
||||
*.lo
|
|
@ -1,45 +0,0 @@
|
|||
INCLUDES = \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir) \
|
||||
$(SASL_CFLAGS)
|
||||
|
||||
pythondir= $(PY_SITE_PACKAGES)
|
||||
python_DATA = lasso.py
|
||||
python_LTLIBRARIES = _lasso.la
|
||||
|
||||
_lasso_la_SOURCES = lasso_wrap.c
|
||||
_lasso_la_CFLAGS = $(LASSO_CORE_CFLAGS) -DSWIG_COBJECT_TYPES $(PY_CFLAGS)
|
||||
_lasso_la_LIBADD = $(top_builddir)/lasso/liblasso.la $(LASSO_LIBS)
|
||||
if DARWIN
|
||||
_lasso_la_LDFLAGS = -no-undefined -module -avoid-version -Wl,-F. -Wl,-F. -bundle -framework Python
|
||||
else
|
||||
if MINGW
|
||||
_lasso_la_LDFLAGS = -no-undefined -module -avoid-version -Wl,--add-stdcall-alias
|
||||
else
|
||||
_lasso_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
endif
|
||||
endif
|
||||
SWIG_I_FILES=$(shell find $(top_srcdir)/swig/ -name '*.[ih]')
|
||||
lasso_wrap.c lasso.py: $(SWIG_I_FILES)
|
||||
$(SWIG) -v -python -module lasso -o lasso_wrap.c $(top_srcdir)/swig/Lasso.i
|
||||
cp lasso_wrap.c lasso_wrap.c.bak
|
||||
sed -e 's/^ int res = 0;$$//' \
|
||||
< lasso_wrap.c.bak > lasso_wrap.c
|
||||
cp lasso_wrap.c lasso_wrap.c.bak
|
||||
sed -e 's/\/\* if (val) \*val = PyObject_IsTrue(obj); return 1; \*\//int res = 0;/' \
|
||||
< lasso_wrap.c.bak > lasso_wrap.c
|
||||
cp lasso_wrap.c lasso_wrap.c.bak
|
||||
grep -q "int res =" lasso_wrap.c || \
|
||||
sed -e 's/if (obj == Py_True) /int res = 0; if (obj == Py_True) /' \
|
||||
< lasso_wrap.c.bak > lasso_wrap.c
|
||||
|
||||
SWIG_OUTPUTS = lasso_wrap.c lasso.py
|
||||
|
||||
clean-local:
|
||||
-rm lasso_wrap.c.bak
|
||||
|
||||
# In distribution, swig generated files are present.
|
||||
EXTRA_DIST = $(SWIG_OUTPUTS)
|
||||
|
||||
# Maintainer clean the swig generated files, because he/she maintains them.
|
||||
MAINTAINERCLEANFILES = Makefile.in $(SWIG_OUTPUTS)
|
|
@ -1,3 +0,0 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
*.pyc
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
EXTRA_DIST = tests.py login_tests.py idwsf2_tests.py
|
|
@ -1,74 +0,0 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# XmlTestRunner
|
||||
#
|
||||
# Copyright (C) 2004-2007 Entr'ouvert
|
||||
#
|
||||
# Authors: Frederic Peters <fpeters@entrouvert.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
import unittest
|
||||
import time
|
||||
import sys
|
||||
|
||||
def xml(text):
|
||||
if not text:
|
||||
return ""
|
||||
return text.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
|
||||
class XmlTestResult(unittest.TestResult):
|
||||
def addSuccess(self, test):
|
||||
print """ <test result="success">
|
||||
<id>%s</id>
|
||||
<description>%s</description>
|
||||
</test>""" % (test.id(), xml(test.shortDescription()))
|
||||
|
||||
def addError(self, test, err):
|
||||
unittest.TestResult.addError(self, test, err)
|
||||
print """ <test result="error">
|
||||
<id>%s</id>
|
||||
<description>%s</description>
|
||||
</test>""" % (test.id(), xml(test.shortDescription()))
|
||||
# TODO: add err
|
||||
|
||||
def addFailure(self, test, err):
|
||||
unittest.TestResult.addFailure(self, test, err)
|
||||
print """ <test result="failure">
|
||||
<id>%s</id>
|
||||
<description>%s</description>
|
||||
</test>""" % (test.id(), xml(test.shortDescription()))
|
||||
# TODO: add err
|
||||
|
||||
|
||||
class XmlTestRunner:
|
||||
def _makeResult(self):
|
||||
return XmlTestResult()
|
||||
|
||||
def run(self, test):
|
||||
print "<suite>"
|
||||
result = self._makeResult()
|
||||
startTime = time.time()
|
||||
test(result)
|
||||
stopTime = time.time()
|
||||
timeTaken = float(stopTime - startTime)
|
||||
print " <duration>%s</duration>" % timeTaken
|
||||
print "</suite>"
|
||||
|
||||
return result
|
||||
|
|
@ -1,324 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Python unit tests for Lasso library
|
||||
#
|
||||
# Copyright (C) 2004-2007 Entr'ouvert
|
||||
# http://lasso.entrouvert.org
|
||||
#
|
||||
# Authors: See AUTHORS file in top-level directory.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
if not '..' in sys.path:
|
||||
sys.path.insert(0, '..')
|
||||
if not '../.libs' in sys.path:
|
||||
sys.path.insert(0, '../.libs')
|
||||
|
||||
import lasso
|
||||
|
||||
|
||||
class BindingTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""Create and delete nodes."""
|
||||
|
||||
authnRequest = lasso.LibAuthnRequest()
|
||||
del authnRequest
|
||||
|
||||
def test02(self):
|
||||
"""Get & set simple attributes of nodes."""
|
||||
|
||||
authnRequest = lasso.LibAuthnRequest()
|
||||
|
||||
# Test a string attribute.
|
||||
self.failUnlessEqual(authnRequest.consent, None)
|
||||
authnRequest.consent = lasso.LIB_CONSENT_OBTAINED
|
||||
self.failUnlessEqual(authnRequest.consent, lasso.LIB_CONSENT_OBTAINED)
|
||||
authnRequest.consent = None
|
||||
self.failUnlessEqual(authnRequest.consent, None)
|
||||
|
||||
# Test a renamed string attribute.
|
||||
self.failUnlessEqual(authnRequest.relayState, None)
|
||||
authnRequest.relayState = 'Hello World!'
|
||||
self.failUnlessEqual(authnRequest.relayState, 'Hello World!')
|
||||
authnRequest.relayState = None
|
||||
self.failUnlessEqual(authnRequest.relayState, None)
|
||||
|
||||
# Test an integer attribute.
|
||||
self.failUnlessEqual(authnRequest.majorVersion, 0)
|
||||
authnRequest.majorVersion = 314
|
||||
self.failUnlessEqual(authnRequest.majorVersion, 314)
|
||||
|
||||
del authnRequest
|
||||
|
||||
def test03(self):
|
||||
"""Get & set attributes of nodes of type string list."""
|
||||
|
||||
authnRequest = lasso.LibAuthnRequest()
|
||||
|
||||
self.failUnlessEqual(authnRequest.respondWith, None)
|
||||
|
||||
respondWith = lasso.StringList()
|
||||
self.failUnlessEqual(len(respondWith), 0)
|
||||
respondWith.append('first string')
|
||||
self.failUnlessEqual(len(respondWith), 1)
|
||||
self.failUnlessEqual(respondWith[0], 'first string')
|
||||
respondWith.append('second string')
|
||||
self.failUnlessEqual(len(respondWith), 2)
|
||||
self.failUnlessEqual(respondWith[0], 'first string')
|
||||
self.failUnlessEqual(respondWith[1], 'second string')
|
||||
respondWith.append('third string')
|
||||
self.failUnlessEqual(len(respondWith), 3)
|
||||
self.failUnlessEqual(respondWith[0], 'first string')
|
||||
self.failUnlessEqual(respondWith[1], 'second string')
|
||||
self.failUnlessEqual(respondWith[2], 'third string')
|
||||
authnRequest.respondWith = respondWith
|
||||
self.failUnlessEqual(authnRequest.respondWith[0], 'first string')
|
||||
self.failUnlessEqual(authnRequest.respondWith[1], 'second string')
|
||||
self.failUnlessEqual(authnRequest.respondWith[2], 'third string')
|
||||
self.failUnlessEqual(respondWith[0], 'first string')
|
||||
self.failUnlessEqual(respondWith[1], 'second string')
|
||||
self.failUnlessEqual(respondWith[2], 'third string')
|
||||
del respondWith
|
||||
self.failUnlessEqual(authnRequest.respondWith[0], 'first string')
|
||||
self.failUnlessEqual(authnRequest.respondWith[1], 'second string')
|
||||
self.failUnlessEqual(authnRequest.respondWith[2], 'third string')
|
||||
respondWith = authnRequest.respondWith
|
||||
self.failUnlessEqual(respondWith[0], 'first string')
|
||||
self.failUnlessEqual(respondWith[1], 'second string')
|
||||
self.failUnlessEqual(respondWith[2], 'third string')
|
||||
del respondWith
|
||||
self.failUnlessEqual(authnRequest.respondWith[0], 'first string')
|
||||
self.failUnlessEqual(authnRequest.respondWith[1], 'second string')
|
||||
self.failUnlessEqual(authnRequest.respondWith[2], 'third string')
|
||||
authnRequest.respondWith = None
|
||||
self.failUnlessEqual(authnRequest.respondWith, None)
|
||||
|
||||
del authnRequest
|
||||
|
||||
def test04(self):
|
||||
"""Get & set attributes of nodes of type node list."""
|
||||
|
||||
response = lasso.SamlpResponse()
|
||||
|
||||
self.failUnlessEqual(response.assertion, None)
|
||||
|
||||
assertions = lasso.NodeList()
|
||||
self.failUnlessEqual(len(assertions), 0)
|
||||
assertion1 = lasso.SamlAssertion()
|
||||
assertion1.assertionId = 'assertion 1'
|
||||
assertions.append(assertion1)
|
||||
self.failUnlessEqual(len(assertions), 1)
|
||||
self.failUnlessEqual(assertions[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(assertions[0].assertionId, 'assertion 1')
|
||||
assertion2 = lasso.SamlAssertion()
|
||||
assertion2.assertionId = 'assertion 2'
|
||||
assertions.append(assertion2)
|
||||
self.failUnlessEqual(len(assertions), 2)
|
||||
self.failUnlessEqual(assertions[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(assertions[1].assertionId, 'assertion 2')
|
||||
assertion3 = lasso.SamlAssertion()
|
||||
assertion3.assertionId = 'assertion 3'
|
||||
assertions.append(assertion3)
|
||||
self.failUnlessEqual(len(assertions), 3)
|
||||
self.failUnlessEqual(assertions[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(assertions[1].assertionId, 'assertion 2')
|
||||
self.failUnlessEqual(assertions[2].assertionId, 'assertion 3')
|
||||
response.assertion = assertions
|
||||
self.failUnlessEqual(response.assertion[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(response.assertion[1].assertionId, 'assertion 2')
|
||||
self.failUnlessEqual(response.assertion[2].assertionId, 'assertion 3')
|
||||
self.failUnlessEqual(assertions[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(assertions[1].assertionId, 'assertion 2')
|
||||
self.failUnlessEqual(assertions[2].assertionId, 'assertion 3')
|
||||
del assertions
|
||||
self.failUnlessEqual(response.assertion[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(response.assertion[1].assertionId, 'assertion 2')
|
||||
self.failUnlessEqual(response.assertion[2].assertionId, 'assertion 3')
|
||||
assertions = response.assertion
|
||||
self.failUnlessEqual(assertions[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(assertions[1].assertionId, 'assertion 2')
|
||||
self.failUnlessEqual(assertions[2].assertionId, 'assertion 3')
|
||||
del assertions
|
||||
self.failUnlessEqual(response.assertion[0].assertionId, 'assertion 1')
|
||||
self.failUnlessEqual(response.assertion[1].assertionId, 'assertion 2')
|
||||
self.failUnlessEqual(response.assertion[2].assertionId, 'assertion 3')
|
||||
response.assertion = None
|
||||
self.failUnlessEqual(response.assertion, None)
|
||||
|
||||
del response
|
||||
|
||||
def test05(self):
|
||||
"""Get & set attributes of nodes of type XML list."""
|
||||
|
||||
authnRequest = lasso.LibAuthnRequest()
|
||||
|
||||
self.failUnlessEqual(authnRequest.extension, None)
|
||||
|
||||
actionString1 = """\
|
||||
<lib:Extension xmlns:lib="urn:liberty:iff:2003-08">
|
||||
<action>do 1</action>
|
||||
</lib:Extension>"""
|
||||
actionString2 = """\
|
||||
<lib:Extension xmlns:lib="urn:liberty:iff:2003-08">
|
||||
<action>do 2</action>
|
||||
</lib:Extension>"""
|
||||
actionString3 = """\
|
||||
<lib:Extension xmlns:lib="urn:liberty:iff:2003-08">
|
||||
<action>do 3</action>
|
||||
</lib:Extension>"""
|
||||
extension = lasso.StringList()
|
||||
self.failUnlessEqual(len(extension), 0)
|
||||
extension.append(actionString1)
|
||||
self.failUnlessEqual(len(extension), 1)
|
||||
self.failUnlessEqual(extension[0], actionString1)
|
||||
self.failUnlessEqual(extension[0], actionString1)
|
||||
extension.append(actionString2)
|
||||
self.failUnlessEqual(len(extension), 2)
|
||||
self.failUnlessEqual(extension[0], actionString1)
|
||||
self.failUnlessEqual(extension[1], actionString2)
|
||||
extension.append(actionString3)
|
||||
self.failUnlessEqual(len(extension), 3)
|
||||
self.failUnlessEqual(extension[0], actionString1)
|
||||
self.failUnlessEqual(extension[1], actionString2)
|
||||
self.failUnlessEqual(extension[2], actionString3)
|
||||
authnRequest.extension = extension
|
||||
self.failUnlessEqual(authnRequest.extension[0], actionString1)
|
||||
self.failUnlessEqual(authnRequest.extension[1], actionString2)
|
||||
self.failUnlessEqual(authnRequest.extension[2], actionString3)
|
||||
self.failUnlessEqual(extension[0], actionString1)
|
||||
self.failUnlessEqual(extension[1], actionString2)
|
||||
self.failUnlessEqual(extension[2], actionString3)
|
||||
del extension
|
||||
self.failUnlessEqual(authnRequest.extension[0], actionString1)
|
||||
self.failUnlessEqual(authnRequest.extension[1], actionString2)
|
||||
self.failUnlessEqual(authnRequest.extension[2], actionString3)
|
||||
extension = authnRequest.extension
|
||||
self.failUnlessEqual(extension[0], actionString1)
|
||||
self.failUnlessEqual(extension[1], actionString2)
|
||||
self.failUnlessEqual(extension[2], actionString3)
|
||||
del extension
|
||||
self.failUnlessEqual(authnRequest.extension[0], actionString1)
|
||||
self.failUnlessEqual(authnRequest.extension[1], actionString2)
|
||||
self.failUnlessEqual(authnRequest.extension[2], actionString3)
|
||||
authnRequest.extension = None
|
||||
self.failUnlessEqual(authnRequest.extension, None)
|
||||
|
||||
del authnRequest
|
||||
|
||||
def test06(self):
|
||||
"""Get & set attributes of nodes of type node."""
|
||||
|
||||
login = lasso.Login(lasso.Server())
|
||||
|
||||
self.failUnlessEqual(login.request, None)
|
||||
login.request = lasso.LibAuthnRequest()
|
||||
login.request.consent = lasso.LIB_CONSENT_OBTAINED
|
||||
self.failUnlessEqual(login.request.consent, lasso.LIB_CONSENT_OBTAINED)
|
||||
login.request = None
|
||||
self.failUnlessEqual(login.request, None)
|
||||
|
||||
del login
|
||||
|
||||
def test07(self):
|
||||
"""Get & set SAML 2.0 assertion attribute values"""
|
||||
|
||||
attribute1_name = 'first attribute'
|
||||
attribute1_string = 'first string'
|
||||
attribute2_name = 'second attribute'
|
||||
attribute2_string = 'second string'
|
||||
attribute3_string = 'third string'
|
||||
|
||||
expected_assertion_dump = '''\
|
||||
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" SignType="0" SignMethod="0" EncryptionActivated="false" EncryptionSymKeyType="0">
|
||||
<saml:AttributeStatement>
|
||||
<saml:Attribute Name="first attribute">
|
||||
<saml:AttributeValue>
|
||||
<XXX>first string</XXX>
|
||||
</saml:AttributeValue>
|
||||
</saml:Attribute>
|
||||
<saml:Attribute Name="second attribute">
|
||||
<saml:AttributeValue>
|
||||
<XXX>second string</XXX>
|
||||
</saml:AttributeValue>
|
||||
<saml:AttributeValue>
|
||||
<XXX>third string</XXX>
|
||||
</saml:AttributeValue>
|
||||
</saml:Attribute>
|
||||
</saml:AttributeStatement>
|
||||
</saml:Assertion>'''
|
||||
|
||||
text_node1 = lasso.MiscTextNode()
|
||||
text_node1.content = attribute1_string
|
||||
any1 = lasso.NodeList()
|
||||
any1.append(text_node1)
|
||||
attribute_value1 = lasso.Saml2AttributeValue()
|
||||
attribute_value1.any = any1
|
||||
attribute_values1 = lasso.NodeList()
|
||||
attribute_values1.append(attribute_value1)
|
||||
attribute1 = lasso.Saml2Attribute()
|
||||
attribute1.name = attribute1_name
|
||||
attribute1.attributeValue = attribute_values1
|
||||
|
||||
text_node2 = lasso.MiscTextNode()
|
||||
text_node2.content = attribute2_string
|
||||
any2 = lasso.NodeList()
|
||||
any2.append(text_node2)
|
||||
attribute_value2 = lasso.Saml2AttributeValue()
|
||||
attribute_value2.any = any2
|
||||
|
||||
text_node3 = lasso.MiscTextNode()
|
||||
text_node3.content = attribute3_string
|
||||
any3 = lasso.NodeList()
|
||||
any3.append(text_node3)
|
||||
attribute_value3 = lasso.Saml2AttributeValue()
|
||||
attribute_value3.any = any3
|
||||
|
||||
attribute_values2 = lasso.NodeList()
|
||||
attribute_values2.append(attribute_value2)
|
||||
attribute_values2.append(attribute_value3)
|
||||
|
||||
attribute2 = lasso.Saml2Attribute()
|
||||
attribute2.name = attribute2_name
|
||||
attribute2.attributeValue = attribute_values2
|
||||
|
||||
attributes = lasso.NodeList()
|
||||
attributes.append(attribute1)
|
||||
attributes.append(attribute2)
|
||||
|
||||
attributeStatement = lasso.Saml2AttributeStatement()
|
||||
attributeStatement.attribute = attributes
|
||||
attributeStatements = lasso.NodeList()
|
||||
attributeStatements.append(attributeStatement)
|
||||
|
||||
assertion = lasso.Saml2Assertion()
|
||||
assertion.attributeStatement = attributeStatements
|
||||
|
||||
self.failUnlessEqual(assertion.dump(), expected_assertion_dump, 'resulting assertion dump is not as expected')
|
||||
|
||||
|
||||
bindingSuite = unittest.makeSuite(BindingTestCase, 'test')
|
||||
|
||||
allTests = unittest.TestSuite((bindingSuite, ))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(not unittest.TextTestRunner(verbosity = 2).run(allTests).wasSuccessful())
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Python unit tests for Lasso library
|
||||
#
|
||||
# Copyright (C) 2004-2007 Entr'ouvert
|
||||
# http://lasso.entrouvert.org
|
||||
#
|
||||
# Authors: See AUTHORS file in top-level directory.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
if not '..' in sys.path:
|
||||
sys.path.insert(0, '..')
|
||||
if not '../.libs' in sys.path:
|
||||
sys.path.insert(0, '../.libs')
|
||||
|
||||
import lasso
|
||||
|
||||
|
||||
try:
|
||||
dataDir
|
||||
except NameError:
|
||||
dataDir = '../../tests/data'
|
||||
|
||||
|
||||
class ErrorCheckingTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""Instanciate Login with None as Server"""
|
||||
try:
|
||||
lasso.Login(None).msgUrl
|
||||
except:
|
||||
pass
|
||||
|
||||
def test02(self):
|
||||
"""Instanciate Logout with None as Server"""
|
||||
# Same as test01; replace Login by Logout
|
||||
try:
|
||||
lasso.Logout(None, lasso.providerTypeSp).msgUrl
|
||||
except:
|
||||
pass
|
||||
|
||||
def test03(self):
|
||||
"""Process empty string as authnrequest msg"""
|
||||
# This time; we got something wrong as query string; we pass it to
|
||||
# initFromAuthnRequestMsg; surely it shouldn't segfault
|
||||
server = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
login = lasso.Login(server)
|
||||
try:
|
||||
login.processAuthnRequestMsg("")
|
||||
except lasso.Error, error:
|
||||
if error[0] != -407:
|
||||
raise
|
||||
|
||||
def test04(self):
|
||||
server = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
logout = lasso.Logout(server)
|
||||
try:
|
||||
logout.initRequest(None, lasso.HTTP_METHOD_REDIRECT)
|
||||
except lasso.Error, error:
|
||||
if error[0] != -418:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
suite1 = unittest.makeSuite(ErrorCheckingTestCase, 'test')
|
||||
|
||||
allTests = unittest.TestSuite((suite1,))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(not unittest.TextTestRunner(verbosity=2).run(allTests).wasSuccessful())
|
||||
|
|
@ -1,257 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# Python unit tests for Lasso library
|
||||
#
|
||||
# Copyright (C) 2004-2007 Entr'ouvert
|
||||
# http://lasso.entrouvert.org
|
||||
#
|
||||
# Authors: See AUTHORS file in top-level directory.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
if not '..' in sys.path:
|
||||
sys.path.insert(0, '..')
|
||||
if not '../.libs' in sys.path:
|
||||
sys.path.insert(0, '../.libs')
|
||||
|
||||
import lasso
|
||||
|
||||
try:
|
||||
dataDir
|
||||
except NameError:
|
||||
dataDir = '../../tests/data'
|
||||
|
||||
wsp_metadata = os.path.join(dataDir, 'sp1-la/metadata.xml')
|
||||
wsp_private_key = os.path.join(dataDir, 'sp1-la/private-key-raw.pem')
|
||||
wsp_public_key = os.path.join(dataDir, 'sp1-la/public-key.pem')
|
||||
wsc_metadata = os.path.join(dataDir, 'sp2-la/metadata.xml')
|
||||
wsc_private_key = os.path.join(dataDir, 'sp2-la/private-key-raw.pem')
|
||||
wsc_public_key = os.path.join(dataDir, 'sp2-la/public-key.pem')
|
||||
idp_metadata = os.path.join(dataDir, 'idp1-la/metadata.xml')
|
||||
idp_private_key = os.path.join(dataDir, 'idp1-la/private-key-raw.pem')
|
||||
idp_public_key = os.path.join(dataDir, 'idp1-la/public-key.pem')
|
||||
|
||||
abstract_description = "Personal Profile Resource"
|
||||
resource_id = "http://idp/user/resources/1"
|
||||
|
||||
class IdWsf1TestCase(unittest.TestCase):
|
||||
def get_wsp_server(self):
|
||||
server = lasso.Server(wsp_metadata, wsp_private_key, None, None)
|
||||
server.addProvider(lasso.PROVIDER_ROLE_IDP, idp_metadata, idp_public_key, None)
|
||||
return server
|
||||
|
||||
def get_wsc_server(self):
|
||||
server = lasso.Server(wsc_metadata, wsc_private_key, None, None)
|
||||
server.addProvider(lasso.PROVIDER_ROLE_IDP, idp_metadata, idp_public_key, None)
|
||||
return server
|
||||
|
||||
def get_idp_server(self):
|
||||
server = lasso.Server(idp_metadata, idp_private_key, None, None)
|
||||
server.addProvider(lasso.PROVIDER_ROLE_SP, wsp_metadata, wsp_public_key, None)
|
||||
server.addProvider(lasso.PROVIDER_ROLE_SP, wsc_metadata, wsc_public_key, None)
|
||||
return server
|
||||
|
||||
def add_services(self, idp):
|
||||
# Add Discovery service
|
||||
disco_description = lasso.DiscoDescription.newWithBriefSoapHttpDescription(
|
||||
lasso.SECURITY_MECH_NULL,
|
||||
"http://idp/discovery/soapEndpoint",
|
||||
"Discovery SOAP Endpoint description");
|
||||
disco_service_instance = lasso.DiscoServiceInstance(
|
||||
lasso.DISCO_HREF,
|
||||
"http://idp/providerId",
|
||||
disco_description);
|
||||
idp.addService(disco_service_instance);
|
||||
|
||||
# Add Personal Profile service
|
||||
pp_description = lasso.DiscoDescription.newWithBriefSoapHttpDescription(
|
||||
lasso.SECURITY_MECH_NULL,
|
||||
"http://idp/pp/soapEndpoint",
|
||||
"Discovery SOAP Endpoint description");
|
||||
pp_service_instance = lasso.DiscoServiceInstance(
|
||||
lasso.PP_HREF,
|
||||
"http://idp/providerId",
|
||||
pp_description);
|
||||
idp.addService(pp_service_instance);
|
||||
return idp
|
||||
|
||||
def login(self, sp, idp):
|
||||
sp_login = lasso.Login(sp)
|
||||
sp_login.initAuthnRequest(sp.providerIds[0], lasso.HTTP_METHOD_POST)
|
||||
sp_login.request.nameIdPolicy = lasso.LIB_NAMEID_POLICY_TYPE_FEDERATED
|
||||
sp_login.request.protocolProfile = lasso.LIB_PROTOCOL_PROFILE_BRWS_POST
|
||||
sp_login.buildAuthnRequestMsg()
|
||||
|
||||
idp_login = lasso.Login(idp)
|
||||
idp_login.processAuthnRequestMsg(sp_login.msgBody)
|
||||
idp_login.validateRequestMsg(True, True)
|
||||
|
||||
# Set a resource offering in the assertion
|
||||
discovery_resource_id = "http://idp/discovery/resources/1"
|
||||
idp_login.setResourceId(discovery_resource_id)
|
||||
idp_login.buildAssertion(lasso.SAML_AUTHENTICATION_METHOD_PASSWORD, None, None, None, None)
|
||||
idp_login.buildAuthnResponseMsg()
|
||||
|
||||
sp_login = lasso.Login(sp)
|
||||
sp_login.processAuthnResponseMsg(idp_login.msgBody)
|
||||
sp_login.acceptSso()
|
||||
|
||||
return sp_login.identity.dump(), sp_login.session.dump(), idp_login.identity.dump(), idp_login.session.dump()
|
||||
|
||||
def get_pp_service(self):
|
||||
self.wsc = self.get_wsc_server()
|
||||
self.idp = self.get_idp_server()
|
||||
self.idp = self.add_services(self.idp)
|
||||
|
||||
# Login from WSC
|
||||
sp_identity_dump, sp_session_dump, idp_identity_dump, idp_session_dump = self.login(self.wsc, self.idp)
|
||||
|
||||
# Init discovery query
|
||||
wsc_disco = lasso.Discovery(self.wsc)
|
||||
wsc_disco.setSessionFromDump(sp_session_dump)
|
||||
wsc_disco.initQuery()
|
||||
wsc_disco.addRequestedServiceType(lasso.PP_HREF)
|
||||
wsc_disco.buildRequestMsg();
|
||||
|
||||
# Process query
|
||||
idp_disco = lasso.Discovery(self.idp)
|
||||
idp_disco.processQueryMsg(wsc_disco.msgBody)
|
||||
idp_disco.setIdentityFromDump(idp_identity_dump)
|
||||
|
||||
# Build resource offering
|
||||
service_instance = lasso.DiscoServiceInstance(
|
||||
lasso.PP_HREF,
|
||||
self.idp.providerId,
|
||||
lasso.DiscoDescription_newWithBriefSoapHttpDescription(
|
||||
lasso.SECURITY_MECH_NULL,
|
||||
'http://idp/pp/soapEndpoint'))
|
||||
resource_offering = lasso.DiscoResourceOffering(service_instance);
|
||||
resource_offering.resourceId = lasso.DiscoResourceID(resource_id)
|
||||
resource_offering.abstract = abstract_description
|
||||
idp_disco.identity.addResourceOffering(resource_offering)
|
||||
idp_disco.buildResponseMsg()
|
||||
|
||||
# Process response
|
||||
wsc_disco.processQueryResponseMsg(idp_disco.msgBody);
|
||||
return wsc_disco.getService()
|
||||
|
||||
def test01(self):
|
||||
'''Test a discovery query'''
|
||||
service = self.get_pp_service()
|
||||
# Check service attributes
|
||||
self.failUnless(service.resourceId is not None)
|
||||
self.failUnless(service.resourceId.content == resource_id)
|
||||
self.failUnless(service.providerId == self.wsc.providerIds[0])
|
||||
self.failUnless(service.abstractDescription == abstract_description)
|
||||
|
||||
def test02(self):
|
||||
'''Test a data service query'''
|
||||
wsc_service = self.get_pp_service()
|
||||
wsc_service.initQuery('/pp:PP/pp:InformalName', 'name')
|
||||
wsc_service.buildRequestMsg()
|
||||
self.failUnless(lasso.getRequestTypeFromSoapMsg(wsc_service.msgBody)
|
||||
== lasso.REQUEST_TYPE_DST_QUERY)
|
||||
|
||||
self.wsp = self.get_wsp_server()
|
||||
wsp_service = lasso.DataService(self.wsp)
|
||||
wsp_service.processQueryMsg(wsc_service.msgBody)
|
||||
wsp_service.resourceData = '''
|
||||
<PP xmlns="urn:liberty:id-sis-pp:2003-08">
|
||||
<InformalName>Damien</InformalName>
|
||||
</PP>'''
|
||||
wsp_service.buildResponseMsg()
|
||||
|
||||
wsc_service.processQueryResponseMsg(wsp_service.msgBody)
|
||||
self.failUnless(wsc_service.getAnswer('/pp:PP/pp:InformalName') ==
|
||||
'<InformalName xmlns="urn:liberty:id-sis-pp:2003-08">Damien</InformalName>')
|
||||
|
||||
def test03(self):
|
||||
'''Test a data service modify'''
|
||||
wsc_service = self.get_pp_service()
|
||||
|
||||
xpath = '/pp:PP/pp:InformalName'
|
||||
old_data = '''
|
||||
<PP xmlns="urn:liberty:id-sis-pp:2003-08">
|
||||
<InformalName>Damien</InformalName>
|
||||
</PP>'''
|
||||
new_data = '<InformalName>Alain</InformalName>'
|
||||
|
||||
new_full_data = '''<PP xmlns="urn:liberty:id-sis-pp:2003-08">
|
||||
<pp:InformalName xmlns:pp="urn:liberty:id-sis-pp:2003-08">Alain</pp:InformalName>
|
||||
</PP>'''
|
||||
|
||||
wsc_service.initModify(xpath, new_data)
|
||||
wsc_service.buildRequestMsg()
|
||||
self.failUnless(lasso.getRequestTypeFromSoapMsg(wsc_service.msgBody)
|
||||
== lasso.REQUEST_TYPE_DST_MODIFY)
|
||||
|
||||
self.wsp = self.get_wsp_server()
|
||||
wsp_service = lasso.DataService(self.wsp)
|
||||
wsp_service.processModifyMsg(wsc_service.msgBody)
|
||||
wsp_service.resourceData = old_data
|
||||
wsp_service.buildModifyResponseMsg()
|
||||
# Save the new wsp_service.resourceData here
|
||||
|
||||
self.failUnless(wsp_service.resourceData == new_full_data)
|
||||
|
||||
wsc_service.processModifyResponseMsg(wsp_service.msgBody)
|
||||
|
||||
def test10(self):
|
||||
'''Test a data service modify - root element'''
|
||||
wsc_service = self.get_pp_service()
|
||||
|
||||
xpath = '/pp:PP'
|
||||
old_data = '''
|
||||
<PP xmlns="urn:liberty:id-sis-pp:2003-08">
|
||||
<InformalName>Damien</InformalName>
|
||||
</PP>'''
|
||||
new_data = '''<PP xmlns="urn:liberty:id-sis-pp:2003-08">
|
||||
<InformalName>Alain</InformalName>
|
||||
</PP>'''
|
||||
|
||||
new_full_data = '''<PP xmlns="urn:liberty:id-sis-pp:2003-08">
|
||||
<InformalName>Alain</InformalName>
|
||||
</PP>'''
|
||||
|
||||
wsc_service.initModify(xpath, new_data)
|
||||
wsc_service.buildRequestMsg()
|
||||
|
||||
self.failUnless(lasso.getRequestTypeFromSoapMsg(wsc_service.msgBody)
|
||||
== lasso.REQUEST_TYPE_DST_MODIFY)
|
||||
|
||||
self.wsp = self.get_wsp_server()
|
||||
wsp_service = lasso.DataService(self.wsp)
|
||||
wsp_service.processModifyMsg(wsc_service.msgBody)
|
||||
wsp_service.resourceData = old_data
|
||||
wsp_service.buildModifyResponseMsg()
|
||||
# Save the new wsp_service.resourceData here
|
||||
|
||||
self.failUnless(wsp_service.resourceData == new_full_data)
|
||||
|
||||
wsc_service.processModifyResponseMsg(wsp_service.msgBody)
|
||||
|
||||
|
||||
idWsf1Suite = unittest.makeSuite(IdWsf1TestCase, 'test')
|
||||
|
||||
allTests = unittest.TestSuite((idWsf1Suite))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(not unittest.TextTestRunner(verbosity = 2).run(allTests).wasSuccessful())
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,356 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Python unit tests for Lasso library
|
||||
#
|
||||
# Copyright (C) 2004-2007 Entr'ouvert
|
||||
# http://lasso.entrouvert.org
|
||||
#
|
||||
# Authors: See AUTHORS file in top-level directory.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
if not '..' in sys.path:
|
||||
sys.path.insert(0, '..')
|
||||
if not '../.libs' in sys.path:
|
||||
sys.path.insert(0, '../.libs')
|
||||
|
||||
import lasso
|
||||
|
||||
|
||||
try:
|
||||
dataDir
|
||||
except NameError:
|
||||
dataDir = '../../tests/data'
|
||||
|
||||
|
||||
class ServerTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""Server construction, dump & newFromDump."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
dump = lassoServer.dump()
|
||||
lassoServer2 = lassoServer.newFromDump(dump)
|
||||
dump2 = lassoServer2.dump()
|
||||
self.failUnlessEqual(dump, dump2)
|
||||
|
||||
def test02(self):
|
||||
"""Server construction without argument, dump & newFromDump."""
|
||||
|
||||
lassoServer = lasso.Server()
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'))
|
||||
dump = lassoServer.dump()
|
||||
lassoServer2 = lassoServer.newFromDump(dump)
|
||||
dump2 = lassoServer2.dump()
|
||||
self.failUnlessEqual(dump, dump2)
|
||||
|
||||
|
||||
class LoginTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""SP login; testing access to authentication request."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
login = lasso.Login(lassoServer)
|
||||
login.initAuthnRequest()
|
||||
login.request.protocolProfile = lasso.LIB_PROTOCOL_PROFILE_BRWS_ART
|
||||
self.failUnlessEqual(login.request.protocolProfile, lasso.LIB_PROTOCOL_PROFILE_BRWS_ART)
|
||||
|
||||
def test02(self):
|
||||
"""SP login; testing processing of an empty Response."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
login = lasso.Login(lassoServer)
|
||||
try:
|
||||
login.processResponseMsg('')
|
||||
except lasso.Error, error:
|
||||
if error[0] != lasso.PROFILE_ERROR_INVALID_MSG:
|
||||
raise
|
||||
|
||||
def test03(self):
|
||||
"""Conversion of a lib:AuthnRequest with an AuthnContext into a query and back."""
|
||||
|
||||
sp = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
sp.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
spLogin = lasso.Login(sp)
|
||||
spLogin.initAuthnRequest()
|
||||
requestAuthnContext = lasso.LibRequestAuthnContext()
|
||||
authnContextClassRefsList = lasso.StringList()
|
||||
authnContextClassRefsList.append(
|
||||
lasso.LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD)
|
||||
requestAuthnContext.authnContextClassRef = authnContextClassRefsList
|
||||
spLogin.request.requestAuthnContext = requestAuthnContext
|
||||
spLogin.request.protocolProfile = lasso.LIB_PROTOCOL_PROFILE_BRWS_ART
|
||||
spLogin.buildAuthnRequestMsg()
|
||||
authnRequestUrl = spLogin.msgUrl
|
||||
authnRequestQuery = spLogin.msgUrl[spLogin.msgUrl.index('?') + 1:]
|
||||
idp = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
idp.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
idpLogin = lasso.Login(idp)
|
||||
idpLogin.processAuthnRequestMsg(authnRequestQuery)
|
||||
self.failUnless(idpLogin.request.requestAuthnContext)
|
||||
authnContextClassRefsList = idpLogin.request.requestAuthnContext.authnContextClassRef
|
||||
self.failUnlessEqual(len(authnContextClassRefsList), 1)
|
||||
self.failUnlessEqual(authnContextClassRefsList[0],
|
||||
lasso.LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD)
|
||||
|
||||
def test04(self):
|
||||
"""Conversion of a lib:AuthnRequest with extensions into a query and back."""
|
||||
|
||||
sp = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
sp.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
spLogin = lasso.Login(sp)
|
||||
spLogin.initAuthnRequest()
|
||||
requestAuthnContext = lasso.LibRequestAuthnContext()
|
||||
extensionList = lasso.StringList()
|
||||
for extension in (
|
||||
'<action>do</action>',
|
||||
'<action2>do action 2</action2><action3>do action 3</action3>'):
|
||||
extensionList.append(
|
||||
'<lib:Extension xmlns:lib="urn:liberty:iff:2003-08">%s</lib:Extension>'
|
||||
% extension)
|
||||
spLogin.request.extension = extensionList
|
||||
spLogin.request.protocolProfile = lasso.LIB_PROTOCOL_PROFILE_BRWS_ART
|
||||
spLogin.buildAuthnRequestMsg()
|
||||
authnRequestUrl = spLogin.msgUrl
|
||||
authnRequestQuery = spLogin.msgUrl[spLogin.msgUrl.index('?') + 1:]
|
||||
idp = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
idp.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
idpLogin = lasso.Login(idp)
|
||||
idpLogin.processAuthnRequestMsg(authnRequestQuery)
|
||||
self.failUnless(idpLogin.request.extension)
|
||||
extensionsList = idpLogin.request.extension
|
||||
self.failUnlessEqual(len(extensionsList), 1)
|
||||
self.failUnless('<action>do</action>' in extensionsList[0])
|
||||
self.failUnless('<action2>do action 2</action2>' in extensionsList[0])
|
||||
self.failUnless('<action3>do action 3</action3>' in extensionsList[0])
|
||||
|
||||
|
||||
class LogoutTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""SP logout without session and identity; testing initRequest."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_IDP,
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
logout = lasso.Logout(lassoServer)
|
||||
try:
|
||||
logout.initRequest()
|
||||
except lasso.Error, error:
|
||||
if error[0] != lasso.PROFILE_ERROR_SESSION_NOT_FOUND:
|
||||
raise
|
||||
else:
|
||||
self.fail('logout.initRequest without having set identity before should fail')
|
||||
|
||||
def test02(self):
|
||||
"""IDP logout without session and identity; testing logout.getNextProviderId."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
logout = lasso.Logout(lassoServer)
|
||||
self.failIf(logout.getNextProviderId())
|
||||
|
||||
def test03(self):
|
||||
"""IDP logout; testing processRequestMsg with non Liberty query."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
logout = lasso.Logout(lassoServer)
|
||||
# The processRequestMsg should fail but not abort.
|
||||
try:
|
||||
logout.processRequestMsg('passport=0&lasso=1')
|
||||
except lasso.Error, error:
|
||||
if error[0] != lasso.PROFILE_ERROR_INVALID_MSG:
|
||||
raise
|
||||
else:
|
||||
self.fail('Logout processRequestMsg should have failed.')
|
||||
|
||||
def test04(self):
|
||||
"""IDP logout; testing processResponseMsg with non Liberty query."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
logout = lasso.Logout(lassoServer)
|
||||
# The processResponseMsg should fail but not abort.
|
||||
try:
|
||||
logout.processResponseMsg('liberty=&alliance')
|
||||
except lasso.Error, error:
|
||||
if error[0] != lasso.PROFILE_ERROR_INVALID_MSG:
|
||||
raise
|
||||
else:
|
||||
self.fail('Logout processResponseMsg should have failed.')
|
||||
|
||||
def test05(self):
|
||||
"""IDP logout; testing logout dump & newFromDump()."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
|
||||
|
||||
class DefederationTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""IDP initiated defederation; testing processNotificationMsg with non Liberty query."""
|
||||
|
||||
lassoServer = lasso.Server(
|
||||
os.path.join(dataDir, 'idp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'idp1-la/private-key-raw.pem'),
|
||||
None,
|
||||
os.path.join(dataDir, 'idp1-la/certificate.pem'))
|
||||
lassoServer.addProvider(
|
||||
lasso.PROVIDER_ROLE_SP,
|
||||
os.path.join(dataDir, 'sp1-la/metadata.xml'),
|
||||
os.path.join(dataDir, 'sp1-la/public-key.pem'),
|
||||
os.path.join(dataDir, 'sp1-la/certificate.pem'))
|
||||
defederation = lasso.Defederation(lassoServer)
|
||||
# The processNotificationMsg should fail but not abort.
|
||||
try:
|
||||
defederation.processNotificationMsg('nonLibertyQuery=1')
|
||||
except lasso.Error, error:
|
||||
if error[0] != lasso.PROFILE_ERROR_INVALID_MSG:
|
||||
raise
|
||||
else:
|
||||
self.fail('Defederation processNotificationMsg should have failed.')
|
||||
|
||||
|
||||
class IdentityTestCase(unittest.TestCase):
|
||||
def test01(self):
|
||||
"""Identity newFromDump & dump."""
|
||||
return
|
||||
# test disabled since dump format changed
|
||||
identityDump = """<Identity xmlns="http://www.entrouvert.org/namespaces/lasso/0.0" Version="1"><Federations><Federation xmlns="http://www.entrouvert.org/namespaces/lasso/0.0" Version="1" RemoteProviderID="https://sp1.entrouvert.lan/metadata"><LocalNameIdentifier><saml:NameIdentifier xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" NameQualifier="https://proxy2.entrouvert.lan/metadata" Format="urn:liberty:iff:nameid:federated">_CD739B41C602EAEA93626EBD1751CB46</saml:NameIdentifier></LocalNameIdentifier></Federation><Federation xmlns="http://www.entrouvert.org/namespaces/lasso/0.0" Version="1" RemoteProviderID="https://idp1.entrouvert.lan/metadata"><RemoteNameIdentifier><saml:NameIdentifier xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" NameQualifier="https://idp1.entrouvert.lan/metadata" Format="urn:liberty:iff:nameid:federated">_11EA77A4FED32C41824AC5DE87298E65</saml:NameIdentifier></RemoteNameIdentifier></Federation></Federations></Identity>"""
|
||||
identity = lasso.Identity.newFromDump(identityDump)
|
||||
newIdentityDump = identity.dump()
|
||||
self.failUnlessEqual(identityDump, newIdentityDump)
|
||||
|
||||
|
||||
serverSuite = unittest.makeSuite(ServerTestCase, 'test')
|
||||
loginSuite = unittest.makeSuite(LoginTestCase, 'test')
|
||||
logoutSuite = unittest.makeSuite(LogoutTestCase, 'test')
|
||||
defederationSuite = unittest.makeSuite(DefederationTestCase, 'test')
|
||||
identitySuite = unittest.makeSuite(IdentityTestCase, 'test')
|
||||
|
||||
allTests = unittest.TestSuite((serverSuite, loginSuite, logoutSuite, defederationSuite,
|
||||
identitySuite))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(not unittest.TextTestRunner(verbosity = 2).run(allTests).wasSuccessful())
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Python unit tests for Lasso library
|
||||
#
|
||||
# Copyright (C) 2004-2007 Entr'ouvert
|
||||
# http://lasso.entrouvert.org
|
||||
#
|
||||
# Authors: See AUTHORS file in top-level directory.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
import __builtin__
|
||||
import imp
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from XmlTestRunner import XmlTestRunner
|
||||
|
||||
if not '..' in sys.path:
|
||||
sys.path.insert(0, '..')
|
||||
if not '../.libs' in sys.path:
|
||||
sys.path.insert(0, '../.libs')
|
||||
|
||||
|
||||
testSuites = [
|
||||
'binding_tests',
|
||||
'profiles_tests',
|
||||
'errorchecking_tests',
|
||||
]
|
||||
|
||||
import lasso
|
||||
if lasso.WSF_SUPPORT:
|
||||
testSuites.append('idwsf1_tests')
|
||||
testSuites.append('idwsf2_tests')
|
||||
|
||||
|
||||
# Parse command line options.
|
||||
parser = OptionParser()
|
||||
parser.add_option(
|
||||
'-x', '--xml', dest = 'xmlMode', help = 'enable XML output',
|
||||
action = 'store_true', default = False)
|
||||
parser.add_option(
|
||||
'-s', '--source-dir', dest = 'srcDir', help = 'path of source directory',
|
||||
metavar = 'DIR', default = os.getcwd())
|
||||
(options, args) = parser.parse_args()
|
||||
__builtin__.__dict__['dataDir'] = os.path.join(options.srcDir, '../../tests/data')
|
||||
|
||||
if options.xmlMode:
|
||||
print """<?xml version="1.0"?>"""
|
||||
print """<testsuites xmlns="http://check.sourceforge.net/ns">"""
|
||||
print """ <title>Python Bindings</title>"""
|
||||
print """ <datetime>%s</datetime>""" % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
|
||||
|
||||
success = True
|
||||
for testSuite in testSuites:
|
||||
fp, pathname, description = imp.find_module(testSuite)
|
||||
try:
|
||||
module = imp.load_module(testSuite, fp, pathname, description)
|
||||
finally:
|
||||
if fp:
|
||||
fp.close()
|
||||
if not module:
|
||||
print >> sys.stderr, 'Unable to load test suite:', testSuite
|
||||
continue
|
||||
|
||||
if module.__doc__:
|
||||
doc = module.__doc__
|
||||
else:
|
||||
doc = testSuite
|
||||
|
||||
if options.xmlMode:
|
||||
runner = XmlTestRunner()
|
||||
else:
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
print
|
||||
print '-' * len(doc)
|
||||
print doc
|
||||
print '-' * len(doc)
|
||||
result = runner.run(module.allTests)
|
||||
success = success and result.wasSuccessful()
|
||||
|
||||
if options.xmlMode:
|
||||
print """</testsuites>"""
|
||||
|
||||
sys.exit(not success)
|
Loading…
Reference in New Issue