Change license header, remove stale pkg files.
[shibboleth/cpp-opensaml.git] / samltest / saml2 / core / impl / Issuer20Test.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/Assertions.h>
23 #include <saml/util/SAMLConstants.h>
24
25 using namespace opensaml::saml2;
26
27 class Issuer20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
28     XMLCh* expectedNameQualifier; 
29     XMLCh* expectedSPNameQualifier; 
30     XMLCh* expectedFormat; 
31     XMLCh* expectedSPProvidedID; 
32     XMLCh* expectedContent; 
33
34 public:
35     void setUp() {
36         expectedNameQualifier = XMLString::transcode("nq"); 
37         expectedSPNameQualifier = XMLString::transcode("spnq"); 
38         expectedFormat = XMLString::transcode("format"); 
39         expectedSPProvidedID = XMLString::transcode("spID"); 
40         expectedContent = XMLString::transcode("someIssuer"); 
41
42         singleElementFile = data_path + "saml2/core/impl/Issuer.xml";
43         singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IssuerOptionalAttributes.xml";
44         SAMLObjectBaseTestCase::setUp();
45     }
46     
47     void tearDown() {
48         XMLString::release(&expectedNameQualifier);
49         XMLString::release(&expectedSPNameQualifier);
50         XMLString::release(&expectedFormat);
51         XMLString::release(&expectedSPProvidedID);
52         XMLString::release(&expectedContent);
53         SAMLObjectBaseTestCase::tearDown();
54     }
55
56     void testSingleElementUnmarshall() {
57         auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
58         Issuer* issuer = dynamic_cast<Issuer*>(xo.get());
59         TS_ASSERT(issuer!=nullptr);
60
61         assertEquals("Element content", expectedContent, issuer->getName());
62     }
63
64     void testSingleElementOptionalAttributesUnmarshall() {
65         auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
66         Issuer* issuer = dynamic_cast<Issuer*>(xo.get());
67         TS_ASSERT(issuer!=nullptr);
68
69         assertEquals("NameQualifier attribute", expectedNameQualifier, issuer->getNameQualifier());
70         assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, issuer->getSPNameQualifier());
71         assertEquals("Format attribute", expectedFormat, issuer->getFormat());
72         assertEquals("SPProvidedID attribute", expectedSPProvidedID, issuer->getSPProvidedID());
73         assertEquals("Element content", expectedContent, issuer->getName());
74     }
75
76
77     void testSingleElementMarshall() {
78         Issuer* issuer = IssuerBuilder::buildIssuer();
79         TS_ASSERT(issuer!=nullptr);
80
81         issuer->setName(expectedContent);
82         assertEquals(expectedDOM, issuer);
83     }
84
85     void testSingleElementOptionalAttributesMarshall() {
86         Issuer* issuer = IssuerBuilder::buildIssuer();
87         TS_ASSERT(issuer!=nullptr);
88
89         issuer->setNameQualifier(expectedNameQualifier);
90         issuer->setSPNameQualifier(expectedSPNameQualifier);
91         issuer->setFormat(expectedFormat);
92         issuer->setSPProvidedID(expectedSPProvidedID);
93         issuer->setName(expectedContent);
94         assertEquals(expectedOptionalAttributesDOM, issuer);
95     }
96
97 };