From 0ba5816a876bed78a05d9ed77db97b809927f1c0 Mon Sep 17 00:00:00 2001 From: Brent Putman Date: Sat, 22 Jul 2006 20:18:01 +0000 Subject: [PATCH] SAML 2.0 Core Assertion namespace unit tests. --- saml/saml2/core/Assertions.h | 3 +- saml/saml2/core/impl/Assertions20Impl.cpp | 7 ++ samltest/Makefile.am | 26 ++++ samltest/data/saml2/core/impl/Action.xml | Bin 260 -> 336 bytes .../saml2/core/impl/ActionOptionalAttributes.xml | Bin 290 -> 0 bytes .../data/saml2/core/impl/AdviceChildElements.xml | Bin 588 -> 876 bytes samltest/data/saml2/core/impl/Assertion.xml | Bin 332 -> 356 bytes .../saml2/core/impl/AssertionChildElements.xml | Bin 766 -> 874 bytes samltest/data/saml2/core/impl/AssertionIDRef.xml | Bin 300 -> 296 bytes .../core/impl/AssertionOptionalAttributes.xml | Bin 348 -> 354 bytes samltest/data/saml2/core/impl/AssertionURIRef.xml | Bin 306 -> 302 bytes samltest/data/saml2/core/impl/Attribute.xml | Bin 260 -> 258 bytes .../saml2/core/impl/AttributeChildElements.xml | Bin 0 -> 402 bytes .../core/impl/AttributeOptionalAttributes.xml | Bin 368 -> 380 bytes .../data/saml2/core/impl/AttributeStatement.xml | Bin 242 -> 240 bytes .../core/impl/AttributeStatementChildElements.xml | Bin 406 -> 450 bytes samltest/data/saml2/core/impl/Audience.xml | Bin 276 -> 272 bytes .../data/saml2/core/impl/AudienceRestriction.xml | Bin 244 -> 242 bytes .../core/impl/AudienceRestrictionChildElements.xml | Bin 368 -> 360 bytes .../saml2/core/impl/AuthenticatingAuthority.xml | Bin 348 -> 344 bytes samltest/data/saml2/core/impl/AuthnContext.xml | Bin 230 -> 228 bytes .../saml2/core/impl/AuthnContextChildElements.xml | Bin 576 -> 518 bytes .../data/saml2/core/impl/AuthnContextClassRef.xml | Bin 330 -> 326 bytes .../data/saml2/core/impl/AuthnContextDeclRef.xml | Bin 338 -> 334 bytes samltest/data/saml2/core/impl/AuthnStatement.xml | Bin 314 -> 312 bytes .../core/impl/AuthnStatementChildElements.xml | Bin 372 -> 368 bytes .../core/impl/AuthnStatementOptionalAttributes.xml | Bin 450 -> 450 bytes .../saml2/core/impl/AuthzDecisionStatement.xml | Bin 300 -> 344 bytes .../impl/AuthzDecisionStatementChildElements.xml | Bin 444 -> 438 bytes samltest/data/saml2/core/impl/Conditions.xml | Bin 300 -> 224 bytes .../saml2/core/impl/ConditionsChildElements.xml | Bin 570 -> 566 bytes .../core/impl/ConditionsOptionalAttributes.xml | Bin 380 -> 378 bytes .../data/saml2/core/impl/EvidenceChildElements.xml | Bin 692 -> 882 bytes samltest/data/saml2/core/impl/Issuer.xml | Bin 266 -> 260 bytes .../saml2/core/impl/IssuerOptionalAttributes.xml | Bin 0 -> 416 bytes .../core/impl/KeyInfoConfirmationDataType.xml | Bin 0 -> 444 bytes .../KeyInfoConfirmationDataTypeChildElements.xml | Bin 0 -> 628 bytes ...yInfoConfirmationDataTypeOptionalAttributes.xml | Bin 0 -> 732 bytes samltest/data/saml2/core/impl/NameID.xml | Bin 258 -> 260 bytes .../saml2/core/impl/NameIDOptionalAttributes.xml | Bin 426 -> 416 bytes samltest/data/saml2/core/impl/NameIDType.xml | Bin 0 -> 496 bytes .../core/impl/NameIDTypeOptionalAttributes.xml | Bin 0 -> 656 bytes samltest/data/saml2/core/impl/OneTimeUse.xml | Bin 226 -> 224 bytes samltest/data/saml2/core/impl/ProxyRestriction.xml | Bin 258 -> 236 bytes .../core/impl/ProxyRestrictionChildElements.xml | Bin 356 -> 348 bytes .../impl/ProxyRestrictionOptionalAttributes.xml | Bin 0 -> 254 bytes samltest/data/saml2/core/impl/Subject.xml | Bin 220 -> 218 bytes .../data/saml2/core/impl/SubjectChildElements.xml | Bin 396 -> 386 bytes .../data/saml2/core/impl/SubjectConfirmation.xml | Bin 286 -> 288 bytes .../core/impl/SubjectConfirmationChildElements.xml | Bin 394 -> 386 bytes .../saml2/core/impl/SubjectConfirmationData.xml | Bin 326 -> 250 bytes .../impl/SubjectConfirmationDataChildElements.xml | Bin 0 -> 250 bytes .../SubjectConfirmationDataOptionalAttributes.xml | Bin 538 -> 536 bytes samltest/data/saml2/core/impl/SubjectLocality.xml | Bin 278 -> 234 bytes .../impl/SubjectLocalityOptionalAttributes.xml | Bin 316 -> 330 bytes samltest/internal.h | 119 ++++++++++++++++++ samltest/saml2/core/impl/Action20Test.h | 61 +++++++++ samltest/saml2/core/impl/Advice20Test.h | 89 +++++++++++++ samltest/saml2/core/impl/Assertion20Test.h | 135 ++++++++++++++++++++ samltest/saml2/core/impl/AssertionIDRef20Test.h | 51 ++++++++ samltest/saml2/core/impl/AssertionURIRef20Test.h | 51 ++++++++ samltest/saml2/core/impl/Attribute20Test.h | 107 ++++++++++++++++ .../saml2/core/impl/AttributeStatement20Test.h | 69 ++++++++++ samltest/saml2/core/impl/Audience20Test.h | 51 ++++++++ .../saml2/core/impl/AudienceRestriction20Test.h | 64 ++++++++++ .../core/impl/AuthenticatingAuthority20Test.h | 51 ++++++++ samltest/saml2/core/impl/AuthnContext20Test.h | 72 +++++++++++ .../saml2/core/impl/AuthnContextClassRef20Test.h | 51 ++++++++ .../saml2/core/impl/AuthnContextDeclRef20Test.h | 51 ++++++++ samltest/saml2/core/impl/AuthnStatement20Test.h | 111 ++++++++++++++++ .../saml2/core/impl/AuthzDecisionStatement20Test.h | 82 ++++++++++++ samltest/saml2/core/impl/Conditions20Test.h | 127 +++++++++++++++++++ samltest/saml2/core/impl/Evidence20Test.h | 85 +++++++++++++ samltest/saml2/core/impl/Issuer20Test.h | 93 ++++++++++++++ .../core/impl/KeyInfoConfirmationDataType20Test.h | 124 ++++++++++++++++++ samltest/saml2/core/impl/NameID20Test.h | 93 ++++++++++++++ samltest/saml2/core/impl/NameIDType20Test.h | 139 +++++++++++++++++++++ samltest/saml2/core/impl/OneTimeUse20Test.h | 46 +++++++ samltest/saml2/core/impl/ProxyRestriction20Test.h | 85 +++++++++++++ samltest/saml2/core/impl/Subject20Test.h | 71 +++++++++++ .../saml2/core/impl/SubjectConfirmation20Test.h | 77 ++++++++++++ .../core/impl/SubjectConfirmationData20Test.h | 119 ++++++++++++++++++ samltest/saml2/core/impl/SubjectLocality20Test.h | 69 ++++++++++ 83 files changed, 2378 insertions(+), 1 deletion(-) delete mode 100644 samltest/data/saml2/core/impl/ActionOptionalAttributes.xml create mode 100644 samltest/data/saml2/core/impl/AttributeChildElements.xml create mode 100644 samltest/data/saml2/core/impl/IssuerOptionalAttributes.xml create mode 100644 samltest/data/saml2/core/impl/KeyInfoConfirmationDataType.xml create mode 100644 samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml create mode 100644 samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml create mode 100644 samltest/data/saml2/core/impl/NameIDType.xml create mode 100644 samltest/data/saml2/core/impl/NameIDTypeOptionalAttributes.xml create mode 100644 samltest/data/saml2/core/impl/ProxyRestrictionOptionalAttributes.xml create mode 100644 samltest/data/saml2/core/impl/SubjectConfirmationDataChildElements.xml create mode 100644 samltest/saml2/core/impl/Action20Test.h create mode 100644 samltest/saml2/core/impl/Advice20Test.h create mode 100644 samltest/saml2/core/impl/Assertion20Test.h create mode 100644 samltest/saml2/core/impl/AssertionIDRef20Test.h create mode 100644 samltest/saml2/core/impl/AssertionURIRef20Test.h create mode 100644 samltest/saml2/core/impl/Attribute20Test.h create mode 100644 samltest/saml2/core/impl/AttributeStatement20Test.h create mode 100644 samltest/saml2/core/impl/Audience20Test.h create mode 100644 samltest/saml2/core/impl/AudienceRestriction20Test.h create mode 100644 samltest/saml2/core/impl/AuthenticatingAuthority20Test.h create mode 100644 samltest/saml2/core/impl/AuthnContext20Test.h create mode 100644 samltest/saml2/core/impl/AuthnContextClassRef20Test.h create mode 100644 samltest/saml2/core/impl/AuthnContextDeclRef20Test.h create mode 100644 samltest/saml2/core/impl/AuthnStatement20Test.h create mode 100644 samltest/saml2/core/impl/AuthzDecisionStatement20Test.h create mode 100644 samltest/saml2/core/impl/Conditions20Test.h create mode 100644 samltest/saml2/core/impl/Evidence20Test.h create mode 100644 samltest/saml2/core/impl/Issuer20Test.h create mode 100644 samltest/saml2/core/impl/KeyInfoConfirmationDataType20Test.h create mode 100644 samltest/saml2/core/impl/NameID20Test.h create mode 100644 samltest/saml2/core/impl/NameIDType20Test.h create mode 100644 samltest/saml2/core/impl/OneTimeUse20Test.h create mode 100644 samltest/saml2/core/impl/ProxyRestriction20Test.h create mode 100644 samltest/saml2/core/impl/Subject20Test.h create mode 100644 samltest/saml2/core/impl/SubjectConfirmation20Test.h create mode 100644 samltest/saml2/core/impl/SubjectConfirmationData20Test.h create mode 100644 samltest/saml2/core/impl/SubjectLocality20Test.h 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 2e9162fbaf7b7f68d74af85ff8b2aed41715329c..bf7705c2dc0f247bca588bf15b0a8c2c58a169ec 100644 GIT binary patch delta 104 zcmZo+y1+EyVzdH-A44KTE<-9qF+%~6l?-IrGAJ>WG88f7F<1dbOMt9QAUhq%%fnEs e#Gt@n2UL|0Hp3C9zXYf{AE?rA;v*#{1}*@qP8F{J delta 28 jcmcb>)WS63qM#i^B11Am2}34BK0_XZ0z=+p9Y!SpbOQ$W diff --git a/samltest/data/saml2/core/impl/ActionOptionalAttributes.xml b/samltest/data/saml2/core/impl/ActionOptionalAttributes.xml deleted file mode 100644 index c7766c7e847539f9200b777bb251f9e5f5b4f888..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 290 zcmZvWy$*sv5QM+lr?}AjTUcBWVq>K?>H`=g#zYSzXncBgZUa-?JNcX)b zGM-`v-75V>cGQDql(siY@$8hgVXbXuoxHhgYuqtn&u#yC*H%c6j7Uw?FJ3yg>nSN? I>Hk`1KP?k7_W%F@ diff --git a/samltest/data/saml2/core/impl/AdviceChildElements.xml b/samltest/data/saml2/core/impl/AdviceChildElements.xml index b872820495207c8ad2773e4b4aff0a3809d4a027..72f40ac31b48a6a5e6d095ac18171bbcd50b31b4 100644 GIT binary patch literal 876 zcmd6mK}*9x5QX1a@IQp!Ynx~-25l)+A)uGqdhk}$D1vUqjYa>w`pvXzk%AWyFOy~F z&AhksHm`3wRA0}!*PRkAROwMsx0);HNDZahQJZf-10FTC7!(K0j`RdGH@O1 fJ}uq+*`Kew&D_;Jb^J|Q{_pPAf@{;u_y6J@pc9L7 delta 66 ucmaFEc7|ob<;iCm6()Bxa!o$XsDwf9X5;~jLui%B{!CIpK7{sUmInYs&KBGN diff --git a/samltest/data/saml2/core/impl/Assertion.xml b/samltest/data/saml2/core/impl/Assertion.xml index 54b5f54a7bc24601719d5b841d5f4f0ab6a23557..24f65224131bcdc918c681db6ed492a35135d073 100644 GIT binary patch delta 29 kcmX@Z^n__bxv&d^ErSw6B0~~GGJ_$55rZ*<(!`=$0B}b%7 diff --git a/samltest/data/saml2/core/impl/AssertionChildElements.xml b/samltest/data/saml2/core/impl/AssertionChildElements.xml index 67e917aa61f9fa57c46c205a090e8919f9c1c27e..238a6b8843eb8352a595255b9282fa72587cd5d1 100644 GIT binary patch delta 253 zcmeyz`igBrX}u?d3xh3#5?fT_ta*&9r1EFcpBo!lqr delta 57 zcmaFG_K$T!>BPGYlM@-GCf75{O+9=F>nC@N(2U9 delta 23 bcmZ3%w1#OyEThrH7*ilIp&Z1LXS4$VSo;R# diff --git a/samltest/data/saml2/core/impl/AssertionOptionalAttributes.xml b/samltest/data/saml2/core/impl/AssertionOptionalAttributes.xml index abfd7dfbeb442c91565d32ea839770d2506aa754..959b5426bf79499c1653f1cb98aa1661c24bbe2b 100644 GIT binary patch delta 40 wcmcb^^oVIf?8JDjiQOTBE)2E|N(_k%Nesyhh73jw#uIOZPPS!~XJX(20Q({eWB>pF delta 35 pcmaFFbcbm|EThrH7;PZY7CP~>AGari3xh3#5<@0K%48cx6#&wd3M2pk diff --git a/samltest/data/saml2/core/impl/AssertionURIRef.xml b/samltest/data/saml2/core/impl/AssertionURIRef.xml index 313ee24f4e82fd823c3593f5ce8eccb40f6487d3..cf339584ed3254efb74b8331eba4c71b7bf6fe6b 100644 GIT binary patch delta 23 dcmdnQw2o;)>|{Ykg^BfI6Q@@IS&B>yTmW8+2Co1B delta 23 bcmZ3-w25g#EThrH7;_*osS?CeWV8bST15u< diff --git a/samltest/data/saml2/core/impl/Attribute.xml b/samltest/data/saml2/core/impl/Attribute.xml index 3f82e102db89e30169894eece48a58440a84034f..c5cdb52ec29db1f5fa5bb7c415f5bb8675fcbdfb 100644 GIT binary patch delta 15 WcmZo+YGRrYJ275sVs|AI0~Y`(vjnpM delta 16 WcmZo-YGIlX%V;z)MjJ@9RRI7fKLrN> diff --git a/samltest/data/saml2/core/impl/AttributeChildElements.xml b/samltest/data/saml2/core/impl/AttributeChildElements.xml new file mode 100644 index 0000000000000000000000000000000000000000..206f191736bc97bee1c9d5d16176ee146cb0fdaf GIT binary patch literal 402 zcmchTxemfG5JX??uZZY53knN}XsDp#=s6;U6dWlB;_HF&f>I$$*IFr1GsYCNB#$A87Bdrt5Z<3uhbEQTm RNB=MSe*5BYe-nSty#U6rMbrQQ literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/AttributeOptionalAttributes.xml b/samltest/data/saml2/core/impl/AttributeOptionalAttributes.xml index 6ceb810e9ba7fee33197044a406985e1a67153d4..ba99fb18f303972aeaae3d4e369d4c636b3f373a 100644 GIT binary patch delta 33 pcmeys^oMCe?8JDjiQS8Mtr*f6@)?R4av2gCN+#?4d delta 16 Wcmeys_=#~sEThrH7+WAQBMbmFa|Pi5 diff --git a/samltest/data/saml2/core/impl/AttributeStatementChildElements.xml b/samltest/data/saml2/core/impl/AttributeStatementChildElements.xml index 6b30b148229880e097804a716e736bc68b02d7e9..61450801f331f7fc1df532aeffe170203ebf69ba 100644 GIT binary patch delta 72 zcmbQne295M>|{kok%`3`6X(VNSt=kbY{lTpkjIeBP{dHlP{2^akjjuU@sBc4N`_OP Xp_n0&A(tU%vI3*%D2QZ8!5V8!6bP|A?PkjaqBkjIb=B<%phWC;5J diff --git a/samltest/data/saml2/core/impl/AudienceRestriction.xml b/samltest/data/saml2/core/impl/AudienceRestriction.xml index 3caca6b6d1183c500b4f18ebff1d78b523acb8e4..c349f1eeb6f5dfe7bddcca8562b244ecc5f0d6de 100644 GIT binary patch delta 15 Wcmeyu_=#~s?8JDxiSt957`Om7IR%vf delta 16 Wcmeyw_=RyoEThrH7<(WwD+~ZNzXj<4 diff --git a/samltest/data/saml2/core/impl/AudienceRestrictionChildElements.xml b/samltest/data/saml2/core/impl/AudienceRestrictionChildElements.xml index 7c5a9b516aa4bd795190cda77979f46c91f29e9e..90f011a752b244aec522849cb10625d8aa6ace72 100644 GIT binary patch delta 35 rcmeys^nz(Z?8JDxiSuJ7D>6#47c(R>$G`;u;8hAk delta 33 kcmaFC^nqzYEThrH7<(Ww3&i@S%xE-Of>9Mn+AwMX0Kymv@&Et; diff --git a/samltest/data/saml2/core/impl/AuthenticatingAuthority.xml b/samltest/data/saml2/core/impl/AuthenticatingAuthority.xml index dbaa5285abaad992338851bac4a2d40c93627469..307b529a7de0962c56c61ce6452d59e04e2b2935 100644 GIT binary patch delta 19 bcmcb^bc1O^?8JDtiOZWN#v3r(F>nC@QsxH% delta 23 bcmcb?bcbm|EThrH76HvEThrH7(*b@69xb?s|B$D diff --git a/samltest/data/saml2/core/impl/AuthnContextChildElements.xml b/samltest/data/saml2/core/impl/AuthnContextChildElements.xml index 943638f6848b0d54f7ef049d5a15a458ec1a364e..e0a500033f1a1f8990466c415b163d9d871a2c35 100644 GIT binary patch delta 87 zcmX@W(#A3&c4EB2#EAj?3JhEfb__NQ#SDoIxePfI-`P%#mzrG5D8SFfppPsw`2nNx Z1 delta 138 zcmZo;IlwX@meFWpj3JQd3FNh7uwf`>NMy)m$YC&=_{J6_B`xj3kjjt@6j5N{V$f$m qRTCpE50ef8DoX<@LQ^t%38VGoxr`i)MnIOaAVgLl$(k5xMmqp^#T|

