Fix linefeeds
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / ArtifactResponse20Test.h
index 2e46e21..23a0017 100644 (file)
-/*\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/Protocols.h>\r
-#include <saml/util/SAMLConstants.h>\r
-\r
-using namespace opensaml::saml2p;\r
-using namespace opensaml::saml2;\r
-\r
-class ArtifactResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
-    XMLCh* expectedID; \r
-    XMLCh* expectedInResponseTo; \r
-    XMLCh* expectedVersion; \r
-    XMLCh* expectedConsent; \r
-    XMLCh* expectedDestination; \r
-    DateTime* expectedIssueInstant; \r
-\r
-    // The payload will be an AuthnRequest in this test.\r
-    // AuthnRequest marshaller autogenerates ID, Version and IssueInstant if they are NULL,\r
-    // so have to agree on something to put in the control XML\r
-    XMLCh* authnRequestID;\r
-\r
-public:\r
-    void setUp() {\r
-        expectedID = XMLString::transcode("def456"); \r
-        expectedInResponseTo = XMLString::transcode("abc123"); \r
-        expectedVersion = XMLString::transcode("2.0"); \r
-        expectedConsent = XMLString::transcode("urn:string:consent"); \r
-        expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); \r
-        expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z"));\r
-        expectedIssueInstant->parseDateTime();\r
-\r
-        authnRequestID = XMLString::transcode("test1"); \r
-\r
-        singleElementFile = data_path + "saml2/core/impl/ArtifactResponse.xml";\r
-        singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ArtifactResponseOptionalAttributes.xml";\r
-        childElementsFile  = data_path + "saml2/core/impl/ArtifactResponseChildElements.xml";    \r
-        SAMLObjectBaseTestCase::setUp();\r
-    }\r
-    \r
-    void tearDown() {\r
-        XMLString::release(&expectedID);\r
-        XMLString::release(&expectedInResponseTo);\r
-        XMLString::release(&expectedVersion);\r
-        XMLString::release(&expectedConsent);\r
-        XMLString::release(&expectedDestination);\r
-        XMLString::release(&authnRequestID);\r
-        delete expectedIssueInstant;\r
-        SAMLObjectBaseTestCase::tearDown();\r
-    }\r
-\r
-    void testSingleElementUnmarshall() {\r
-        auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
-        ArtifactResponse* response = dynamic_cast<ArtifactResponse*>(xo.get());\r
-        TS_ASSERT(response!=NULL);\r
-\r
-        assertEquals("ID attribute", expectedID, response->getID());\r
-        assertEquals("Version attribute", expectedVersion, response->getVersion());\r
-        TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch());\r
-\r
-        TS_ASSERT(response->getIssuer()==NULL);\r
-        TS_ASSERT(response->getSignature()==NULL);\r
-        TS_ASSERT(response->getExtensions()==NULL);\r
-        TS_ASSERT(response->getStatus()==NULL);\r
-        TS_ASSERT(response->getPayload()==NULL);\r
-    }\r
-\r
-    void testSingleElementOptionalAttributesUnmarshall() {\r
-        auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));\r
-        ArtifactResponse* response = dynamic_cast<ArtifactResponse*>(xo.get());\r
-        TS_ASSERT(response!=NULL);\r
-\r
-        assertEquals("Consent attribute", expectedConsent, response->getConsent());\r
-        assertEquals("Destination attribute", expectedDestination, response->getDestination());\r
-        assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo());\r
-\r
-        TS_ASSERT(response->getIssuer()==NULL);\r
-        TS_ASSERT(response->getSignature()==NULL);\r
-        TS_ASSERT(response->getExtensions()==NULL);\r
-        TS_ASSERT(response->getStatus()==NULL);\r
-        TS_ASSERT(response->getPayload()==NULL);\r
-    }\r
-\r
-    void testChildElementsUnmarshall() {\r
-        auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
-        ArtifactResponse* response= dynamic_cast<ArtifactResponse*>(xo.get());\r
-        TS_ASSERT(response!=NULL);\r
-\r
-        TS_ASSERT(response->getIssuer()!=NULL);\r
-        TS_ASSERT(response->getSignature()==NULL);\r
-        TS_ASSERT(response->getExtensions()==NULL);\r
-        TS_ASSERT(response->getStatus()!=NULL);\r
-        TS_ASSERT(response->getPayload()!=NULL);\r
-    }\r
-\r
-    void testSingleElementMarshall() {\r
-        ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse();\r
-        TS_ASSERT(response!=NULL);\r
-\r
-        response->setID(expectedID);\r
-        response->setIssueInstant(expectedIssueInstant);\r
-        //response->setVersion(expectedVersion);\r
-        assertEquals(expectedDOM, response);\r
-    }\r
-\r
-    void testSingleElementOptionalAttributesMarshall() {\r
-        ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse();\r
-        TS_ASSERT(response!=NULL);\r
-\r
-        response->setID(expectedID);\r
-        response->setInResponseTo(expectedInResponseTo);\r
-        response->setIssueInstant(expectedIssueInstant);\r
-        //response->setVersion(expectedVersion);\r
-        response->setConsent(expectedConsent);\r
-        response->setDestination(expectedDestination);\r
-        response->setInResponseTo(expectedInResponseTo);\r
-        assertEquals(expectedOptionalAttributesDOM, response);\r
-    }\r
-\r
-    void testChildElementsMarshall() {\r
-        ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse();\r
-        TS_ASSERT(response!=NULL);\r
-\r
-        response->setID(expectedID);\r
-        response->setIssueInstant(expectedIssueInstant);\r
-        // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file\r
-        Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX);\r
-        response->addNamespace(*ns);\r
-        response->setIssuer(IssuerBuilder::buildIssuer());\r
-        response->setStatus(StatusBuilder::buildStatus());\r
-\r
-        AuthnRequest* authnRequest = AuthnRequestBuilder::buildAuthnRequest();\r
-        authnRequest->setIssueInstant(expectedIssueInstant);\r
-        authnRequest->setID(authnRequestID);\r
-        response->setPayload(authnRequest);\r
-\r
-        assertEquals(expectedChildElementsDOM, response);\r
-        delete ns;\r
-    }\r
-\r
-};\r
+/*
+ *  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 <saml/saml2/core/Protocols.h>
+#include <saml/util/SAMLConstants.h>
+
+using namespace opensaml::saml2p;
+using namespace opensaml::saml2;
+
+class ArtifactResponse20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
+    XMLCh* expectedID; 
+    XMLCh* expectedInResponseTo; 
+    XMLCh* expectedVersion; 
+    XMLCh* expectedConsent; 
+    XMLCh* expectedDestination; 
+    DateTime* expectedIssueInstant; 
+
+    // The payload will be an AuthnRequest in this test.
+    // AuthnRequest marshaller autogenerates ID, Version and IssueInstant if they are NULL,
+    // so have to agree on something to put in the control XML
+    XMLCh* authnRequestID;
+
+public:
+    void setUp() {
+        expectedID = XMLString::transcode("def456"); 
+        expectedInResponseTo = XMLString::transcode("abc123"); 
+        expectedVersion = XMLString::transcode("2.0"); 
+        expectedConsent = XMLString::transcode("urn:string:consent"); 
+        expectedDestination = XMLString::transcode("http://sp.example.org/endpoint"); 
+        expectedIssueInstant = new DateTime(XMLString::transcode("2006-02-21T16:40:00.000Z"));
+        expectedIssueInstant->parseDateTime();
+
+        authnRequestID = XMLString::transcode("test1"); 
+
+        singleElementFile = data_path + "saml2/core/impl/ArtifactResponse.xml";
+        singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ArtifactResponseOptionalAttributes.xml";
+        childElementsFile  = data_path + "saml2/core/impl/ArtifactResponseChildElements.xml";    
+        SAMLObjectBaseTestCase::setUp();
+    }
+    
+    void tearDown() {
+        XMLString::release(&expectedID);
+        XMLString::release(&expectedInResponseTo);
+        XMLString::release(&expectedVersion);
+        XMLString::release(&expectedConsent);
+        XMLString::release(&expectedDestination);
+        XMLString::release(&authnRequestID);
+        delete expectedIssueInstant;
+        SAMLObjectBaseTestCase::tearDown();
+    }
+
+    void testSingleElementUnmarshall() {
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
+        ArtifactResponse* response = dynamic_cast<ArtifactResponse*>(xo.get());
+        TS_ASSERT(response!=NULL);
+
+        assertEquals("ID attribute", expectedID, response->getID());
+        assertEquals("Version attribute", expectedVersion, response->getVersion());
+        TSM_ASSERT_EQUALS("IssueInstant attribute", expectedIssueInstant->getEpoch(), response->getIssueInstant()->getEpoch());
+
+        TS_ASSERT(response->getIssuer()==NULL);
+        TS_ASSERT(response->getSignature()==NULL);
+        TS_ASSERT(response->getExtensions()==NULL);
+        TS_ASSERT(response->getStatus()==NULL);
+        TS_ASSERT(response->getPayload()==NULL);
+    }
+
+    void testSingleElementOptionalAttributesUnmarshall() {
+        auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
+        ArtifactResponse* response = dynamic_cast<ArtifactResponse*>(xo.get());
+        TS_ASSERT(response!=NULL);
+
+        assertEquals("Consent attribute", expectedConsent, response->getConsent());
+        assertEquals("Destination attribute", expectedDestination, response->getDestination());
+        assertEquals("InResponseTo attribute", expectedInResponseTo, response->getInResponseTo());
+
+        TS_ASSERT(response->getIssuer()==NULL);
+        TS_ASSERT(response->getSignature()==NULL);
+        TS_ASSERT(response->getExtensions()==NULL);
+        TS_ASSERT(response->getStatus()==NULL);
+        TS_ASSERT(response->getPayload()==NULL);
+    }
+
+    void testChildElementsUnmarshall() {
+        auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
+        ArtifactResponse* response= dynamic_cast<ArtifactResponse*>(xo.get());
+        TS_ASSERT(response!=NULL);
+
+        TS_ASSERT(response->getIssuer()!=NULL);
+        TS_ASSERT(response->getSignature()==NULL);
+        TS_ASSERT(response->getExtensions()==NULL);
+        TS_ASSERT(response->getStatus()!=NULL);
+        TS_ASSERT(response->getPayload()!=NULL);
+    }
+
+    void testSingleElementMarshall() {
+        ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse();
+        TS_ASSERT(response!=NULL);
+
+        response->setID(expectedID);
+        response->setIssueInstant(expectedIssueInstant);
+        //response->setVersion(expectedVersion);
+        assertEquals(expectedDOM, response);
+    }
+
+    void testSingleElementOptionalAttributesMarshall() {
+        ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse();
+        TS_ASSERT(response!=NULL);
+
+        response->setID(expectedID);
+        response->setInResponseTo(expectedInResponseTo);
+        response->setIssueInstant(expectedIssueInstant);
+        //response->setVersion(expectedVersion);
+        response->setConsent(expectedConsent);
+        response->setDestination(expectedDestination);
+        response->setInResponseTo(expectedInResponseTo);
+        assertEquals(expectedOptionalAttributesDOM, response);
+    }
+
+    void testChildElementsMarshall() {
+        ArtifactResponse* response = ArtifactResponseBuilder::buildArtifactResponse();
+        TS_ASSERT(response!=NULL);
+
+        response->setID(expectedID);
+        response->setIssueInstant(expectedIssueInstant);
+        // Do this just so don't have to redeclare the saml namespace prefix on every child element in the control XML file
+        Namespace* ns = new Namespace(opensaml::SAMLConstants::SAML20_NS, opensaml::SAMLConstants::SAML20_PREFIX);
+        response->addNamespace(*ns);
+        response->setIssuer(IssuerBuilder::buildIssuer());
+        response->setStatus(StatusBuilder::buildStatus());
+
+        AuthnRequest* authnRequest = AuthnRequestBuilder::buildAuthnRequest();
+        authnRequest->setIssueInstant(expectedIssueInstant);
+        authnRequest->setID(authnRequestID);
+        response->setPayload(authnRequest);
+
+        assertEquals(expectedChildElementsDOM, response);
+        delete ns;
+    }
+
+};