2 * Copyright 2001-2010 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <saml/saml2/core/Protocols.h>
19 #include <saml/util/SAMLConstants.h>
21 using namespace opensaml::saml2p;
22 using namespace opensaml::saml2;
24 class IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
25 XMLCh* expectedProviderID;
31 expectedProviderID = XMLString::transcode("urn:string:providerid");;
32 expectedName = XMLString::transcode("Example IdP");
33 expectedLoc = XMLString::transcode("http://idp.example.org/endpoint");
35 singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml";
36 singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml";
37 SAMLObjectBaseTestCase::setUp();
41 XMLString::release(&expectedProviderID);
42 XMLString::release(&expectedName);
43 XMLString::release(&expectedLoc);
44 SAMLObjectBaseTestCase::tearDown();
47 void testSingleElementUnmarshall() {
48 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
49 IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());
50 TS_ASSERT(entry!=nullptr);
51 assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());
54 void testSingleElementOptionalAttributesUnmarshall() {
55 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
56 IDPEntry* entry = dynamic_cast<IDPEntry*>(xo.get());
57 TS_ASSERT(entry!=nullptr);
58 assertEquals("ProviderID attribute", expectedProviderID, entry->getProviderID());
59 assertEquals("Name attribute", expectedName, entry->getName());
60 assertEquals("Loc attribute", expectedLoc, entry->getLoc());
63 void testSingleElementMarshall() {
64 IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
65 entry->setProviderID(expectedProviderID);
66 assertEquals(expectedDOM, entry);
69 void testSingleElementOptionalAttributesMarshall() {
70 IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
71 entry->setProviderID(expectedProviderID);
72 entry->setName(expectedName);
73 entry->setLoc(expectedLoc);
74 assertEquals(expectedOptionalAttributesDOM, entry);