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.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <saml/saml2/core/Protocols.h>
23 #include <saml/util/SAMLConstants.h>
25 using namespace opensaml::saml2p;
26 using namespace opensaml::saml2;
28 class IDPEntry20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
29 XMLCh* expectedProviderID;
35 expectedProviderID = XMLString::transcode("urn:string:providerid");;
36 expectedName = XMLString::transcode("Example IdP");
37 expectedLoc = XMLString::transcode("http://idp.example.org/endpoint");
39 singleElementFile = data_path + "saml2/core/impl/IDPEntry.xml";
40 singleElementOptionalAttributesFile = data_path + "saml2/core/impl/IDPEntryOptionalAttributes.xml";
41 SAMLObjectBaseTestCase::setUp();
45 XMLString::release(&expectedProviderID);
46 XMLString::release(&expectedName);
47 XMLString::release(&expectedLoc);
48 SAMLObjectBaseTestCase::tearDown();
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());
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());
67 void testSingleElementMarshall() {
68 IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
69 entry->setProviderID(expectedProviderID);
70 assertEquals(expectedDOM, entry);
73 void testSingleElementOptionalAttributesMarshall() {
74 IDPEntry* entry=IDPEntryBuilder::buildIDPEntry();
75 entry->setProviderID(expectedProviderID);
76 entry->setName(expectedName);
77 entry->setLoc(expectedLoc);
78 assertEquals(expectedOptionalAttributesDOM, entry);