2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include "internal.h"
\r
18 #include <saml/saml2/metadata/MetadataProvider.h>
\r
20 using namespace opensaml::saml2md;
\r
22 class FilesystemMetadataProviderTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
\r
24 XMLCh* supportedProtocol;
\r
25 XMLCh* supportedProtocol2;
\r
26 MetadataProvider* metadataProvider;
\r
30 entityID=XMLString::transcode("urn:mace:incommon:washington.edu");
\r
31 supportedProtocol=XMLString::transcode("urn:oasis:names:tc:SAML:1.1:protocol");
\r
32 supportedProtocol2=XMLString::transcode("urn:mace:shibboleth:1.0");
\r
34 auto_ptr_XMLCh MP("MetadataProvider");
\r
35 auto_ptr_XMLCh path("path");
\r
36 auto_ptr_XMLCh validate("validate");
\r
37 string s=data_path + "saml2/metadata/InCommon-metadata.xml";
\r
38 auto_ptr_XMLCh file(s.c_str());
\r
39 DOMDocument* doc=XMLToolingConfig::getConfig().getParser().newDocument();
\r
40 XercesJanitor<DOMDocument> janitor(doc);
\r
41 DOMElement* root=doc->createElementNS(NULL,MP.get());
\r
42 root->setAttributeNS(NULL,path.get(),file.get());
\r
43 root->setAttributeNS(NULL,validate.get(),XMLConstants::XML_ZERO);
\r
44 metadataProvider = NULL;
\r
45 metadataProvider = SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,root);
\r
46 metadataProvider->init();
\r
48 SAMLObjectBaseTestCase::setUp();
\r
52 XMLString::release(&entityID);
\r
53 XMLString::release(&supportedProtocol);
\r
54 delete metadataProvider;
\r
55 SAMLObjectBaseTestCase::tearDown();
\r
58 void testEntityDescriptor() {
\r
59 Locker locker(metadataProvider);
\r
60 const EntityDescriptor* descriptor = metadataProvider->getEntityDescriptor(entityID);
\r
61 TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL);
\r
62 assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID());
\r
63 TSM_ASSERT_EQUALS("Unexpected number of roles", 1, descriptor->getIDPSSODescriptors().size());
\r
64 TSM_ASSERT("Role lookup failed", descriptor->getIDPSSODescriptor(supportedProtocol)!=NULL);
\r
65 TSM_ASSERT("Role lookup failed", descriptor->getIDPSSODescriptor(supportedProtocol2)!=NULL);
\r