Change license header, remove stale pkg files.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / IDPEntry20Test.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 #include "internal.h"
22 #include <saml/saml2/core/Protocols.h>
23 #include <saml/util/SAMLConstants.h>
24
25 using namespace opensaml::saml2p;
26 using namespace opensaml::saml2;
27
28 class IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
29     XMLCh* expectedProviderID; 
30     XMLCh* expectedName; 
31     XMLCh* expectedLoc;
32
33 public:
34     void setUp() {
35         expectedProviderID = XMLString::transcode("urn:string:providerid");; 
36         expectedName = XMLString::transcode("Example IdP"); 
37         expectedLoc = XMLString::transcode("http://idp.example.org/endpoint"); 
38
39         singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml";
40         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml";
41         SAMLObjectBaseTestCase::setUp();
42     }
43     
44     void tearDown() {
45         XMLString::release(&expectedProviderID);
46         XMLString::release(&expectedName);
47         XMLString::release(&expectedLoc);
48         SAMLObjectBaseTestCase::tearDown();
49     }
50
51     void testSingleElementUnmarshall() {
52         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
53         IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());
54         TS_ASSERT(entry!=nullptr);
55         assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());
56     }
57
58     void testSingleElementOptionalAttributesUnmarshall() {
59         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
60         IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());
61         TS_ASSERT(entry!=nullptr);
62         assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());
63         assertEquals("Name attribute", expectedName, entry->getName());
64         assertEquals("Loc attribute", expectedLoc, entry->getLoc());
65     }
66
67     void testSingleElementMarshall() {
68         IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
69         entry->setProviderID(expectedProviderID);
70         assertEquals(expectedDOM, entry);
71     }
72
73     void testSingleElementOptionalAttributesMarshall() {
74         IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
75         entry->setProviderID(expectedProviderID);
76         entry->setName(expectedName);
77         entry->setLoc(expectedLoc);
78         assertEquals(expectedOptionalAttributesDOM, entry);
79     }
80
81 };