-/*\r
- * Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include "internal.h"\r
-#include <saml/saml2/core/Assertions.h>\r
-#include <saml/util/SAMLConstants.h>\r
-\r
-using namespace opensaml::saml2;\r
-using namespace xmlsignature;\r
-\r
-//TODO need testing for ElementProxy and wildcard attributes/elements\r
-\r
-class KeyInfoConfirmationDataType20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
- DateTime* expectedNotBefore;\r
- DateTime* expectedNotOnOrAfter;\r
- XMLCh* expectedRecipient;\r
- XMLCh* expectedInResponseTo;\r
- XMLCh* expectedAddress;\r
-\r
-public:\r
- void setUp() {\r
- expectedNotBefore = new DateTime(XMLString::transcode("1984-08-26T10:01:30.043Z"));\r
- expectedNotBefore->parseDateTime();\r
- expectedNotOnOrAfter = new DateTime(XMLString::transcode("1984-08-26T10:11:30.043Z"));\r
- expectedNotOnOrAfter->parseDateTime();\r
- expectedRecipient = (XMLString::transcode("recipient"));\r
- expectedInResponseTo = (XMLString::transcode("inresponse"));\r
- expectedAddress = (XMLString::transcode("address"));\r
-\r
- singleElementFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataType.xml";\r
- singleElementOptionalAttributesFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeOptionalAttributes.xml";\r
- childElementsFile = data_path + "saml2/core/impl/KeyInfoConfirmationDataTypeChildElements.xml"; \r
- SAMLObjectBaseTestCase::setUp();\r
- }\r
- \r
- void tearDown() {\r
- delete expectedNotBefore;\r
- delete expectedNotOnOrAfter;\r
- XMLString::release(&expectedRecipient);\r
- XMLString::release(&expectedInResponseTo);\r
- XMLString::release(&expectedAddress);\r
- SAMLObjectBaseTestCase::tearDown();\r
- }\r
-\r
- void testSingleElementUnmarshall() {\r
- auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
- KeyInfoConfirmationDataType* scd = dynamic_cast<KeyInfoConfirmationDataType*>(xo.get());\r
- TS_ASSERT(scd!=NULL);\r
-\r
- TS_ASSERT(scd->getNotBefore()==NULL);\r
- TS_ASSERT(scd->getNotOnOrAfter()==NULL);\r
- TS_ASSERT(scd->getRecipient()==NULL);\r
- TS_ASSERT(scd->getInResponseTo()==NULL);\r
- TS_ASSERT(scd->getAddress()==NULL);\r
- TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size());\r
- }\r
-\r
- void testSingleElementOptionalAttributesUnmarshall() {\r
- auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
- KeyInfoConfirmationDataType* scd = dynamic_cast<KeyInfoConfirmationDataType*>(xo.get());\r
- TS_ASSERT(scd!=NULL);\r
-\r
- TSM_ASSERT_EQUALS("NotBefore attribute", expectedNotBefore->getEpoch(), scd->getNotBefore()->getEpoch());\r
- TSM_ASSERT_EQUALS("NotOnOrAfter attribute", expectedNotOnOrAfter->getEpoch(), scd->getNotOnOrAfter()->getEpoch());\r
- assertEquals("Recipient attribute", expectedRecipient, scd->getRecipient());\r
- assertEquals("InResponseTo attribute", expectedInResponseTo, scd->getInResponseTo());\r
- assertEquals("Address attribute", expectedAddress, scd->getAddress());\r
- TSM_ASSERT_EQUALS("# of KeyInfo child elements", 0, scd->getKeyInfos().size());\r
-\r
- //TODO need to test with some wildcard attributes\r
- }\r
-\r
- void testChildElementsUnmarshall() {\r
- auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
- KeyInfoConfirmationDataType* scd= dynamic_cast<KeyInfoConfirmationDataType*>(xo.get());\r
- TS_ASSERT(scd!=NULL);\r
-\r
- TS_ASSERT(scd->getNotBefore()==NULL);\r
- TS_ASSERT(scd->getNotOnOrAfter()==NULL);\r
- TS_ASSERT(scd->getRecipient()==NULL);\r
- TS_ASSERT(scd->getInResponseTo()==NULL);\r
- TS_ASSERT(scd->getAddress()==NULL);\r
- TSM_ASSERT_EQUALS("# of KeyInfo child elements", 1, scd->getKeyInfos().size());\r
-\r
- //TODO need to test with some wildcard child elements\r
- }\r
-\r
- void testSingleElementMarshall() {\r
- KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType();\r
- assertEquals(expectedDOM, scd);\r
- }\r
-\r
- void testSingleElementOptionalAttributesMarshall() {\r
- KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType();\r
- scd->setNotBefore(expectedNotBefore);\r
- scd->setNotOnOrAfter(expectedNotOnOrAfter);\r
- scd->setRecipient(expectedRecipient);\r
- scd->setInResponseTo(expectedInResponseTo);\r
- scd->setAddress(expectedAddress);\r
- //TODO need to test with some wilcard attributes\r
- assertEquals(expectedOptionalAttributesDOM, scd);\r
- }\r
-\r
- void testChildElementsMarshall() {\r
- KeyInfoConfirmationDataType* scd=KeyInfoConfirmationDataTypeBuilder::buildKeyInfoConfirmationDataType();\r
- scd->getKeyInfos().push_back(KeyInfoBuilder::buildKeyInfo());\r
- //TODO need to test with some wilcard child elements\r
- assertEquals(expectedChildElementsDOM, scd);\r
- }\r
-\r
-};\r
+/*
+ * Copyright 2001-2007 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 <saml/saml2/core/Assertions.h>
+#include <saml/util/SAMLConstants.h>
+
+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<XMLObject> xo(unmarshallElement(singleElementFile));
+ KeyInfoConfirmationDataType* scd = dynamic_cast<KeyInfoConfirmationDataType*>(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<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
+ KeyInfoConfirmationDataType* scd = dynamic_cast<KeyInfoConfirmationDataType*>(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<XMLObject> xo(unmarshallElement(childElementsFile));
+ KeyInfoConfirmationDataType* scd= dynamic_cast<KeyInfoConfirmationDataType*>(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);
+ }
+
+};