Convert from NULL macro to nullptr, remove unused zlib code.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / AuthnContext20Test.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 AuthnContext20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
24
25 public:
26     void setUp() {
27         singleElementFile = data_path + "saml2/core/impl/AuthnContext.xml";
28         childElementsFile  = data_path + "saml2/core/impl/AuthnContextChildElements.xml";    
29         SAMLObjectBaseTestCase::setUp();
30     }
31     
32     void tearDown() {
33         SAMLObjectBaseTestCase::tearDown();
34     }
35
36     void testSingleElementUnmarshall() {
37         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
38         AuthnContext* ac = dynamic_cast<AuthnContext*>(xo.get());
39         TS_ASSERT(ac!=nullptr);
40
41         TS_ASSERT(ac->getAuthnContextClassRef()==nullptr);
42         TS_ASSERT(ac->getAuthnContextDecl()==nullptr);
43         TS_ASSERT(ac->getAuthnContextDeclRef()==nullptr);
44         TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 0, ac->getAuthenticatingAuthoritys().size());
45     }
46
47     void testChildElementsUnmarshall() {
48         auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
49         AuthnContext* ac= dynamic_cast<AuthnContext*>(xo.get());
50         TS_ASSERT(ac!=nullptr);
51
52         TS_ASSERT(ac->getAuthnContextClassRef()!=nullptr);
53         TS_ASSERT(ac->getAuthnContextDecl()==nullptr);
54         TS_ASSERT(ac->getAuthnContextDeclRef()!=nullptr);
55         TSM_ASSERT_EQUALS("# of AuthenticatingAuthority child elements", 2, ac->getAuthenticatingAuthoritys().size());
56     }
57
58     void testSingleElementMarshall() {
59         AuthnContext* ac=AuthnContextBuilder::buildAuthnContext();
60         assertEquals(expectedDOM, ac);
61     }
62
63     void testChildElementsMarshall() {
64         AuthnContext* ac=AuthnContextBuilder::buildAuthnContext();
65         ac->setAuthnContextClassRef(AuthnContextClassRefBuilder::buildAuthnContextClassRef());
66         ac->setAuthnContextDeclRef(AuthnContextDeclRefBuilder::buildAuthnContextDeclRef());
67         ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority());
68         ac->getAuthenticatingAuthoritys().push_back(AuthenticatingAuthorityBuilder::buildAuthenticatingAuthority());
69         assertEquals(expectedChildElementsDOM, ac);
70     }
71
72 };