summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Laniel <dlaniel@entrouvert.com>2008-01-14 11:20:16 +0000
committerDamien Laniel <dlaniel@entrouvert.com>2008-01-14 11:20:16 +0000
commit53a2b18539d70a49a94b36616b16cf05a06d273c (patch)
tree475b4fd363a0c1cab0f2e5b4124a703bf653452b
parentee439f13f2c0ef127f7d27922b6d21952bf92070 (diff)
downloadlasso-53a2b18539d70a49a94b36616b16cf05a06d273c.tar.gz
lasso-53a2b18539d70a49a94b36616b16cf05a06d273c.tar.xz
lasso-53a2b18539d70a49a94b36616b16cf05a06d273c.zip
added swig binding for Saml2AttributeValue + tests
-rwxr-xr-xpython/tests/binding_tests.py67
-rw-r--r--swig/saml-2.0/Makefile.am1
-rw-r--r--swig/saml-2.0/inheritance.h1
-rw-r--r--swig/saml-2.0/main.h2
-rw-r--r--swig/saml-2.0/saml2_attribute.i15
-rw-r--r--swig/saml-2.0/saml2_attribute_value.i67
6 files changed, 153 insertions, 0 deletions
diff --git a/python/tests/binding_tests.py b/python/tests/binding_tests.py
index 8e9e0b29..8ac44c40 100755
--- a/python/tests/binding_tests.py
+++ b/python/tests/binding_tests.py
@@ -238,6 +238,73 @@ class BindingTestCase(unittest.TestCase):
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>
+ <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
+ text_node3 = lasso.MiscTextNode()
+ text_node3.content = attribute3_string
+ any1 = lasso.NodeList()
+ any1.append(text_node2)
+ any1.append(text_node3)
+ attribute_value2 = lasso.Saml2AttributeValue()
+ attribute_value2.any = any1
+ attribute_values2 = lasso.NodeList()
+ attribute_values2.append(attribute_value2)
+ 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')
diff --git a/swig/saml-2.0/Makefile.am b/swig/saml-2.0/Makefile.am
index f530a05f..42378f89 100644
--- a/swig/saml-2.0/Makefile.am
+++ b/swig/saml-2.0/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST = \
saml2_assertion.i \
saml2_attribute.i \
saml2_attribute_statement.i \
+ saml2_attribute_value.i \
saml2_audience_restriction.i \
saml2_authn_context.i \
saml2_authn_statement.i \
diff --git a/swig/saml-2.0/inheritance.h b/swig/saml-2.0/inheritance.h
index d691a709..ca38eadc 100644
--- a/swig/saml-2.0/inheritance.h
+++ b/swig/saml-2.0/inheritance.h
@@ -38,6 +38,7 @@ SET_NODE_INFO(Saml2AudienceRestriction, Saml2ConditionAbstract)
SET_NODE_INFO(Samlp2LogoutRequest, Samlp2RequestAbstract)
SET_NODE_INFO(Samlp2AuthnQuery, Samlp2SubjectQueryAbstract)
SET_NODE_INFO(Saml2Attribute, Node)
+SET_NODE_INFO(Saml2AttributeValue, Node)
SET_NODE_INFO(Samlp2Terminate, Node)
SET_NODE_INFO(Samlp2StatusDetail, Node)
SET_NODE_INFO(Saml2AuthzDecisionStatement, Saml2StatementAbstract)
diff --git a/swig/saml-2.0/main.h b/swig/saml-2.0/main.h
index 3e52ec38..fe80feda 100644
--- a/swig/saml-2.0/main.h
+++ b/swig/saml-2.0/main.h
@@ -21,6 +21,7 @@
#include <lasso/xml/saml-2.0/saml2_statement_abstract.h>
#include <lasso/xml/saml-2.0/saml2_authn_statement.h>
#include <lasso/xml/saml-2.0/saml2_attribute_statement.h>
+#include <lasso/xml/saml-2.0/saml2_attribute_value.h>
#include <lasso/xml/saml-2.0/samlp2_idp_entry.h>
#include <lasso/xml/saml-2.0/samlp2_extensions.h>
#include <lasso/xml/saml-2.0/saml2_action.h>
@@ -70,6 +71,7 @@
%include saml2_statement_abstract.i
%include saml2_authn_statement.i
%include saml2_attribute_statement.i
+%include saml2_attribute_value.i
%include samlp2_idp_entry.i
%include samlp2_extensions.i
%include saml2_action.i
diff --git a/swig/saml-2.0/saml2_attribute.i b/swig/saml-2.0/saml2_attribute.i
index 0b3c8268..8a1037b2 100644
--- a/swig/saml-2.0/saml2_attribute.i
+++ b/swig/saml-2.0/saml2_attribute.i
@@ -30,17 +30,26 @@ typedef struct {
%rename(name) Name;
#endif
char *Name;
+
#ifndef SWIG_PHP_RENAMES
%rename(nameFormat) NameFormat;
#endif
char *NameFormat;
+
#ifndef SWIG_PHP_RENAMES
%rename(friendlyName) FriendlyName;
#endif
char *FriendlyName;
+
} LassoSaml2Attribute;
%extend LassoSaml2Attribute {
+ /* Attribute */
+#ifndef SWIG_PHP_RENAMES
+ %rename(attributeValue) AttributeValue;
+#endif
+ %newobject AttributeValue_get;
+ LassoNodeList *AttributeValue;
/* Constructor, Destructor & Static Methods */
LassoSaml2Attribute();
@@ -53,6 +62,12 @@ typedef struct {
%{
+/* Attributes */
+
+#define LassoSaml2Attribute_get_AttributeValue(self) get_node_list((self)->AttributeValue)
+#define LassoSaml2Attribute_AttributeValue_get(self) get_node_list((self)->AttributeValue)
+#define LassoSaml2Attribute_set_AttributeValue(self,value) set_node_list(&(self)->AttributeValue, (value))
+#define LassoSaml2Attribute_AttributeValue_set(self,value) set_node_list(&(self)->AttributeValue, (value))
/* Constructors, destructors & static methods implementations */
diff --git a/swig/saml-2.0/saml2_attribute_value.i b/swig/saml-2.0/saml2_attribute_value.i
new file mode 100644
index 00000000..acbcd096
--- /dev/null
+++ b/swig/saml-2.0/saml2_attribute_value.i
@@ -0,0 +1,67 @@
+/* $Id: saml2_attribute_value.i 3378 2007-08-13 10:43:37Z dlaniel $
+ *
+ * Lasso - A free implementation of the Liberty Alliance specifications.
+ *
+ * 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
+ */
+
+#ifndef SWIG_PHP_RENAMES
+%rename(Saml2AttributeValue) LassoSaml2AttributeValue;
+#endif
+typedef struct {
+} LassoSaml2AttributeValue;
+%extend LassoSaml2AttributeValue {
+
+ /* Attribute */
+#ifdef SWIG_PHP_RENAMES
+ %rename(Any) any;
+#endif
+ %newobject any_get;
+ LassoNodeList *any;
+
+ /* Constructor, Destructor & Static Methods */
+ LassoSaml2AttributeValue();
+ ~LassoSaml2AttributeValue();
+
+ /* Method inherited from LassoNode */
+ %newobject dump;
+ char* dump();
+}
+
+%{
+
+/* Attributes */
+
+#define LassoSaml2AttributeValue_get_any(self) get_node_list((self)->any)
+#define LassoSaml2AttributeValue_any_get(self) get_node_list((self)->any)
+#define LassoSaml2AttributeValue_set_any(self,value) set_node_list(&(self)->any, (value))
+#define LassoSaml2AttributeValue_any_set(self,value) set_node_list(&(self)->any, (value))
+
+/* Constructors, destructors & static methods implementations */
+
+#define new_LassoSaml2AttributeValue lasso_saml2_attribute_value_new
+#define delete_LassoSaml2AttributeValue(self) lasso_node_destroy(LASSO_NODE(self))
+
+/* Implementations of methods inherited from LassoNode */
+
+#define LassoSaml2AttributeValue_dump(self) lasso_node_dump(LASSO_NODE(self))
+
+%}
+