cc12ece0089d904a0a19ae42ec7c912fcfa98590
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / SubjectConfirmation20Test.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #include "internal.h"\r
18 #include <saml/saml2/core/Assertions.h>\r
19 #include <saml/util/SAMLConstants.h>\r
20 \r
21 using namespace opensaml::saml2;\r
22 \r
23 class SubjectConfirmation20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {\r
24     XMLCh* expectedMethod; \r
25 \r
26 public:\r
27     void setUp() {\r
28         expectedMethod = XMLString::transcode("urn:string:cm"); \r
29 \r
30         singleElementFile = data_path + "saml2/core/impl/SubjectConfirmation.xml";\r
31         childElementsFile  = data_path + "saml2/core/impl/SubjectConfirmationChildElements.xml";    \r
32         SAMLObjectBaseTestCase::setUp();\r
33     }\r
34     \r
35     void tearDown() {\r
36         XMLString::release(&expectedMethod);\r
37         SAMLObjectBaseTestCase::tearDown();\r
38     }\r
39 \r
40     void testSingleElementUnmarshall() {\r
41         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));\r
42         SubjectConfirmation* sc = dynamic_cast<SubjectConfirmation*>(xo.get());\r
43         TS_ASSERT(sc!=NULL);\r
44 \r
45         assertEquals("Method attribute", expectedMethod, sc->getMethod());\r
46 \r
47         TS_ASSERT(sc->getBaseID()==NULL);\r
48         TS_ASSERT(sc->getNameID()==NULL);\r
49         TS_ASSERT(sc->getEncryptedID()==NULL);\r
50         TS_ASSERT(sc->getSubjectConfirmationData()==NULL);\r
51     }\r
52 \r
53     void testChildElementsUnmarshall() {\r
54         auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));\r
55         SubjectConfirmation* sc= dynamic_cast<SubjectConfirmation*>(xo.get());\r
56         TS_ASSERT(sc!=NULL);\r
57 \r
58         TS_ASSERT(sc->getBaseID()==NULL);\r
59         TS_ASSERT(sc->getNameID()!=NULL);\r
60         TS_ASSERT(sc->getEncryptedID()==NULL);\r
61         TS_ASSERT(sc->getSubjectConfirmationData()!=NULL);\r
62     }\r
63 \r
64     void testSingleElementMarshall() {\r
65         SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation();\r
66         sc->setMethod(expectedMethod);\r
67         assertEquals(expectedDOM, sc);\r
68     }\r
69 \r
70     void testChildElementsMarshall() {\r
71         SubjectConfirmation* sc=SubjectConfirmationBuilder::buildSubjectConfirmation();\r
72         sc->setNameID(NameIDBuilder::buildNameID());\r
73         sc->setSubjectConfirmationData(SubjectConfirmationDataBuilder::buildSubjectConfirmationData());\r
74         assertEquals(expectedChildElementsDOM, sc);\r
75     }\r
76 \r
77 };\r