2 * Copyright 2001-2005 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 "XMLObjectBaseTestCase.h"
\r
20 #include <xmltooling/signature/KeyInfo.h>
\r
22 class KeyInfoTest : public CxxTest::TestSuite {
\r
27 XMLObjectBuilder::registerDefaultBuilder(new AnyElementBuilder());
\r
31 XMLObjectBuilder::deregisterDefaultBuilder();
\r
34 void testKeyInfo1() {
\r
35 TS_TRACE("testKeyInfo1");
\r
37 string path=data_path + "KeyInfo1.xml";
\r
38 ifstream fs(path.c_str());
\r
39 DOMDocument* doc=validatingPool->parse(fs);
\r
40 TS_ASSERT(doc!=NULL);
\r
42 const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());
\r
45 auto_ptr<KeyInfo> kiObject(
\r
46 dynamic_cast<KeyInfo*>(b->buildFromDocument(doc))
\r
48 TS_ASSERT(kiObject.get()!=NULL);
\r
49 TSM_ASSERT_EQUALS("Number of child elements was not expected value",
\r
50 3, kiObject->getOrderedChildren().size());
\r
51 TSM_ASSERT_EQUALS("Number of child elements was not expected value",
\r
52 1, kiObject->getKeyValues().size());
\r
53 TSM_ASSERT_EQUALS("Number of child elements was not expected value",
\r
54 1, kiObject->getX509Datas().front()->getX509Certificates().size());
\r
56 auto_ptr_XMLCh expected("Public Key for CN=xmldap.org, OU=Domain Control Validated, O=xmldap.org");
\r
57 TSM_ASSERT_SAME_DATA("KeyName was not expected value",
\r
58 expected.get(), kiObject->getKeyNames().front()->getName(), XMLString::stringLen(expected.get()));
\r