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 MetadataProvider* metadataProvider;
\r
29 entityID=XMLString::transcode("urn:mace:incommon:washington.edu");
\r
30 supportedProtocol=XMLString::transcode("urn:oasis:names:tc:SAML:1.1:protocol");
\r
32 auto_ptr_XMLCh MP("MetadataProvider");
\r
33 auto_ptr_XMLCh path("path");
\r
34 auto_ptr_XMLCh validate("validate");
\r
35 string s=data_path + "saml2/metadata/InCommon-metadata.xml";
\r
36 auto_ptr_XMLCh file(s.c_str());
\r
37 DOMDocument* doc=XMLToolingConfig::getConfig().getParser().newDocument();
\r
38 XercesJanitor<DOMDocument> janitor(doc);
\r
39 DOMElement* root=doc->createElementNS(NULL,MP.get());
\r
40 root->setAttributeNS(NULL,path.get(),file.get());
\r
41 root->setAttributeNS(NULL,validate.get(),XMLConstants::XML_ZERO);
\r
42 metadataProvider = NULL;
\r
43 metadataProvider = SAMLConfig::getConfig().MetadataProviderManager.newPlugin(FILESYSTEM_METADATA_PROVIDER,root);
\r
44 metadataProvider->init();
\r
46 SAMLObjectBaseTestCase::setUp();
\r
50 XMLString::release(&entityID);
\r
51 XMLString::release(&supportedProtocol);
\r
52 delete metadataProvider;
\r
53 SAMLObjectBaseTestCase::tearDown();
\r
56 void testGetEntityDescriptor() {
\r
57 Locker locker(metadataProvider);
\r
58 const EntityDescriptor* descriptor = metadataProvider->lookup(entityID);
\r
59 TSM_ASSERT("Retrieved entity descriptor was null", descriptor!=NULL);
\r
60 assertEquals("Entity's ID does not match requested ID", entityID, descriptor->getEntityID());
\r