Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / NameIDPolicy20Test.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/Protocols.h>
19 #include <saml/util/SAMLConstants.h>
20
21 using namespace opensaml::saml2p;
22 using namespace opensaml::saml2;
23
24 class NameIDPolicy20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
25     XMLCh* expectedFormat; 
26     XMLCh* expectedSPNameQualifier; 
27     bool expectedAllowCreate;
28
29 public:
30     void setUp() {
31         expectedFormat = XMLString::transcode("urn:string:format");; 
32         expectedSPNameQualifier = XMLString::transcode("urn:string:spname"); 
33         expectedAllowCreate=true;
34
35         singleElementFile = data_path + "saml2/core/impl/NameIDPolicy.xml";
36         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDPolicyOptionalAttributes.xml";
37         SAMLObjectBaseTestCase::setUp();
38     }
39     
40     void tearDown() {
41         XMLString::release(&expectedFormat);
42         XMLString::release(&expectedSPNameQualifier);
43         SAMLObjectBaseTestCase::tearDown();
44     }
45
46     void testSingleElementUnmarshall() {
47         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
48         NameIDPolicy* policy = dynamic_cast<NameIDPolicy*>(xo.get());
49         TS_ASSERT(policy!=nullptr);
50         TSM_ASSERT_EQUALS("AllowCreate attribute presence", xmlconstants::XML_BOOL_NULL, policy->getAllowCreate());
51     }
52
53     void testSingleElementOptionalAttributesUnmarshall() {
54         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
55         NameIDPolicy* policy = dynamic_cast<NameIDPolicy*>(xo.get());
56         TS_ASSERT(policy!=nullptr);
57         assertEquals("Format attribute", expectedFormat, policy->getFormat());
58         assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, policy->getSPNameQualifier());
59         TSM_ASSERT_DIFFERS("AllowCreate attribute presence", xmlconstants::XML_BOOL_NULL, policy->getAllowCreate());
60         TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate());
61     }
62
63     void testSingleElementMarshall() {
64         NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy();
65         assertEquals(expectedDOM, policy);
66     }
67
68     void testSingleElementOptionalAttributesMarshall() {
69         NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy();
70         policy->setFormat(expectedFormat);
71         policy->setSPNameQualifier(expectedSPNameQualifier);
72         policy->AllowCreate(expectedAllowCreate);
73         assertEquals(expectedOptionalAttributesDOM, policy);
74     }
75
76 };