From: Brent Putman Date: Sat, 22 Jul 2006 20:18:01 +0000 (+0000) Subject: SAML 2.0 Core Assertion namespace unit tests. X-Git-Tag: 2.0-alpha1~218 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=0ba5816a876bed78a05d9ed77db97b809927f1c0 SAML 2.0 Core Assertion namespace unit tests. --- diff --git a/saml/saml2/core/Assertions.h b/saml/saml2/core/Assertions.h index d408c80..cc1ccc9 100644 --- a/saml/saml2/core/Assertions.h +++ b/saml/saml2/core/Assertions.h @@ -49,6 +49,7 @@ namespace opensaml { // Forward references class SAML_API Assertion; + class SAML_API EncryptedAssertion; DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionIDRef,AssertionID,SAML 2.0 AssertionIDRef element); DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionURIRef,AssertionURI,SAML 2.0 AssertionURIRef element); @@ -216,7 +217,7 @@ namespace opensaml { DECL_TYPED_CHILDREN(AssertionIDRef); DECL_TYPED_CHILDREN(AssertionURIRef); DECL_TYPED_CHILDREN(Assertion); - //DECL_TYPED_CHILDREN(EncryptedAssertion); + DECL_TYPED_CHILDREN(EncryptedAssertion); /** EvidenceType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; diff --git a/saml/saml2/core/impl/Assertions20Impl.cpp b/saml/saml2/core/impl/Assertions20Impl.cpp index 4672495..532f6ad 100644 --- a/saml/saml2/core/impl/Assertions20Impl.cpp +++ b/saml/saml2/core/impl/Assertions20Impl.cpp @@ -154,6 +154,8 @@ namespace opensaml { } }; + //TODO unit test for this + // - need to test encryption/decryption too, or already done in xmltooling ? class SAML_DLLLOCAL EncryptedElementTypeImpl : public virtual EncryptedElementType, public AbstractComplexElement, public AbstractDOMCachingXMLObject, @@ -222,6 +224,7 @@ namespace opensaml { } }; + //TODO unit test for this class SAML_DLLLOCAL EncryptedIDImpl : public virtual EncryptedID, public EncryptedElementTypeImpl { public: @@ -789,6 +792,7 @@ namespace opensaml { } }; + //TODO need unit test for this class SAML_DLLLOCAL AuthnContextDeclImpl : public virtual AuthnContextDecl, public AnyElementImpl { public: @@ -1097,6 +1101,7 @@ namespace opensaml { } }; + //TODO need unit test for this class SAML_DLLLOCAL AttributeValueImpl : public virtual AttributeValue, public AnyElementImpl { public: @@ -1199,6 +1204,7 @@ namespace opensaml { } }; + //TODO unit test for this class SAML_DLLLOCAL EncryptedAttributeImpl : public virtual EncryptedAttribute, public EncryptedElementTypeImpl { public: @@ -1331,6 +1337,7 @@ namespace opensaml { } }; + //TODO unit test for this class SAML_DLLLOCAL EncryptedAssertionImpl : public virtual EncryptedAssertion, public EncryptedElementTypeImpl { public: diff --git a/samltest/Makefile.am b/samltest/Makefile.am index be61ae8..f5de16d 100644 --- a/samltest/Makefile.am +++ b/samltest/Makefile.am @@ -23,17 +23,35 @@ samltest_h = \ saml1/core/impl/AudienceRestrictionConditionTest.h \ saml1/core/impl/AudienceTest.h \ saml1/core/impl/AuthenticationStatementTest.h \ + saml2/core/impl/Action20Test.h \ + saml2/core/impl/Advice20Test.h \ saml2/core/impl/Artifact20Test.h \ saml2/core/impl/ArtifactResolve20Test.h \ saml2/core/impl/ArtifactResponse20Test.h \ + saml2/core/impl/Assertion20Test.h \ saml2/core/impl/AssertionIDRequest20Test.h \ + saml2/core/impl/AssertionURIRef20Test.h \ + saml2/core/impl/Attribute20Test.h \ saml2/core/impl/AttributeQuery20Test.h \ + saml2/core/impl/AttributeStatement20Test.h \ + saml2/core/impl/Audience20Test.h \ + saml2/core/impl/AudienceRestriction20Test.h \ + saml2/core/impl/AuthenticatingAuthority20Test.h \ + saml2/core/impl/AuthnContext20Test.h \ + saml2/core/impl/AuthnContextClassRef20Test.h \ + saml2/core/impl/AuthnContextDeclRef20Test.h \ saml2/core/impl/AuthnQuery20Test.h \ saml2/core/impl/AuthnRequest20Test.h \ + saml2/core/impl/AuthnStatement20Test.h \ saml2/core/impl/AuthzDecisionQuery20Test.h \ + saml2/core/impl/AuthzDecisionStatement20Test.h \ + saml2/core/impl/Conditions20Test.h \ + saml2/core/impl/Evidence20Test.h \ saml2/core/impl/GetComplete20Test.h \ saml2/core/impl/IDPEntry20Test.h \ saml2/core/impl/IDPList20Test.h \ + saml2/core/impl/Issuer20Test.h \ + saml2/core/impl/KeyInfoConfirmationDataType20Test.h\ saml2/core/impl/LogoutRequest20Test.h \ saml2/core/impl/LogoutResponse20Test.h \ saml2/core/impl/ManageNameIDRequest20Test.h \ @@ -41,8 +59,12 @@ samltest_h = \ saml2/core/impl/NameIDMappingRequest20Test.h \ saml2/core/impl/NameIDMappingResponse20Test.h \ saml2/core/impl/NameIDPolicy20Test.h \ + saml2/core/impl/NameID20Test.h \ + saml2/core/impl/NameIDType20Test.h \ saml2/core/impl/NewEncryptedID20Test.h \ saml2/core/impl/NewID20Test.h \ + saml2/core/impl/OneTimeUse20Test.h \ + saml2/core/impl/ProxyRestriction20Test.h \ saml2/core/impl/RequesterID20Test.h \ saml2/core/impl/RequestedAuthnContext20Test.h \ saml2/core/impl/Response20Test.h \ @@ -53,6 +75,10 @@ samltest_h = \ saml2/core/impl/StatusDetail20Test.h \ saml2/core/impl/StatusMessage20Test.h \ saml2/core/impl/StatusResponse20Test.h\ + saml2/core/impl/Subject20Test.h\ + saml2/core/impl/SubjectConfirmation20Test.h\ + saml2/core/impl/SubjectConfirmationData20Test.h\ + saml2/core/impl/SubjectLocality20Test.h\ saml2/core/impl/Terminate20Test.h \ saml2/metadata/FilesystemMetadataProviderTest.h diff --git a/samltest/data/saml2/core/impl/Action.xml b/samltest/data/saml2/core/impl/Action.xml index 2e9162f..bf7705c 100644 Binary files a/samltest/data/saml2/core/impl/Action.xml and b/samltest/data/saml2/core/impl/Action.xml differ diff --git a/samltest/data/saml2/core/impl/ActionOptionalAttributes.xml b/samltest/data/saml2/core/impl/ActionOptionalAttributes.xml deleted file mode 100644 index c7766c7..0000000 Binary files a/samltest/data/saml2/core/impl/ActionOptionalAttributes.xml and /dev/null differ diff --git a/samltest/data/saml2/core/impl/AdviceChildElements.xml b/samltest/data/saml2/core/impl/AdviceChildElements.xml index b872820..72f40ac 100644 Binary files a/samltest/data/saml2/core/impl/AdviceChildElements.xml and b/samltest/data/saml2/core/impl/AdviceChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/Assertion.xml b/samltest/data/saml2/core/impl/Assertion.xml index 54b5f54..24f6522 100644 Binary files a/samltest/data/saml2/core/impl/Assertion.xml and b/samltest/data/saml2/core/impl/Assertion.xml differ diff --git a/samltest/data/saml2/core/impl/AssertionChildElements.xml b/samltest/data/saml2/core/impl/AssertionChildElements.xml index 67e917a..238a6b8 100644 Binary files a/samltest/data/saml2/core/impl/AssertionChildElements.xml and b/samltest/data/saml2/core/impl/AssertionChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/AssertionIDRef.xml b/samltest/data/saml2/core/impl/AssertionIDRef.xml index b6c07b0..039ec59 100644 Binary files a/samltest/data/saml2/core/impl/AssertionIDRef.xml and b/samltest/data/saml2/core/impl/AssertionIDRef.xml differ diff --git a/samltest/data/saml2/core/impl/AssertionOptionalAttributes.xml b/samltest/data/saml2/core/impl/AssertionOptionalAttributes.xml index abfd7df..959b542 100644 Binary files a/samltest/data/saml2/core/impl/AssertionOptionalAttributes.xml and b/samltest/data/saml2/core/impl/AssertionOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/AssertionURIRef.xml b/samltest/data/saml2/core/impl/AssertionURIRef.xml index 313ee24..cf33958 100644 Binary files a/samltest/data/saml2/core/impl/AssertionURIRef.xml and b/samltest/data/saml2/core/impl/AssertionURIRef.xml differ diff --git a/samltest/data/saml2/core/impl/Attribute.xml b/samltest/data/saml2/core/impl/Attribute.xml index 3f82e10..c5cdb52 100644 Binary files a/samltest/data/saml2/core/impl/Attribute.xml and b/samltest/data/saml2/core/impl/Attribute.xml differ diff --git a/samltest/data/saml2/core/impl/AttributeChildElements.xml b/samltest/data/saml2/core/impl/AttributeChildElements.xml new file mode 100644 index 0000000..206f191 Binary files /dev/null and b/samltest/data/saml2/core/impl/AttributeChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/AttributeOptionalAttributes.xml b/samltest/data/saml2/core/impl/AttributeOptionalAttributes.xml index 6ceb810..ba99fb1 100644 Binary files a/samltest/data/saml2/core/impl/AttributeOptionalAttributes.xml and b/samltest/data/saml2/core/impl/AttributeOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/AttributeStatement.xml b/samltest/data/saml2/core/impl/AttributeStatement.xml index 126259c..36f7ea2 100644 Binary files a/samltest/data/saml2/core/impl/AttributeStatement.xml and b/samltest/data/saml2/core/impl/AttributeStatement.xml differ diff --git a/samltest/data/saml2/core/impl/AttributeStatementChildElements.xml b/samltest/data/saml2/core/impl/AttributeStatementChildElements.xml index 6b30b14..6145080 100644 Binary files a/samltest/data/saml2/core/impl/AttributeStatementChildElements.xml and b/samltest/data/saml2/core/impl/AttributeStatementChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/Audience.xml b/samltest/data/saml2/core/impl/Audience.xml index 014826e..446ffac 100644 Binary files a/samltest/data/saml2/core/impl/Audience.xml and b/samltest/data/saml2/core/impl/Audience.xml differ diff --git a/samltest/data/saml2/core/impl/AudienceRestriction.xml b/samltest/data/saml2/core/impl/AudienceRestriction.xml index 3caca6b..c349f1e 100644 Binary files a/samltest/data/saml2/core/impl/AudienceRestriction.xml and b/samltest/data/saml2/core/impl/AudienceRestriction.xml differ diff --git a/samltest/data/saml2/core/impl/AudienceRestrictionChildElements.xml b/samltest/data/saml2/core/impl/AudienceRestrictionChildElements.xml index 7c5a9b5..90f011a 100644 Binary files a/samltest/data/saml2/core/impl/AudienceRestrictionChildElements.xml and b/samltest/data/saml2/core/impl/AudienceRestrictionChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/AuthenticatingAuthority.xml b/samltest/data/saml2/core/impl/AuthenticatingAuthority.xml index dbaa528..307b529 100644 Binary files a/samltest/data/saml2/core/impl/AuthenticatingAuthority.xml and b/samltest/data/saml2/core/impl/AuthenticatingAuthority.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnContext.xml b/samltest/data/saml2/core/impl/AuthnContext.xml index 4cc45b7..4f03ea6 100644 Binary files a/samltest/data/saml2/core/impl/AuthnContext.xml and b/samltest/data/saml2/core/impl/AuthnContext.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnContextChildElements.xml b/samltest/data/saml2/core/impl/AuthnContextChildElements.xml index 943638f..e0a5000 100644 Binary files a/samltest/data/saml2/core/impl/AuthnContextChildElements.xml and b/samltest/data/saml2/core/impl/AuthnContextChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnContextClassRef.xml b/samltest/data/saml2/core/impl/AuthnContextClassRef.xml index 5c98363..5324cc3 100644 Binary files a/samltest/data/saml2/core/impl/AuthnContextClassRef.xml and b/samltest/data/saml2/core/impl/AuthnContextClassRef.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnContextDeclRef.xml b/samltest/data/saml2/core/impl/AuthnContextDeclRef.xml index 86d6476..18ab5ff 100644 Binary files a/samltest/data/saml2/core/impl/AuthnContextDeclRef.xml and b/samltest/data/saml2/core/impl/AuthnContextDeclRef.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnStatement.xml b/samltest/data/saml2/core/impl/AuthnStatement.xml index d86cb43..7ce1017 100644 Binary files a/samltest/data/saml2/core/impl/AuthnStatement.xml and b/samltest/data/saml2/core/impl/AuthnStatement.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnStatementChildElements.xml b/samltest/data/saml2/core/impl/AuthnStatementChildElements.xml index f32826a..11d0a40 100644 Binary files a/samltest/data/saml2/core/impl/AuthnStatementChildElements.xml and b/samltest/data/saml2/core/impl/AuthnStatementChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/AuthnStatementOptionalAttributes.xml b/samltest/data/saml2/core/impl/AuthnStatementOptionalAttributes.xml index 7198d82..1603be1 100644 Binary files a/samltest/data/saml2/core/impl/AuthnStatementOptionalAttributes.xml and b/samltest/data/saml2/core/impl/AuthnStatementOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/AuthzDecisionStatement.xml b/samltest/data/saml2/core/impl/AuthzDecisionStatement.xml index 970b15e..25b7c75 100644 Binary files a/samltest/data/saml2/core/impl/AuthzDecisionStatement.xml and b/samltest/data/saml2/core/impl/AuthzDecisionStatement.xml differ diff --git a/samltest/data/saml2/core/impl/AuthzDecisionStatementChildElements.xml b/samltest/data/saml2/core/impl/AuthzDecisionStatementChildElements.xml index 84bd12a..5f5693a 100644 Binary files a/samltest/data/saml2/core/impl/AuthzDecisionStatementChildElements.xml and b/samltest/data/saml2/core/impl/AuthzDecisionStatementChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/Conditions.xml b/samltest/data/saml2/core/impl/Conditions.xml index 2fbb68b..b061bbf 100644 Binary files a/samltest/data/saml2/core/impl/Conditions.xml and b/samltest/data/saml2/core/impl/Conditions.xml differ diff --git a/samltest/data/saml2/core/impl/ConditionsChildElements.xml b/samltest/data/saml2/core/impl/ConditionsChildElements.xml index 696778c..f32c3f0 100644 Binary files a/samltest/data/saml2/core/impl/ConditionsChildElements.xml and b/samltest/data/saml2/core/impl/ConditionsChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/ConditionsOptionalAttributes.xml b/samltest/data/saml2/core/impl/ConditionsOptionalAttributes.xml index 2eb7206..fad56ed 100644 Binary files a/samltest/data/saml2/core/impl/ConditionsOptionalAttributes.xml and b/samltest/data/saml2/core/impl/ConditionsOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/EvidenceChildElements.xml b/samltest/data/saml2/core/impl/EvidenceChildElements.xml index 956b603..d3e597f 100644 Binary files a/samltest/data/saml2/core/impl/EvidenceChildElements.xml and b/samltest/data/saml2/core/impl/EvidenceChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/Issuer.xml b/samltest/data/saml2/core/impl/Issuer.xml index 5dd24ae..5dd303a 100644 Binary files a/samltest/data/saml2/core/impl/Issuer.xml and b/samltest/data/saml2/core/impl/Issuer.xml differ diff --git a/samltest/data/saml2/core/impl/IssuerOptionalAttributes.xml b/samltest/data/saml2/core/impl/IssuerOptionalAttributes.xml new file mode 100644 index 0000000..3cc35ae Binary files /dev/null and b/samltest/data/saml2/core/impl/IssuerOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/KeyInfoConfirmationDataType.xml b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataType.xml new file mode 100644 index 0000000..db780d2 Binary files /dev/null and b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataType.xml differ diff --git a/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml new file mode 100644 index 0000000..9002fbd Binary files /dev/null and b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml new file mode 100644 index 0000000..10546cb Binary files /dev/null and b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/NameID.xml b/samltest/data/saml2/core/impl/NameID.xml index bccde84..cef35e8 100644 Binary files a/samltest/data/saml2/core/impl/NameID.xml and b/samltest/data/saml2/core/impl/NameID.xml differ diff --git a/samltest/data/saml2/core/impl/NameIDOptionalAttributes.xml b/samltest/data/saml2/core/impl/NameIDOptionalAttributes.xml index 405c31f..8af601f 100644 Binary files a/samltest/data/saml2/core/impl/NameIDOptionalAttributes.xml and b/samltest/data/saml2/core/impl/NameIDOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/NameIDType.xml b/samltest/data/saml2/core/impl/NameIDType.xml new file mode 100644 index 0000000..b5a802b Binary files /dev/null and b/samltest/data/saml2/core/impl/NameIDType.xml differ diff --git a/samltest/data/saml2/core/impl/NameIDTypeOptionalAttributes.xml b/samltest/data/saml2/core/impl/NameIDTypeOptionalAttributes.xml new file mode 100644 index 0000000..cd6bcc0 Binary files /dev/null and b/samltest/data/saml2/core/impl/NameIDTypeOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/OneTimeUse.xml b/samltest/data/saml2/core/impl/OneTimeUse.xml index c77061c..8f7d3c4 100644 Binary files a/samltest/data/saml2/core/impl/OneTimeUse.xml and b/samltest/data/saml2/core/impl/OneTimeUse.xml differ diff --git a/samltest/data/saml2/core/impl/ProxyRestriction.xml b/samltest/data/saml2/core/impl/ProxyRestriction.xml index e1a79e9..3827d49 100644 Binary files a/samltest/data/saml2/core/impl/ProxyRestriction.xml and b/samltest/data/saml2/core/impl/ProxyRestriction.xml differ diff --git a/samltest/data/saml2/core/impl/ProxyRestrictionChildElements.xml b/samltest/data/saml2/core/impl/ProxyRestrictionChildElements.xml index fc39669..97c16c6 100644 Binary files a/samltest/data/saml2/core/impl/ProxyRestrictionChildElements.xml and b/samltest/data/saml2/core/impl/ProxyRestrictionChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/ProxyRestrictionOptionalAttributes.xml b/samltest/data/saml2/core/impl/ProxyRestrictionOptionalAttributes.xml new file mode 100644 index 0000000..1f4903e Binary files /dev/null and b/samltest/data/saml2/core/impl/ProxyRestrictionOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/Subject.xml b/samltest/data/saml2/core/impl/Subject.xml index 3f53fe2..22f301e 100644 Binary files a/samltest/data/saml2/core/impl/Subject.xml and b/samltest/data/saml2/core/impl/Subject.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectChildElements.xml b/samltest/data/saml2/core/impl/SubjectChildElements.xml index c60a5ad..7864e11 100644 Binary files a/samltest/data/saml2/core/impl/SubjectChildElements.xml and b/samltest/data/saml2/core/impl/SubjectChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectConfirmation.xml b/samltest/data/saml2/core/impl/SubjectConfirmation.xml index a7951db..f8ae526 100644 Binary files a/samltest/data/saml2/core/impl/SubjectConfirmation.xml and b/samltest/data/saml2/core/impl/SubjectConfirmation.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectConfirmationChildElements.xml b/samltest/data/saml2/core/impl/SubjectConfirmationChildElements.xml index feacd77..0983bd0 100644 Binary files a/samltest/data/saml2/core/impl/SubjectConfirmationChildElements.xml and b/samltest/data/saml2/core/impl/SubjectConfirmationChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectConfirmationData.xml b/samltest/data/saml2/core/impl/SubjectConfirmationData.xml index 5c88556..1e894aa 100644 Binary files a/samltest/data/saml2/core/impl/SubjectConfirmationData.xml and b/samltest/data/saml2/core/impl/SubjectConfirmationData.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectConfirmationDataChildElements.xml b/samltest/data/saml2/core/impl/SubjectConfirmationDataChildElements.xml new file mode 100644 index 0000000..1e894aa Binary files /dev/null and b/samltest/data/saml2/core/impl/SubjectConfirmationDataChildElements.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml b/samltest/data/saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml index 615f8cf..f664011 100644 Binary files a/samltest/data/saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml and b/samltest/data/saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectLocality.xml b/samltest/data/saml2/core/impl/SubjectLocality.xml index 77d8d38..e5c6072 100644 Binary files a/samltest/data/saml2/core/impl/SubjectLocality.xml and b/samltest/data/saml2/core/impl/SubjectLocality.xml differ diff --git a/samltest/data/saml2/core/impl/SubjectLocalityOptionalAttributes.xml b/samltest/data/saml2/core/impl/SubjectLocalityOptionalAttributes.xml index db678ff..12c2e98 100644 Binary files a/samltest/data/saml2/core/impl/SubjectLocalityOptionalAttributes.xml and b/samltest/data/saml2/core/impl/SubjectLocalityOptionalAttributes.xml differ diff --git a/samltest/internal.h b/samltest/internal.h index 664ab40..a49c55f 100644 --- a/samltest/internal.h +++ b/samltest/internal.h @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -126,3 +128,120 @@ public: if (expectedChildElementsDOM) expectedChildElementsDOM->release(); } }; + +class SAMLObjectValidatorBaseTestCase : virtual public SAMLObjectBaseTestCase { + + public: + SAMLObjectValidatorBaseTestCase() : target(NULL), targetQName(NULL), builder(NULL), validator(NULL) {} + + virtual ~SAMLObjectValidatorBaseTestCase() { + delete validator; + } + + protected: + /** The primary XMLObject which will be the target of a given test run */ + XMLObject* target; + + /** QName of the object to be tested */ + QName targetQName; + + /** Builder for XMLObjects of type targetQName */ + const XMLObjectBuilder* builder; + + /** Validator for the type corresponding to the test target */ + Validator* validator; + + /** Subclasses should override to populate required elements and attributes */ + virtual void populateRequiredData() { } + + /** + * Asserts that the validation of default test XMLObject target + * was successful, as expected. + * + * @param message + */ + void assertValidationPass(const char* message) { + assertValidationPass(message, target); + } + + /** + * Asserts that the validation of the specified XMLObject target + * was successful, as expected. + * + * @param message + * @param validateTarget + */ + void assertValidationPass(const char* message, XMLObject* validateTarget) { + try { + validator->validate(validateTarget); + } catch (ValidationException &e) { + TS_TRACE(message); + TS_TRACE("Expected success, but validation failure raised following ValidationException: "); + TS_FAIL(e.getMessage()); + } + } + + /** + * Asserts that the validation of the default test XMLObject target + * failed, as expected. + * + * @param message + */ + void assertValidationFail(const char* message) { + assertValidationFail(message, target); + } + + /** + * Asserts that the validation of the specified XMLObject target + * failed, as expected. + * + * @param message + * @param validateTarget + */ + void assertValidationFail(const char* message, XMLObject* validateTarget) { + try { + validator->validate(validateTarget); + TS_TRACE(message); + TS_FAIL("Validation success, expected failure to raise ValidationException"); + } catch (ValidationException &e) { + } + } + + /** + * Build an XMLObject based on the specified QName + * + * @param targetQName QName of the type of object to build + * @returns new XMLObject of type targetQName + */ + XMLObject* buildXMLObject(QName &targetQName) { + // Create the builder on the first request only, for efficiency + if (builder == NULL) { + builder = XMLObjectBuilder::getBuilder(targetQName); + TSM_ASSERT("Unable to retrieve builder for object QName: " + targetQName.toString(), builder!=NULL); + } + return builder->buildObject(targetQName.getNamespaceURI(), targetQName.getLocalPart(), targetQName.getPrefix()); + + } + + public: + + void setUp() { + SAMLObjectBaseTestCase::setUp(); + + TSM_ASSERT("targetQName was empty", targetQName.hasLocalPart()); + + TSM_ASSERT("validator was null", validator!=NULL); + + target = buildXMLObject(targetQName); + TSM_ASSERT("XMLObject target was NULL", target!=NULL); + populateRequiredData(); + } + + void tearDown() { + delete target; + target=NULL; + SAMLObjectBaseTestCase::tearDown(); + } + +}; + diff --git a/samltest/saml2/core/impl/Action20Test.h b/samltest/saml2/core/impl/Action20Test.h new file mode 100644 index 0000000..910a990 --- /dev/null +++ b/samltest/saml2/core/impl/Action20Test.h @@ -0,0 +1,61 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Action20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNamespace; + XMLCh* expectedContent; + +public: + void setUp() { + expectedNamespace = XMLString::transcode("urn:string:namespace"); + expectedContent = XMLString::transcode("someActionName"); + + singleElementFile = data_path + "saml2/core/impl/Action.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNamespace); + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Action* action = dynamic_cast(xo.get()); + TS_ASSERT(action!=NULL); + + assertEquals("Element content", expectedContent, action->getAction()); + assertEquals("Namespace attribute", expectedNamespace, action->getNamespace()); + } + + + void testSingleElementMarshall() { + Action* action = ActionBuilder::buildAction(); + TS_ASSERT(action!=NULL); + + action->setAction(expectedContent); + action->setNamespace(expectedNamespace); + assertEquals(expectedDOM, action); + } + +}; diff --git a/samltest/saml2/core/impl/Advice20Test.h b/samltest/saml2/core/impl/Advice20Test.h new file mode 100644 index 0000000..66e0c41 --- /dev/null +++ b/samltest/saml2/core/impl/Advice20Test.h @@ -0,0 +1,89 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Advice20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +//TODO test with some non-SAML Other children + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Advice.xml"; + childElementsFile = data_path + "saml2/core/impl/AdviceChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Advice* advice = dynamic_cast(xo.get()); + TS_ASSERT(advice!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, advice->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 0, advice->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 0, advice->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, advice->getEncryptedAssertions().size()); + TSM_ASSERT_EQUALS("# of Other child elements", 0, advice->getOthers().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Advice* advice= dynamic_cast(xo.get()); + TS_ASSERT(advice!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, advice->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 2, advice->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 2, advice->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, advice->getEncryptedAssertions().size()); + TSM_ASSERT_EQUALS("# of Other child elements", 0, advice->getOthers().size()); + } + + void testSingleElementMarshall() { + Advice* advice=AdviceBuilder::buildAdvice(); + assertEquals(expectedDOM, advice); + } + + void testChildElementsMarshall() { + Advice* advice=AdviceBuilder::buildAdvice(); + + Assertion* assertion1 = AssertionBuilder::buildAssertion(); + assertion1->setID(XMLString::transcode("abc123")); + assertion1->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + Assertion* assertion2 = AssertionBuilder::buildAssertion(); + assertion2->setID(XMLString::transcode("def456")); + assertion2->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + advice->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + advice->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + advice->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + advice->getAssertions().push_back(assertion1); + advice->getEncryptedAssertions().push_back(EncryptedAssertionBuilder::buildEncryptedAssertion()); + advice->getAssertions().push_back(assertion2); + assertEquals(expectedChildElementsDOM, advice); + } + +}; diff --git a/samltest/saml2/core/impl/Assertion20Test.h b/samltest/saml2/core/impl/Assertion20Test.h new file mode 100644 index 0000000..4bd3ddb --- /dev/null +++ b/samltest/saml2/core/impl/Assertion20Test.h @@ -0,0 +1,135 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Assertion20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + const XMLCh* expectedVersion; + XMLCh* expectedID; + DateTime* expectedIssueInstant; + +public: + void setUp() { + expectedVersion = SAMLConstants::SAML20_VERSION; + expectedID = XMLString::transcode("abc123"); + expectedIssueInstant = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedIssueInstant->parseDateTime(); + + + singleElementFile = data_path + "saml2/core/impl/Assertion.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AssertionOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AssertionChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedIssueInstant; + XMLString::release(&expectedID); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Assertion* assertion = dynamic_cast(xo.get()); + TS_ASSERT(assertion!=NULL); + + assertEquals("ID attribute", expectedID, assertion->getID()); + assertEquals("Version attribute", expectedVersion, assertion->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion->getIssueInstant()->getEpoch()); + + TS_ASSERT(assertion->getIssuer()==NULL); + TS_ASSERT(assertion->getSignature()==NULL); + TS_ASSERT(assertion->getSubject()==NULL); + TS_ASSERT(assertion->getConditions()==NULL); + TS_ASSERT(assertion->getAdvice()==NULL); + + TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); + TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 0, assertion->getAuthnStatements().size()); + TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 0, assertion->getAttributeStatements().size()); + TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 0, assertion->getAuthzDecisionStatements().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Assertion* assertion= dynamic_cast(xo.get()); + TS_ASSERT(assertion!=NULL); + + assertEquals("ID attribute", expectedID, assertion->getID()); + assertEquals("Version attribute", expectedVersion, assertion->getVersion()); + TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), assertion->getIssueInstant()->getEpoch()); + + TS_ASSERT(assertion->getIssuer()!=NULL); + TS_ASSERT(assertion->getSignature()==NULL); + TS_ASSERT(assertion->getSubject()!=NULL); + TS_ASSERT(assertion->getConditions()!=NULL); + TS_ASSERT(assertion->getAdvice()!=NULL); + + TSM_ASSERT_EQUALS("# of Statement child elements", 0, assertion->getStatements().size()); + TSM_ASSERT_EQUALS("# of AuthnStatement child elements", 1, assertion->getAuthnStatements().size()); + TSM_ASSERT_EQUALS("# of AttributeStatement child elements", 3, assertion->getAttributeStatements().size()); + TSM_ASSERT_EQUALS("# of AuthzDecisionStatement child elements", 2, assertion->getAuthzDecisionStatements().size()); + } + + void testSingleElementMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertEquals(expectedDOM, assertion); + } + + void testChildElementsMarshall() { + Assertion* assertion=AssertionBuilder::buildAssertion(); + assertion->setID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setIssuer(IssuerBuilder::buildIssuer()); + assertion->setSubject(SubjectBuilder::buildSubject()); + assertion->setConditions(ConditionsBuilder::buildConditions()); + assertion->setAdvice(AdviceBuilder::buildAdvice()); + + //Test storing children as their direct type + assertion->getAuthnStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); + assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getAuthzDecisionStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getAttributeStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertEquals(expectedChildElementsDOM, assertion); + + // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed + assertion=NULL; + assertion=AssertionBuilder::buildAssertion(); + assertion->setID(expectedID); + assertion->setIssueInstant(expectedIssueInstant); + assertion->setIssuer(IssuerBuilder::buildIssuer()); + assertion->setSubject(SubjectBuilder::buildSubject()); + assertion->setConditions(ConditionsBuilder::buildConditions()); + assertion->setAdvice(AdviceBuilder::buildAdvice()); + + //Test storing children as a Statement (each is a derived type of StatementAbstractType) + assertion->getStatements().push_back(AuthnStatementBuilder::buildAuthnStatement()); + assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getStatements().push_back(AuthzDecisionStatementBuilder::buildAuthzDecisionStatement()); + assertion->getStatements().push_back(AttributeStatementBuilder::buildAttributeStatement()); + assertEquals(expectedChildElementsDOM, assertion); + } + +}; diff --git a/samltest/saml2/core/impl/AssertionIDRef20Test.h b/samltest/saml2/core/impl/AssertionIDRef20Test.h new file mode 100644 index 0000000..ab78cef --- /dev/null +++ b/samltest/saml2/core/impl/AssertionIDRef20Test.h @@ -0,0 +1,51 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class AssertionIDRef20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("assertion ID"); + singleElementFile = data_path + "saml2/core/impl/AssertionIDRef.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AssertionIDRef* idref = dynamic_cast(xo.get()); + TS_ASSERT(idref!=NULL); + assertEquals("AssertionIDRef text content", expectedContent, idref->getAssertionID()); + } + + void testSingleElementMarshall() { + AssertionIDRef * idref = AssertionIDRefBuilder::buildAssertionIDRef(); + idref->setAssertionID(expectedContent); + assertEquals(expectedDOM, idref); + } + + +}; diff --git a/samltest/saml2/core/impl/AssertionURIRef20Test.h b/samltest/saml2/core/impl/AssertionURIRef20Test.h new file mode 100644 index 0000000..df02d0e --- /dev/null +++ b/samltest/saml2/core/impl/AssertionURIRef20Test.h @@ -0,0 +1,51 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class AssertionURIRef20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("assertion URI"); + singleElementFile = data_path + "saml2/core/impl/AssertionURIRef.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AssertionURIRef* uriref = dynamic_cast(xo.get()); + TS_ASSERT(uriref!=NULL); + assertEquals("AssertionURIRef text content", expectedContent, uriref->getAssertionURI()); + } + + void testSingleElementMarshall() { + AssertionURIRef * uriref = AssertionURIRefBuilder::buildAssertionURIRef(); + uriref->setAssertionURI(expectedContent); + assertEquals(expectedDOM, uriref); + } + + +}; diff --git a/samltest/saml2/core/impl/Attribute20Test.h b/samltest/saml2/core/impl/Attribute20Test.h new file mode 100644 index 0000000..18e37c6 --- /dev/null +++ b/samltest/saml2/core/impl/Attribute20Test.h @@ -0,0 +1,107 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Attribute20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedName; + XMLCh* expectedNameFormat; + XMLCh* expectedFriendlyName; + +public: + void setUp() { + expectedName = XMLString::transcode("attribName"); + expectedNameFormat = XMLString::transcode("urn:string:format"); + expectedFriendlyName = XMLString::transcode("Attribute Name"); + + singleElementFile = data_path + "saml2/core/impl/Attribute.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AttributeOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AttributeChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedName); + XMLString::release(&expectedNameFormat); + XMLString::release(&expectedFriendlyName); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Attribute* attribute = dynamic_cast(xo.get()); + TS_ASSERT(attribute!=NULL); + + assertEquals("Name attribute", expectedName, attribute->getName()); + TS_ASSERT(attribute->getNameFormat()==NULL); + TS_ASSERT(attribute->getFriendlyName()==NULL); + + TSM_ASSERT_EQUALS("# of AttributeValue child elements", 0, attribute->getAttributeValues().size()); + + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Attribute* attribute = dynamic_cast(xo.get()); + TS_ASSERT(attribute!=NULL); + + assertEquals("Name attribute", expectedName, attribute->getName()); + assertEquals("NameFormat attribute", expectedNameFormat, attribute->getNameFormat()); + assertEquals("FriendlyName attribute", expectedFriendlyName, attribute->getFriendlyName()); + + TSM_ASSERT_EQUALS("# of AttributeValue child elements", 0, attribute->getAttributeValues().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Attribute* attribute= dynamic_cast(xo.get()); + TS_ASSERT(attribute!=NULL); + + TS_ASSERT(attribute->getName()==NULL); + TS_ASSERT(attribute->getNameFormat()==NULL); + TS_ASSERT(attribute->getFriendlyName()==NULL); + + TSM_ASSERT_EQUALS("# of AttributeValue child elements", 3, attribute->getAttributeValues().size()); + + } + + void testSingleElementMarshall() { + Attribute* attribute=AttributeBuilder::buildAttribute(); + attribute->setName(expectedName); + assertEquals(expectedDOM, attribute); + } + + void testSingleElementOptionalAttributesMarshall() { + Attribute* attribute=AttributeBuilder::buildAttribute(); + attribute->setName(expectedName); + attribute->setNameFormat(expectedNameFormat); + attribute->setFriendlyName(expectedFriendlyName); + assertEquals(expectedOptionalAttributesDOM, attribute); + } + + void testChildElementsMarshall() { + Attribute* attribute=AttributeBuilder::buildAttribute(); + attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); + attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); + attribute->getAttributeValues().push_back(AttributeValueBuilder::buildAttributeValue()); + assertEquals(expectedChildElementsDOM, attribute); + } + +}; diff --git a/samltest/saml2/core/impl/AttributeStatement20Test.h b/samltest/saml2/core/impl/AttributeStatement20Test.h new file mode 100644 index 0000000..830d557 --- /dev/null +++ b/samltest/saml2/core/impl/AttributeStatement20Test.h @@ -0,0 +1,69 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AttributeStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/AttributeStatement.xml"; + childElementsFile = data_path + "saml2/core/impl/AttributeStatementChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AttributeStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("# of Attribute child elements", 0, statement->getAttributes().size()); + TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 0, statement->getEncryptedAttributes().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AttributeStatement* statement= dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("# of Attribute child elements", 3, statement->getAttributes().size()); + TSM_ASSERT_EQUALS("# of EncryptedAttribute child elements", 1, statement->getEncryptedAttributes().size()); + } + + void testSingleElementMarshall() { + AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement(); + assertEquals(expectedDOM, statement); + } + + void testChildElementsMarshall() { + AttributeStatement* statement=AttributeStatementBuilder::buildAttributeStatement(); + + statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); + statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); + statement->getEncryptedAttributes().push_back(EncryptedAttributeBuilder::buildEncryptedAttribute()); + statement->getAttributes().push_back(AttributeBuilder::buildAttribute()); + assertEquals(expectedChildElementsDOM, statement); + } + +}; diff --git a/samltest/saml2/core/impl/Audience20Test.h b/samltest/saml2/core/impl/Audience20Test.h new file mode 100644 index 0000000..22e4098 --- /dev/null +++ b/samltest/saml2/core/impl/Audience20Test.h @@ -0,0 +1,51 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class Audience20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("audience URI"); + singleElementFile = data_path + "saml2/core/impl/Audience.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Audience* audience = dynamic_cast(xo.get()); + TS_ASSERT(audience!=NULL); + assertEquals("Audience text content", expectedContent, audience->getAudienceURI()); + } + + void testSingleElementMarshall() { + Audience * audience = AudienceBuilder::buildAudience(); + audience->setAudienceURI(expectedContent); + assertEquals(expectedDOM, audience); + } + + +}; diff --git a/samltest/saml2/core/impl/AudienceRestriction20Test.h b/samltest/saml2/core/impl/AudienceRestriction20Test.h new file mode 100644 index 0000000..dedd2e5 --- /dev/null +++ b/samltest/saml2/core/impl/AudienceRestriction20Test.h @@ -0,0 +1,64 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AudienceRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/AudienceRestriction.xml"; + childElementsFile = data_path + "saml2/core/impl/AudienceRestrictionChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AudienceRestriction* ar = dynamic_cast(xo.get()); + TS_ASSERT(ar!=NULL); + + TSM_ASSERT_EQUALS("# of Audience child elements", 0, ar->getAudiences().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AudienceRestriction* ar= dynamic_cast(xo.get()); + TS_ASSERT(ar!=NULL); + + TSM_ASSERT_EQUALS("# of Audience child elements", 2, ar->getAudiences().size()); + } + + void testSingleElementMarshall() { + AudienceRestriction* ar=AudienceRestrictionBuilder::buildAudienceRestriction(); + assertEquals(expectedDOM, ar); + } + + void testChildElementsMarshall() { + AudienceRestriction* ar=AudienceRestrictionBuilder::buildAudienceRestriction(); + ar->getAudiences().push_back(AudienceBuilder::buildAudience()); + ar->getAudiences().push_back(AudienceBuilder::buildAudience()); + assertEquals(expectedChildElementsDOM, ar); + } + +}; diff --git a/samltest/saml2/core/impl/AuthenticatingAuthority20Test.h b/samltest/saml2/core/impl/AuthenticatingAuthority20Test.h new file mode 100644 index 0000000..cbffa1b --- /dev/null +++ b/samltest/saml2/core/impl/AuthenticatingAuthority20Test.h @@ -0,0 +1,51 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class AuthenticatingAuthority20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("authenticating URI"); + singleElementFile = data_path + "saml2/core/impl/AuthenticatingAuthority.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthenticatingAuthority* aa = dynamic_cast(xo.get()); + TS_ASSERT(aa!=NULL); + assertEquals("AuthenticatingAuthority text content", expectedContent, aa->getID()); + } + + void testSingleElementMarshall() { + AuthenticatingAuthority * aa = AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority(); + aa->setID(expectedContent); + assertEquals(expectedDOM, aa); + } + + +}; diff --git a/samltest/saml2/core/impl/AuthnContext20Test.h b/samltest/saml2/core/impl/AuthnContext20Test.h new file mode 100644 index 0000000..360d144 --- /dev/null +++ b/samltest/saml2/core/impl/AuthnContext20Test.h @@ -0,0 +1,72 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AuthnContext20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/AuthnContext.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthnContextChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnContext* ac = dynamic_cast(xo.get()); + TS_ASSERT(ac!=NULL); + + TS_ASSERT(ac->getAuthnContextClassRef()==NULL); + TS_ASSERT(ac->getAuthnContextDecl()==NULL); + TS_ASSERT(ac->getAuthnContextDeclRef()==NULL); + TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 0, ac->getAuthenticatingAuthoritys().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthnContext* ac= dynamic_cast(xo.get()); + TS_ASSERT(ac!=NULL); + + TS_ASSERT(ac->getAuthnContextClassRef()!=NULL); + TS_ASSERT(ac->getAuthnContextDecl()==NULL); + TS_ASSERT(ac->getAuthnContextDeclRef()!=NULL); + TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 2, ac->getAuthenticatingAuthoritys().size()); + } + + void testSingleElementMarshall() { + AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); + assertEquals(expectedDOM, ac); + } + + void testChildElementsMarshall() { + AuthnContext* ac=AuthnContextBuilder::buildAuthnContext(); + ac->setAuthnContextClassRef(AuthnContextClassRefBuilder::buildAuthnContextClassRef()); + ac->setAuthnContextDeclRef(AuthnContextDeclRefBuilder::buildAuthnContextDeclRef()); + ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority()); + ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority()); + assertEquals(expectedChildElementsDOM, ac); + } + +}; diff --git a/samltest/saml2/core/impl/AuthnContextClassRef20Test.h b/samltest/saml2/core/impl/AuthnContextClassRef20Test.h new file mode 100644 index 0000000..56a4084 --- /dev/null +++ b/samltest/saml2/core/impl/AuthnContextClassRef20Test.h @@ -0,0 +1,51 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class AuthnContextClassRef20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("class reference"); + singleElementFile = data_path + "saml2/core/impl/AuthnContextClassRef.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnContextClassRef* classref = dynamic_cast(xo.get()); + TS_ASSERT(classref!=NULL); + assertEquals("AuthnContextClassRef text content", expectedContent, classref->getReference()); + } + + void testSingleElementMarshall() { + AuthnContextClassRef * classref = AuthnContextClassRefBuilder::buildAuthnContextClassRef(); + classref->setReference(expectedContent); + assertEquals(expectedDOM, classref); + } + + +}; diff --git a/samltest/saml2/core/impl/AuthnContextDeclRef20Test.h b/samltest/saml2/core/impl/AuthnContextDeclRef20Test.h new file mode 100644 index 0000000..c912811 --- /dev/null +++ b/samltest/saml2/core/impl/AuthnContextDeclRef20Test.h @@ -0,0 +1,51 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class AuthnContextDeclRef20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedContent; + +public: + void setUp() { + expectedContent=XMLString::transcode("declaration reference"); + singleElementFile = data_path + "saml2/core/impl/AuthnContextDeclRef.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnContextDeclRef* declref = dynamic_cast(xo.get()); + TS_ASSERT(declref!=NULL); + assertEquals("AuthnContextDeclRef text content", expectedContent, declref->getReference()); + } + + void testSingleElementMarshall() { + AuthnContextDeclRef * declref = AuthnContextDeclRefBuilder::buildAuthnContextDeclRef(); + declref->setReference(expectedContent); + assertEquals(expectedDOM, declref); + } + + +}; diff --git a/samltest/saml2/core/impl/AuthnStatement20Test.h b/samltest/saml2/core/impl/AuthnStatement20Test.h new file mode 100644 index 0000000..e4223be --- /dev/null +++ b/samltest/saml2/core/impl/AuthnStatement20Test.h @@ -0,0 +1,111 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AuthnStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedAuthnInstant; + XMLCh* expectedSessionIndex; + DateTime* expectedSessionNotOnOrAfter; + +public: + void setUp() { + expectedAuthnInstant = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedAuthnInstant->parseDateTime(); + expectedSessionIndex = (XMLString::transcode("abc123")); + expectedSessionNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedSessionNotOnOrAfter->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/AuthnStatement.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/AuthnStatementOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthnStatementChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedAuthnInstant; + XMLString::release(&expectedSessionIndex); + delete expectedSessionNotOnOrAfter; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthnStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("AuthnInstant attribute", expectedAuthnInstant->getEpoch(), statement->getAuthnInstant()->getEpoch()); + TS_ASSERT(statement->getSessionIndex()==NULL); + TS_ASSERT(statement->getSessionNotOnOrAfter()==NULL); + + TS_ASSERT(statement->getSubjectLocality()==NULL); + TS_ASSERT(statement->getAuthnContext()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthnStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TSM_ASSERT_EQUALS("AuthnInstant attribute", expectedAuthnInstant->getEpoch(), statement->getAuthnInstant()->getEpoch()); + assertEquals("SessionIndex attribute", expectedSessionIndex, statement->getSessionIndex()); + TSM_ASSERT_EQUALS("SessionNotOnOrAfter attribute", expectedSessionNotOnOrAfter->getEpoch(), statement->getSessionNotOnOrAfter()->getEpoch()); + + TS_ASSERT(statement->getSubjectLocality()==NULL); + TS_ASSERT(statement->getAuthnContext()==NULL); + + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthnStatement* statement= dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + TS_ASSERT(statement->getAuthnInstant()==NULL); + TS_ASSERT(statement->getSessionIndex()==NULL); + TS_ASSERT(statement->getSessionNotOnOrAfter()==NULL); + + TS_ASSERT(statement->getSubjectLocality()!=NULL); + TS_ASSERT(statement->getAuthnContext()!=NULL); + + } + + void testSingleElementMarshall() { + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setAuthnInstant(expectedAuthnInstant); + assertEquals(expectedDOM, statement); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setAuthnInstant(expectedAuthnInstant); + statement->setSessionIndex(expectedSessionIndex); + statement->setSessionNotOnOrAfter(expectedSessionNotOnOrAfter); + assertEquals(expectedOptionalAttributesDOM, statement); + } + + void testChildElementsMarshall() { + AuthnStatement* statement=AuthnStatementBuilder::buildAuthnStatement(); + statement->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); + statement->setAuthnContext(AuthnContextBuilder::buildAuthnContext()); + assertEquals(expectedChildElementsDOM, statement); + } + +}; diff --git a/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h b/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h new file mode 100644 index 0000000..fb0d5fd --- /dev/null +++ b/samltest/saml2/core/impl/AuthzDecisionStatement20Test.h @@ -0,0 +1,82 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class AuthzDecisionStatement20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedResource; + const XMLCh* expectedDecision; + +public: + void setUp() { + expectedResource = XMLString::transcode("urn:string:resource"); + expectedDecision = AuthzDecisionStatement::DECISION_PERMIT; + + singleElementFile = data_path + "saml2/core/impl/AuthzDecisionStatement.xml"; + childElementsFile = data_path + "saml2/core/impl/AuthzDecisionStatementChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedResource); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthzDecisionStatement* statement = dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + assertEquals("Resource attribute", expectedResource, statement->getResource()); + assertEquals("Decision attribute", expectedDecision, statement->getDecision()); + + TSM_ASSERT_EQUALS("# of Action child elements", 0, statement->getActions().size()); + TS_ASSERT(statement->getEvidence()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthzDecisionStatement* statement= dynamic_cast(xo.get()); + TS_ASSERT(statement!=NULL); + + assertEquals("Resource attribute", NULL, statement->getResource()); + assertEquals("Decision attribute", NULL, statement->getDecision()); + + TSM_ASSERT_EQUALS("# of Action child elements", 3, statement->getActions().size()); + TS_ASSERT(statement->getEvidence()!=NULL); + } + + void testSingleElementMarshall() { + AuthzDecisionStatement* statement=AuthzDecisionStatementBuilder::buildAuthzDecisionStatement(); + statement->setResource(expectedResource); + statement->setDecision(expectedDecision); + assertEquals(expectedDOM, statement); + } + + void testChildElementsMarshall() { + AuthzDecisionStatement* statement=AuthzDecisionStatementBuilder::buildAuthzDecisionStatement(); + statement->getActions().push_back(ActionBuilder::buildAction()); + statement->getActions().push_back(ActionBuilder::buildAction()); + statement->getActions().push_back(ActionBuilder::buildAction()); + statement->setEvidence(EvidenceBuilder::buildEvidence()); + assertEquals(expectedChildElementsDOM, statement); + } + +}; diff --git a/samltest/saml2/core/impl/Conditions20Test.h b/samltest/saml2/core/impl/Conditions20Test.h new file mode 100644 index 0000000..e144e5a --- /dev/null +++ b/samltest/saml2/core/impl/Conditions20Test.h @@ -0,0 +1,127 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Conditions20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedNotBefore; + DateTime* expectedNotOnOrAfter; + +public: + void setUp() { + expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedNotBefore->parseDateTime(); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedNotOnOrAfter->parseDateTime(); + + singleElementFile = data_path + "saml2/core/impl/Conditions.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ConditionsOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ConditionsChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedNotBefore; + delete expectedNotOnOrAfter; + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Conditions* conditions = dynamic_cast(xo.get()); + TS_ASSERT(conditions!=NULL); + + + TS_ASSERT(conditions->getNotBefore()==NULL); + TS_ASSERT(conditions->getNotOnOrAfter()==NULL); + + TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 0, conditions->getAudienceRestrictions().size()); + TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 0, conditions->getOneTimeUses().size()); + TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 0, conditions->getProxyRestrictions().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Conditions* conditions = dynamic_cast(xo.get()); + TS_ASSERT(conditions!=NULL); + + TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), conditions->getNotBefore()->getEpoch()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), conditions->getNotOnOrAfter()->getEpoch()); + + TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 0, conditions->getAudienceRestrictions().size()); + TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 0, conditions->getOneTimeUses().size()); + TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 0, conditions->getProxyRestrictions().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Conditions* conditions= dynamic_cast(xo.get()); + TS_ASSERT(conditions!=NULL); + + TS_ASSERT(conditions->getNotBefore()==NULL); + TS_ASSERT(conditions->getNotOnOrAfter()==NULL); + + TSM_ASSERT_EQUALS("# of Condition child elements", 0, conditions->getConditions().size()); + TSM_ASSERT_EQUALS("# of AudienceRestriction child elements", 3, conditions->getAudienceRestrictions().size()); + TSM_ASSERT_EQUALS("# of OneTimeUse child elements", 1, conditions->getOneTimeUses().size()); + TSM_ASSERT_EQUALS("# of ProxyRestriction child elements", 2, conditions->getProxyRestrictions().size()); + } + + void testSingleElementMarshall() { + Conditions* conditions=ConditionsBuilder::buildConditions(); + assertEquals(expectedDOM, conditions); + } + + void testSingleElementOptionalAttributesMarshall() { + Conditions* conditions=ConditionsBuilder::buildConditions(); + conditions->setNotBefore(expectedNotBefore); + conditions->setNotOnOrAfter(expectedNotOnOrAfter); + assertEquals(expectedOptionalAttributesDOM, conditions); + } + + void testChildElementsMarshall() { + Conditions* conditions=ConditionsBuilder::buildConditions(); + + //Test storing children as their direct type + conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + conditions->getAudienceRestrictions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getOneTimeUses().push_back(OneTimeUseBuilder::buildOneTimeUse()); + conditions->getProxyRestrictions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + assertEquals(expectedChildElementsDOM, conditions); + + // Note: assertEquals() above has already 'delete'-ed the XMLObject* it was passed + conditions=NULL; + conditions=ConditionsBuilder::buildConditions(); + + //Test storing children as a Condition (each is a derived type of ConditionAbstractType) + conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + conditions->getConditions().push_back(AudienceRestrictionBuilder::buildAudienceRestriction()); + conditions->getConditions().push_back(OneTimeUseBuilder::buildOneTimeUse()); + conditions->getConditions().push_back(ProxyRestrictionBuilder::buildProxyRestriction()); + assertEquals(expectedChildElementsDOM, conditions); + } + +}; diff --git a/samltest/saml2/core/impl/Evidence20Test.h b/samltest/saml2/core/impl/Evidence20Test.h new file mode 100644 index 0000000..ae03184 --- /dev/null +++ b/samltest/saml2/core/impl/Evidence20Test.h @@ -0,0 +1,85 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Evidence20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Evidence.xml"; + childElementsFile = data_path + "saml2/core/impl/EvidenceChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Evidence* evidence = dynamic_cast(xo.get()); + TS_ASSERT(evidence!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 0, evidence->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 0, evidence->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 0, evidence->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 0, evidence->getEncryptedAssertions().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Evidence* evidence= dynamic_cast(xo.get()); + TS_ASSERT(evidence!=NULL); + + TSM_ASSERT_EQUALS("# of AssertionIDRef child elements", 3, evidence->getAssertionIDRefs().size()); + TSM_ASSERT_EQUALS("# of AssertionURIRef child elements", 2, evidence->getAssertionURIRefs().size()); + TSM_ASSERT_EQUALS("# of Assertion child elements", 2, evidence->getAssertions().size()); + TSM_ASSERT_EQUALS("# of EncryptedAssertion child elements", 1, evidence->getEncryptedAssertions().size()); + } + + void testSingleElementMarshall() { + Evidence* evidence=EvidenceBuilder::buildEvidence(); + assertEquals(expectedDOM, evidence); + } + + void testChildElementsMarshall() { + Evidence* evidence=EvidenceBuilder::buildEvidence(); + + Assertion* assertion1 = AssertionBuilder::buildAssertion(); + assertion1->setID(XMLString::transcode("abc123")); + assertion1->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + Assertion* assertion2 = AssertionBuilder::buildAssertion(); + assertion2->setID(XMLString::transcode("def456")); + assertion2->setIssueInstant(new DateTime(XMLString::transcode("2006-07-21T22:27:19Z"))); + + evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + evidence->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + evidence->getAssertionIDRefs().push_back(AssertionIDRefBuilder::buildAssertionIDRef()); + evidence->getAssertionURIRefs().push_back(AssertionURIRefBuilder::buildAssertionURIRef()); + evidence->getAssertions().push_back(assertion1); + evidence->getEncryptedAssertions().push_back(EncryptedAssertionBuilder::buildEncryptedAssertion()); + evidence->getAssertions().push_back(assertion2); + assertEquals(expectedChildElementsDOM, evidence); + } + +}; diff --git a/samltest/saml2/core/impl/Issuer20Test.h b/samltest/saml2/core/impl/Issuer20Test.h new file mode 100644 index 0000000..849b436 --- /dev/null +++ b/samltest/saml2/core/impl/Issuer20Test.h @@ -0,0 +1,93 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Issuer20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNameQualifier; + XMLCh* expectedSPNameQualifier; + XMLCh* expectedFormat; + XMLCh* expectedSPProvidedID; + XMLCh* expectedContent; + +public: + void setUp() { + expectedNameQualifier = XMLString::transcode("nq"); + expectedSPNameQualifier = XMLString::transcode("spnq"); + expectedFormat = XMLString::transcode("format"); + expectedSPProvidedID = XMLString::transcode("spID"); + expectedContent = XMLString::transcode("someIssuer"); + + singleElementFile = data_path + "saml2/core/impl/Issuer.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IssuerOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNameQualifier); + XMLString::release(&expectedSPNameQualifier); + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPProvidedID); + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Issuer* issuer = dynamic_cast(xo.get()); + TS_ASSERT(issuer!=NULL); + + assertEquals("Element content", expectedContent, issuer->getName()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + Issuer* issuer = dynamic_cast(xo.get()); + TS_ASSERT(issuer!=NULL); + + assertEquals("NameQualifier attribute", expectedNameQualifier, issuer->getNameQualifier()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, issuer->getSPNameQualifier()); + assertEquals("Format attribute", expectedFormat, issuer->getFormat()); + assertEquals("SPProvidedID attribute", expectedSPProvidedID, issuer->getSPProvidedID()); + assertEquals("Element content", expectedContent, issuer->getName()); + } + + + void testSingleElementMarshall() { + Issuer* issuer = IssuerBuilder::buildIssuer(); + TS_ASSERT(issuer!=NULL); + + issuer->setName(expectedContent); + assertEquals(expectedDOM, issuer); + } + + void testSingleElementOptionalAttributesMarshall() { + Issuer* issuer = IssuerBuilder::buildIssuer(); + TS_ASSERT(issuer!=NULL); + + issuer->setNameQualifier(expectedNameQualifier); + issuer->setSPNameQualifier(expectedSPNameQualifier); + issuer->setFormat(expectedFormat); + issuer->setSPProvidedID(expectedSPProvidedID); + issuer->setName(expectedContent); + assertEquals(expectedOptionalAttributesDOM, issuer); + } + +}; diff --git a/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h b/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h new file mode 100644 index 0000000..f4aefce --- /dev/null +++ b/samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h @@ -0,0 +1,124 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; +using namespace xmlsignature; + +//TODO need testing for ElementProxy and wildcard attributes/elements + +class KeyInfoConfirmationDataType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedNotBefore; + DateTime* expectedNotOnOrAfter; + XMLCh* expectedRecipient; + XMLCh* expectedInResponseTo; + XMLCh* expectedAddress; + +public: + void setUp() { + expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedNotBefore->parseDateTime(); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedNotOnOrAfter->parseDateTime(); + expectedRecipient = (XMLString::transcode("recipient")); + expectedInResponseTo = (XMLString::transcode("inresponse")); + expectedAddress = (XMLString::transcode("address")); + + singleElementFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataType.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedNotBefore; + delete expectedNotOnOrAfter; + XMLString::release(&expectedRecipient); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedAddress); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + KeyInfoConfirmationDataType* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + KeyInfoConfirmationDataType* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch()); + assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient()); + assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo()); + assertEquals("Address attribute", expectedAddress, scd->getAddress()); + TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size()); + + //TODO need to test with some wildcard attributes + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + KeyInfoConfirmationDataType* scd= dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + TSM_ASSERT_EQUALS("# of KeyInfo child elements", 1, scd->getKeyInfos().size()); + + //TODO need to test with some wildcard child elements + } + + void testSingleElementMarshall() { + KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); + assertEquals(expectedDOM, scd); + } + + void testSingleElementOptionalAttributesMarshall() { + KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); + scd->setNotBefore(expectedNotBefore); + scd->setNotOnOrAfter(expectedNotOnOrAfter); + scd->setRecipient(expectedRecipient); + scd->setInResponseTo(expectedInResponseTo); + scd->setAddress(expectedAddress); + //TODO need to test with some wilcard attributes + assertEquals(expectedOptionalAttributesDOM, scd); + } + + void testChildElementsMarshall() { + KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType(); + scd->getKeyInfos().push_back(KeyInfoBuilder::buildKeyInfo()); + //TODO need to test with some wilcard child elements + assertEquals(expectedChildElementsDOM, scd); + } + +}; diff --git a/samltest/saml2/core/impl/NameID20Test.h b/samltest/saml2/core/impl/NameID20Test.h new file mode 100644 index 0000000..6948cab --- /dev/null +++ b/samltest/saml2/core/impl/NameID20Test.h @@ -0,0 +1,93 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class NameID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNameQualifier; + XMLCh* expectedSPNameQualifier; + XMLCh* expectedFormat; + XMLCh* expectedSPProvidedID; + XMLCh* expectedContent; + +public: + void setUp() { + expectedNameQualifier = XMLString::transcode("nq"); + expectedSPNameQualifier = XMLString::transcode("spnq"); + expectedFormat = XMLString::transcode("format"); + expectedSPProvidedID = XMLString::transcode("spID"); + expectedContent = XMLString::transcode("someNameID"); + + singleElementFile = data_path + "saml2/core/impl/NameID.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNameQualifier); + XMLString::release(&expectedSPNameQualifier); + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPProvidedID); + XMLString::release(&expectedContent); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameID* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + assertEquals("Element content", expectedContent, nameid->getName()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameID* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier()); + assertEquals("Format attribute", expectedFormat, nameid->getFormat()); + assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID()); + assertEquals("Element content", expectedContent, nameid->getName()); + } + + + void testSingleElementMarshall() { + NameID* nameid = NameIDBuilder::buildNameID(); + TS_ASSERT(nameid!=NULL); + + nameid->setName(expectedContent); + assertEquals(expectedDOM, nameid); + } + + void testSingleElementOptionalAttributesMarshall() { + NameID* nameid = NameIDBuilder::buildNameID(); + TS_ASSERT(nameid!=NULL); + + nameid->setNameQualifier(expectedNameQualifier); + nameid->setSPNameQualifier(expectedSPNameQualifier); + nameid->setFormat(expectedFormat); + nameid->setSPProvidedID(expectedSPProvidedID); + nameid->setName(expectedContent); + assertEquals(expectedOptionalAttributesDOM, nameid); + } + +}; diff --git a/samltest/saml2/core/impl/NameIDType20Test.h b/samltest/saml2/core/impl/NameIDType20Test.h new file mode 100644 index 0000000..aa87866 --- /dev/null +++ b/samltest/saml2/core/impl/NameIDType20Test.h @@ -0,0 +1,139 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +/* + This tests building an element of type NameIDType with a non-SAML element name and namespace + */ + +class NameIDType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedNameQualifier; + XMLCh* expectedSPNameQualifier; + XMLCh* expectedFormat; + XMLCh* expectedSPProvidedID; + XMLCh* expectedContent; + + //TODO possibly move these up to SAMLObjectBaseTestCase, for use in optional helper methods below + XMLCh* elementName; + XMLCh* elementNS; + XMLCh* elementPrefix; + const XMLCh* typeName; + const XMLCh* typeNS; + const XMLCh* typePrefix; + +public: + void setUp() { + expectedNameQualifier = XMLString::transcode("nq"); + expectedSPNameQualifier = XMLString::transcode("spnq"); + expectedFormat = XMLString::transcode("format"); + expectedSPProvidedID = XMLString::transcode("spID"); + expectedContent = XMLString::transcode("someNameID"); + + elementName = XMLString::transcode("Foo");; + elementNS = XMLString::transcode("http://www.example.org/test"); + elementPrefix = XMLString::transcode("test");; + typeName = NameIDType::TYPE_NAME; + typeNS = SAMLConstants::SAML20_NS; + typePrefix = SAMLConstants::SAML20_PREFIX; + + singleElementFile = data_path + "saml2/core/impl/NameIDType.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDTypeOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedNameQualifier); + XMLString::release(&expectedSPNameQualifier); + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPProvidedID); + XMLString::release(&expectedContent); + XMLString::release(&elementName); + XMLString::release(&elementNS); + XMLString::release(&elementPrefix); + SAMLObjectBaseTestCase::tearDown(); + } + + //TODO possibly move this functionality up to SAMLObjectBaseTestCase, as optional helper method + void checkNameAndType(XMLObject* xo) { + assertEquals("Element name", elementName, xo->getElementQName().getLocalPart()); + assertEquals("Element namespace", elementNS, xo->getElementQName().getNamespaceURI()); + assertEquals("Element namespace prefix", elementPrefix, xo->getElementQName().getPrefix()); + + assertEquals("Schema type name", typeName, xo->getSchemaType()->getLocalPart()); + assertEquals("Schema type namespace", typeNS, xo->getSchemaType()->getNamespaceURI()); + assertEquals("Schema type namespace prefix", typePrefix, xo->getSchemaType()->getPrefix()); + } + + //TODO possibly move this functionality up to SAMLObjectBaseTestCase, as optional helper method + XMLObject * buildObject() { + const XMLObjectBuilder* builder = XMLObjectBuilder::getBuilder(QName(typeNS,typeName)); + QName type(typeNS,typeName,typePrefix); + return builder->buildObject(elementNS, elementName, elementPrefix, &type); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameIDType* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + checkNameAndType(nameid); + + assertEquals("Element content", expectedContent, nameid->getName()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameIDType* nameid = dynamic_cast(xo.get()); + TS_ASSERT(nameid!=NULL); + + checkNameAndType(nameid); + + assertEquals("NameQualifier attribute", expectedNameQualifier, nameid->getNameQualifier()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, nameid->getSPNameQualifier()); + assertEquals("Format attribute", expectedFormat, nameid->getFormat()); + assertEquals("SPProvidedID attribute", expectedSPProvidedID, nameid->getSPProvidedID()); + assertEquals("Element content", expectedContent, nameid->getName()); + } + + + void testSingleElementMarshall() { + NameIDType* nameid = dynamic_cast(buildObject()); + TS_ASSERT(nameid!=NULL); + checkNameAndType(nameid); + + nameid->setName(expectedContent); + assertEquals(expectedDOM, nameid); + } + + void testSingleElementOptionalAttributesMarshall() { + NameIDType* nameid = dynamic_cast(buildObject()); + TS_ASSERT(nameid!=NULL); + checkNameAndType(nameid); + + nameid->setNameQualifier(expectedNameQualifier); + nameid->setSPNameQualifier(expectedSPNameQualifier); + nameid->setFormat(expectedFormat); + nameid->setSPProvidedID(expectedSPProvidedID); + nameid->setName(expectedContent); + assertEquals(expectedOptionalAttributesDOM, nameid); + } + +}; diff --git a/samltest/saml2/core/impl/OneTimeUse20Test.h b/samltest/saml2/core/impl/OneTimeUse20Test.h new file mode 100644 index 0000000..53cfbe6 --- /dev/null +++ b/samltest/saml2/core/impl/OneTimeUse20Test.h @@ -0,0 +1,46 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include + +using namespace opensaml::saml2; + +class OneTimeUse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/OneTimeUse.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + OneTimeUse* otu = dynamic_cast(xo.get()); + TS_ASSERT(otu!=NULL); + } + + void testSingleElementMarshall() { + OneTimeUse * otu = OneTimeUseBuilder::buildOneTimeUse(); + assertEquals(expectedDOM, otu); + } + + +}; diff --git a/samltest/saml2/core/impl/ProxyRestriction20Test.h b/samltest/saml2/core/impl/ProxyRestriction20Test.h new file mode 100644 index 0000000..09416a4 --- /dev/null +++ b/samltest/saml2/core/impl/ProxyRestriction20Test.h @@ -0,0 +1,85 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class ProxyRestriction20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + int expectedCount; + +public: + void setUp() { + expectedCount = 5; + singleElementFile = data_path + "saml2/core/impl/ProxyRestriction.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ProxyRestrictionOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/ProxyRestrictionChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + ProxyRestriction* pr = dynamic_cast(xo.get()); + TS_ASSERT(pr!=NULL); + + TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first); + TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + ProxyRestriction* pr = dynamic_cast(xo.get()); + TS_ASSERT(pr!=NULL); + + TSM_ASSERT_EQUALS("Count attribute presence", true, pr->getCount().first); + TSM_ASSERT_EQUALS("Count attribute value", expectedCount, pr->getCount().second); + TSM_ASSERT_EQUALS("# of Audience child elements", 0, pr->getAudiences().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + ProxyRestriction* pr= dynamic_cast(xo.get()); + TS_ASSERT(pr!=NULL); + + TSM_ASSERT_EQUALS("Count attribute presence", false, pr->getCount().first); + TSM_ASSERT_EQUALS("# of Audience child elements", 2, pr->getAudiences().size()); + } + + void testSingleElementMarshall() { + ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); + assertEquals(expectedDOM, pr); + } + + void testSingleElementOptionalAttributesMarshall() { + ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); + pr->setCount(expectedCount); + assertEquals(expectedOptionalAttributesDOM, pr); + } + + void testChildElementsMarshall() { + ProxyRestriction* pr=ProxyRestrictionBuilder::buildProxyRestriction(); + pr->getAudiences().push_back(AudienceBuilder::buildAudience()); + pr->getAudiences().push_back(AudienceBuilder::buildAudience()); + assertEquals(expectedChildElementsDOM, pr); + } + +}; diff --git a/samltest/saml2/core/impl/Subject20Test.h b/samltest/saml2/core/impl/Subject20Test.h new file mode 100644 index 0000000..36f4ef0 --- /dev/null +++ b/samltest/saml2/core/impl/Subject20Test.h @@ -0,0 +1,71 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class Subject20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + +public: + void setUp() { + singleElementFile = data_path + "saml2/core/impl/Subject.xml"; + childElementsFile = data_path + "saml2/core/impl/SubjectChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + Subject* subject = dynamic_cast(xo.get()); + TS_ASSERT(subject!=NULL); + + TS_ASSERT(subject->getBaseID()==NULL); + TS_ASSERT(subject->getNameID()==NULL); + TS_ASSERT(subject->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 0, subject->getSubjectConfirmations().size()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + Subject* subject= dynamic_cast(xo.get()); + TS_ASSERT(subject!=NULL); + + TS_ASSERT(subject->getBaseID()==NULL); + TS_ASSERT(subject->getNameID()!=NULL); + TS_ASSERT(subject->getEncryptedID()==NULL); + TSM_ASSERT_EQUALS("# of SubjectConfirmation child elements", 2, subject->getSubjectConfirmations().size()); + } + + void testSingleElementMarshall() { + Subject* subject=SubjectBuilder::buildSubject(); + assertEquals(expectedDOM, subject); + } + + void testChildElementsMarshall() { + Subject* subject=SubjectBuilder::buildSubject(); + subject->setNameID(NameIDBuilder::buildNameID()); + subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation()); + subject->getSubjectConfirmations().push_back(SubjectConfirmationBuilder::buildSubjectConfirmation()); + assertEquals(expectedChildElementsDOM, subject); + } + +}; diff --git a/samltest/saml2/core/impl/SubjectConfirmation20Test.h b/samltest/saml2/core/impl/SubjectConfirmation20Test.h new file mode 100644 index 0000000..cc12ece --- /dev/null +++ b/samltest/saml2/core/impl/SubjectConfirmation20Test.h @@ -0,0 +1,77 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class SubjectConfirmation20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedMethod; + +public: + void setUp() { + expectedMethod = XMLString::transcode("urn:string:cm"); + + singleElementFile = data_path + "saml2/core/impl/SubjectConfirmation.xml"; + childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedMethod); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SubjectConfirmation* sc = dynamic_cast(xo.get()); + TS_ASSERT(sc!=NULL); + + assertEquals("Method attribute", expectedMethod, sc->getMethod()); + + TS_ASSERT(sc->getBaseID()==NULL); + TS_ASSERT(sc->getNameID()==NULL); + TS_ASSERT(sc->getEncryptedID()==NULL); + TS_ASSERT(sc->getSubjectConfirmationData()==NULL); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + SubjectConfirmation* sc= dynamic_cast(xo.get()); + TS_ASSERT(sc!=NULL); + + TS_ASSERT(sc->getBaseID()==NULL); + TS_ASSERT(sc->getNameID()!=NULL); + TS_ASSERT(sc->getEncryptedID()==NULL); + TS_ASSERT(sc->getSubjectConfirmationData()!=NULL); + } + + void testSingleElementMarshall() { + SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation(); + sc->setMethod(expectedMethod); + assertEquals(expectedDOM, sc); + } + + void testChildElementsMarshall() { + SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation(); + sc->setNameID(NameIDBuilder::buildNameID()); + sc->setSubjectConfirmationData(SubjectConfirmationDataBuilder::buildSubjectConfirmationData()); + assertEquals(expectedChildElementsDOM, sc); + } + +}; diff --git a/samltest/saml2/core/impl/SubjectConfirmationData20Test.h b/samltest/saml2/core/impl/SubjectConfirmationData20Test.h new file mode 100644 index 0000000..fcf2e0c --- /dev/null +++ b/samltest/saml2/core/impl/SubjectConfirmationData20Test.h @@ -0,0 +1,119 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +//TODO need testing for ElementProxy and wildcard attributes/elements + +class SubjectConfirmationData20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + DateTime* expectedNotBefore; + DateTime* expectedNotOnOrAfter; + XMLCh* expectedRecipient; + XMLCh* expectedInResponseTo; + XMLCh* expectedAddress; + +public: + void setUp() { + expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z")); + expectedNotBefore->parseDateTime(); + expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z")); + expectedNotOnOrAfter->parseDateTime(); + expectedRecipient = (XMLString::transcode("recipient")); + expectedInResponseTo = (XMLString::transcode("inresponse")); + expectedAddress = (XMLString::transcode("address")); + + singleElementFile = data_path + "saml2/core/impl/SubjectConfirmationData.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml"; + childElementsFile = data_path + "saml2/core/impl/SubjectConfirmationDataChildElements.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + delete expectedNotBefore; + delete expectedNotOnOrAfter; + XMLString::release(&expectedRecipient); + XMLString::release(&expectedInResponseTo); + XMLString::release(&expectedAddress); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SubjectConfirmationData* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + SubjectConfirmationData* scd = dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch()); + TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch()); + assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient()); + assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo()); + assertEquals("Address attribute", expectedAddress, scd->getAddress()); + + //TODO need to test with some wildcard attributes + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + SubjectConfirmationData* scd= dynamic_cast(xo.get()); + TS_ASSERT(scd!=NULL); + + TS_ASSERT(scd->getNotBefore()==NULL); + TS_ASSERT(scd->getNotOnOrAfter()==NULL); + TS_ASSERT(scd->getRecipient()==NULL); + TS_ASSERT(scd->getInResponseTo()==NULL); + TS_ASSERT(scd->getAddress()==NULL); + + //TODO need to test with some wildcard child elements + } + + void testSingleElementMarshall() { + SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); + assertEquals(expectedDOM, scd); + } + + void testSingleElementOptionalAttributesMarshall() { + SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); + scd->setNotBefore(expectedNotBefore); + scd->setNotOnOrAfter(expectedNotOnOrAfter); + scd->setRecipient(expectedRecipient); + scd->setInResponseTo(expectedInResponseTo); + scd->setAddress(expectedAddress); + //TODO need to test with some wilcard attributes + assertEquals(expectedOptionalAttributesDOM, scd); + } + + void testChildElementsMarshall() { + SubjectConfirmationData* scd=SubjectConfirmationDataBuilder::buildSubjectConfirmationData(); + //TODO need to test with some wilcard child elements + assertEquals(expectedChildElementsDOM, scd); + } + +}; diff --git a/samltest/saml2/core/impl/SubjectLocality20Test.h b/samltest/saml2/core/impl/SubjectLocality20Test.h new file mode 100644 index 0000000..953c918 --- /dev/null +++ b/samltest/saml2/core/impl/SubjectLocality20Test.h @@ -0,0 +1,69 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2; + +class SubjectLocality20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedAddress; + XMLCh* expectedDNSName; + +public: + void setUp() { + expectedAddress = XMLString::transcode("10.1.2.3");; + expectedDNSName = XMLString::transcode("client.example.org"); + + singleElementFile = data_path + "saml2/core/impl/SubjectLocality.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/SubjectLocalityOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedAddress); + XMLString::release(&expectedDNSName); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + SubjectLocality* sl = dynamic_cast(xo.get()); + TS_ASSERT(sl!=NULL); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + SubjectLocality* sl = dynamic_cast(xo.get()); + TS_ASSERT(sl!=NULL); + assertEquals("Address attribute", expectedAddress, sl->getAddress()); + assertEquals("DNSName attribute", expectedDNSName, sl->getDNSName()); + } + + void testSingleElementMarshall() { + SubjectLocality* sl=SubjectLocalityBuilder::buildSubjectLocality(); + assertEquals(expectedDOM, sl); + } + + void testSingleElementOptionalAttributesMarshall() { + SubjectLocality* sl=SubjectLocalityBuilder::buildSubjectLocality(); + sl->setAddress(expectedAddress); + sl->setDNSName(expectedDNSName); + assertEquals(expectedOptionalAttributesDOM, sl); + } + +};