Update copyright.
[shibboleth/cpp-xmltooling.git] / xmltoolingtest / FilesystemCredentialResolverTest.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "XMLObjectBaseTestCase.h"
18
19 #include <xmltooling/signature/CredentialResolver.h>
20
21 #include <fstream>
22
23 class FilesystemCredentialResolverTest : public CxxTest::TestSuite {
24 public:
25     void setUp() {
26     }
27     
28     void tearDown() {
29     }
30
31     void testFilesystemProvider() {
32         string config = data_path + "FilesystemCredentialResolver.xml";
33         ifstream in(config.c_str());
34         DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);
35         XercesJanitor<DOMDocument> janitor(doc);
36
37         auto_ptr<CredentialResolver> credResolver(
38             XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin(
39                 FILESYSTEM_CREDENTIAL_RESOLVER,doc->getDocumentElement()
40                 )
41             );
42
43         Locker locker(credResolver.get());
44         auto_ptr<XSECCryptoKey> key(credResolver->getKey());
45         TSM_ASSERT("Retrieved key was null", key.get()!=NULL);
46         TSM_ASSERT_EQUALS("Unexpected number of certificates", 1, credResolver->getCertificates().size());
47     }
48 };