-F>nC@O+^Mu delta 23 bcmX@cbc$(0EThrH7)Ky6rxwK0X0!tUUw;Qm diff --git a/samltest/data/saml2/core/impl/AuthnContextDeclRef.xml b/samltest/data/saml2/core/impl/AuthnContextDeclRef.xml index 86d6476ebc813d56be413853f600f9882f420caa..18ab5ff030f2a06d2d7d1c27767d085356dc6610 100644 GIT binary patch delta 19 bcmcb_bdG64?8JDxiSs)q#%nO!F>nC@Q04~P delta 23 bcmX@dbcty~EThrH7<(Wws}sc1WV8bSVGRdh diff --git a/samltest/data/saml2/core/impl/AuthnStatement.xml b/samltest/data/saml2/core/impl/AuthnStatement.xml index d86cb43af9cbbc083b0f162fe6d2d2229b5c2c06..7ce1017ede58486c12e3775dc1509fc779c38e62 100644 GIT binary patch delta 15 XcmdnRw1a6v?8JDJiBp#{F>nC@FvA63 delta 16 WcmdnNw2Ns%EThrH7*ilIVHp4~4+XOT diff --git a/samltest/data/saml2/core/impl/AuthnStatementChildElements.xml b/samltest/data/saml2/core/impl/AuthnStatementChildElements.xml index f32826a74101efeee5745447935867a7ce4c456c..11d0a408a2be03508d3db8c410d72ebc38ad5f7e 100644 GIT binary patch delta 66 zcmeyu^nqzY?8JDJiBki3xftviY#53e5*czCawaP=6j$uq=V&DP*s|pCI delta 30 kcmX@ae295METhrH7*ilIVLxXkLmop4Ln=eX#h Ap8x;= diff --git a/samltest/data/saml2/core/impl/AuthzDecisionStatementChildElements.xml b/samltest/data/saml2/core/impl/AuthzDecisionStatementChildElements.xml index 84bd12a31c465061b01638433d4673c5cfc025f5..5f5693a234d55d422d542b6c10e63c1590225536 100644 GIT binary patch delta 83 zcmdnPyp4H6?8JDNiAw``xftviY#53e5*czCawe-VDo$2qQ~+UBD+X7FGKNfs6oyoW aJceW-sldR+pbu8B57RL*PM_J1feQdi>=A8=s!hwBL*u5M}}mE5{68M me1<#*1qOWv6qP`ESB5g6YzjjvP(B$*!qn&^nHQtaXa@jBz!<>* diff --git a/samltest/data/saml2/core/impl/Conditions.xml b/samltest/data/saml2/core/impl/Conditions.xml index 2fbb68bdb9bac6e0a06cf4076c7c43cd44efeebd..b061bbf5848f6f17569f850c39bef06cbaadfda8 100644 GIT binary patch delta 18 ZcmZ3(^nh_f?8JDTiM>Ir`V4jqTmV5C1%&_r delta 94 zcmaFBxQ1y$EThrH7+oOI5$x;7kk3%U;KY#1kOpKG0cl$XB?dzVO9l%D69!!d10b!- jV8md?5CRl6V6XyWLm+7kr1gN<1jvd4>QG?NXRreRmS7K5 diff --git a/samltest/data/saml2/core/impl/ConditionsChildElements.xml b/samltest/data/saml2/core/impl/ConditionsChildElements.xml index 696778c0df17890c4cc019322b27ad9cc49b5d51..f32c3f0ee52f7fffd5ace2c4487e129e3f0246b0 100644 GIT binary patch delta 79 zcmdnRvW;az?8JDTiM=tC{Ta3Rxft{r>=D4Um@z j6whHWnk>g?$%r7eC-XB30QrX))q&&-MpGau!z2L!HxLxx diff --git a/samltest/data/saml2/core/impl/ConditionsOptionalAttributes.xml b/samltest/data/saml2/core/impl/ConditionsOptionalAttributes.xml index 2eb7206641c8b91913c641bde7627bc5248fe5ba..fad56ed09664c9cf6974063e1511ebf9d75c4dde 100644 GIT binary patch delta 15 Wcmeyv^owai?8JDTiM{Wc7`Om9!v-Ay delta 16 Wcmeyx^oMCeEThrH7+oOI@c{rf)dq0@ diff --git a/samltest/data/saml2/core/impl/EvidenceChildElements.xml b/samltest/data/saml2/core/impl/EvidenceChildElements.xml index 956b603f6fc1e79c4b2bf5e10b1d5ae6085ed85a..d3e597f8094b6764e4cd02b5fce2b924d39a22e5 100644 GIT binary patch literal 882 zcmd6m-Ae*d5XFDbLjS|!yXkJ3wD^Ib!9u;5`p}ynYY2H2ca8ezt8-_gv$tblB%?*s3$r zoxkfYn~L^j+uOaW+Sdt jd-8qm!IA!azRhpjf^+J&mHys)|2J=|is`4_x4+{J3K)$5 delta 82 ucmeywwuN=V^~vWM6(;vGa!o$VsDwf9W#j>iW2aRn2QoE<-AVCqpq1mI7Ht3^okSCG@%V;z)Miodj1RG~E6a!%?Ln=cNg91YyLn1>ikZr@D4-^Hla~O;mtQb6z HRM`OlE`1KD diff --git a/samltest/data/saml2/core/impl/IssuerOptionalAttributes.xml b/samltest/data/saml2/core/impl/IssuerOptionalAttributes.xml new file mode 100644 index 0000000000000000000000000000000000000000..3cc35ae1af1ca1a2324916572a437bc311e066e7 GIT binary patch literal 416 zcmaiw&1wQc5QM*To?`JH{|-4U{ve1TXi(G#Sag*IomFQIdHTfaW)Tm9hhciUYO1>H z@1Gt+emQX@;fI_nk%E#yp9US8v~?#!0$cTWLIVd!H>{cPDb|-bLk4_EFOs=l%2aja z=Bi2U64Xf_9P_xzGpJYUpLrV|TqF0ol5fh25p!m$x;|6t?C9E6J+aOCUH@E4H`7)H zdmY=$yaE^BX2s$SGje{gCz|c5oiZv{*+0F_)6^DXluEErLb=YAv2#tw>W0#ZVw{9N N=hCC4{;R~4<{iZkNcjK& literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/KeyInfoConfirmationDataType.xml b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataType.xml new file mode 100644 index 0000000000000000000000000000000000000000..db780d2cfc69796078bcc40738276bf865581511 GIT binary patch literal 444 zcmaiw$w~uJ5Jk`0uL#*^FoKIl4WbC5t`fm*8#5^STGAa&eqKGV+F>aVx{Dgly;UEd z95H6g3(s_TW6qkIM=BD>blIoR(0|8DVrKrqYGN7HTc%vlv+K~FF(>TFt0{w5Fk!aX2+%cg?j&ao_;f0ZoXpczSYR&l{$?&1q0uEyuRN9 mJy!0uG&}OfL$5gCE;g9B&q^QpO1-#uEu)k@GuyS#OMd~1Ku)Xx literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml new file mode 100644 index 0000000000000000000000000000000000000000..9002fbd73bb30dcc4ea96545e4e5096759f7b036 GIT binary patch literal 628 zcmb7?OG^Vm5QOWTUlHOt*)@XTq6t9}L_H;f*LCwoXC=GQL_oy)^2?MiDKdP#0 z_Ty9M>T9DHJ*%lVO|(*_g-QiosHJ0dl=5v-2`b2ssRqrw`k;}n)u!u|p1yi&fLAGZ zyi7x_^`s@Ug=$?o>Xi8v^_)!Px$-!NBkBksWWOk;V$DP#SJG+ftR9?Y;&BbWu?=*u zJEE?u&b+(woqo7%lZ|6!@Ne}>)fje~Z^>+R1O61g|1^)jF(R(H7}ZA(L!QG^!;>lD zy!+{JpP;d1uNm1c9;djN=+QSAvd2zK7Ovn1&P$ bsm{3LTNuIujYrO!IB)XDt;1f}{*T5NP%mwd literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml b/samltest/data/saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml new file mode 100644 index 0000000000000000000000000000000000000000..10546cbd70be059529c51da891bb14955c1ebe2a GIT binary patch literal 732 zcmaiyTT22_6ouDwze0LfM-!<-B~}E{MM#6_Z5nSyjWRQq{`u^`x0n9cfn$)fDlrkV%ygACgTq@$8)jI#-pdHZ>g`YX@Gg z*m*&HE%c~odJ`2ob?TV@jC@R_)H(BYj7I4rg%Exz=3+rdN^C}@xwCxgDkEPP@J+3& zYhAHwy6fQ8xzF^YWs@wO5zt?0PSzCuJYN!7=>q;3y=|Tc-;9!LyI8s}HH|$N_K0%*(rueX3s``HCFk;vVQPaAix6lb+<}%}5p4Nf( z)uJcjU4`4`gc^JW=Lb|H-E<-AVA44LT_GEBjuwl?=C=?KJ=K2i} delta 60 zcmZo+YGRrY%V;z)Miodj1Z!t9q%bHjOz3|#;K diff --git a/samltest/data/saml2/core/impl/NameIDOptionalAttributes.xml b/samltest/data/saml2/core/impl/NameIDOptionalAttributes.xml index 405c31f58d61f60ac6d2edd1942e522d0771422f..8af601f5c7f433827be9d357dca3cc4901c23766 100644 GIT binary patch delta 106 zcmZ3*ynuN^?8JDLiLHlXl^7Hlf*AsUu!td_p^PDuA%!6oh&>rx7;G7o7>XGRz-%Q3 hJ0LrsAr~m?$B+o7L27Im^nv0aehz~bii{lt7XbSO6wd$v delta 116 zcmZ3$yoz~3EThrH7*!zAa5!0kp_rkBp^_noA(cUiL4hHdApi)A81fm)7%~}BfTBeV wo(wJwwm{iph5|5KiNOvmr@)ZMkjRh=RAa-S50nM5a~O;mtQh>D;vk)N0LQ2nhyVZp diff --git a/samltest/data/saml2/core/impl/NameIDType.xml b/samltest/data/saml2/core/impl/NameIDType.xml new file mode 100644 index 0000000000000000000000000000000000000000..b5a802b60d19ba9a28dedc80886e95441e043dc9 GIT binary patch literal 496 zcmZ{hO-lnY5Qg8g;D1IBsVnz^oYtRp(^ zQDW;;MSWq`>H^GES31@a zj4kMfJtbSQlD$G8n(}Q5#=Zj6YD;Xy`t&tqKS#B~$&%<9`ePJEdewvOmEmFqf2ka0 z^I}T5yDQvjS52oCo&2v>;3tP|O9zUcZaitV_Zb^UZ`}V5j{)};F{{a{3!b<7Q+&4vU%2s>pRkGUu9Ky6@I@EE_< z9rW&f$uv8FY|xEpySduC+&asm_iwt!HUm*HHEX7#;4yEeXgu~kU?Lh2CE4iF;uCH& K_BYOm&(0qwz;PD< literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/OneTimeUse.xml b/samltest/data/saml2/core/impl/OneTimeUse.xml index c77061ceb13b1128fc4ad885694f235d5c373345..8f7d3c4acffd488e8bb6f72c4428407934813fc5 100644 GIT binary patch delta 15 WcmaFF_<(Uj?8JDTiM^pr3|s&+X$4IH delta 16 WcmaFB_=s^rEThrH7+oOI5e5J=69u6F diff --git a/samltest/data/saml2/core/impl/ProxyRestriction.xml b/samltest/data/saml2/core/impl/ProxyRestriction.xml index e1a79e9fec18a09c2ea62cd4ff6571cb1e0159a8..3827d49e739389f038608a611ea976bcdb67a7b9 100644 GIT binary patch delta 18 ZcmZo-dc!y&c4EB6#F;^?`V4jqTmV141%Chl delta 40 scmaFE*u*p;meFWpj3tnm5-je_kk3%ckjGHMV9TJyU<$+v4EhXq0O1=5#sB~S diff --git a/samltest/data/saml2/core/impl/ProxyRestrictionChildElements.xml b/samltest/data/saml2/core/impl/ProxyRestrictionChildElements.xml index fc39669febd37078d6e5e3277bc3b6ce5d468c10..97c16c60f01f45a7d7ffbb24eaf61b724c7ebc4b 100644 GIT binary patch delta 39 ucmaFDbcbm|>|{qqrHPGV6KBRumS&V44-~s>xw+gEO delta 37 kcmcb^^n__bEThrH7)u~A1;qNG3?if_>oRhI#FZKC0QC|Jvj6}9 diff --git a/samltest/data/saml2/core/impl/ProxyRestrictionOptionalAttributes.xml b/samltest/data/saml2/core/impl/ProxyRestrictionOptionalAttributes.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f4903e7b25798fe3c805bed2feb5c67cab4cfab GIT binary patch literal 254 zcmX|+%L>9U6hzP3uPE+)f-ZtuL~x}bK0ZLINI?@Yt?19IlS_4z*UUXLd4HIY^W?^r zj0b1#L`njlDQyOH>1)rVcnZCrqD4MQ&$YoGsP+-t!uw&o?08#M@ A`~Uy| delta 46 xcmZ3$G>>UQEThrH7<(WwD_J&~A)g_SA&o(SA(tVQp@bm=$WLKV0`m14>;NI(3S$5O diff --git a/samltest/data/saml2/core/impl/SubjectConfirmationChildElements.xml b/samltest/data/saml2/core/impl/SubjectConfirmationChildElements.xml index feacd777a8e85ef3bec99eb5b365830fcc26fdbe..0983bd041c198b61bd2f04d5f40202b373da282a 100644 GIT binary patch delta 34 mcmeBTZepGgJ2{b2V`975#Q8B3|H^?llU*65fV3tP0~Y|*i3+^{ delta 37 jcmZo-?qZ%0%V;z)#vVw_0O; delta 94 zcmeyxc#LU6EThrH79)S>q=>Px# literal 0 HcmV?d00001 diff --git a/samltest/data/saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml b/samltest/data/saml2/core/impl/SubjectConfirmationDataOptionalAttributes.xml index 615f8cf3a47a72292c6612560f017a7816545d9a..f664011907d6ba0c638ab2884e2d32cabe30f2ae 100644 GIT binary patch delta 16 XcmbQmGJ|D8?8JDtjmwJ}nHabLGjs(u delta 17 YcmbQiGK*zGEThrH7n1bgFk~{MGUPFo0L4-nDi{(O bav2JMqNzZBK0^^hI)f5}0)sw-9Rn8t$3+il delta 82 zcmX@bw1;UzEThrH7;_*oDb+EPp@2bwA(0^k2#Xj}8H#~W2`J*i;KvXQ#EA^KKv7$u TSPDZPP)-3zLc~C-^cm~`AGi=^ 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); + } + +}; -- 2.1.4