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