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/core/Protocols.h>
\r
19 #include <xmltooling/encryption/Encryption.h>
\r
20 #include <xmltooling/util/XMLConstants.h>
\r
22 using namespace opensaml;
\r
23 using namespace opensaml::saml2p;
\r
24 using namespace xmlencryption;
\r
26 class NewEncryptedID20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
\r
30 singleElementFile = data_path + "saml2/core/impl/NewEncryptedID.xml";
\r
31 childElementsFile = data_path + "saml2/core/impl/NewEncryptedIDChildElements.xml";
\r
32 SAMLObjectBaseTestCase::setUp();
\r
36 SAMLObjectBaseTestCase::tearDown();
\r
39 void testSingleElementUnmarshall() {
\r
40 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
\r
41 NewEncryptedID* encID = dynamic_cast<NewEncryptedID*>(xo.get());
\r
42 TS_ASSERT(encID!=NULL);
\r
43 TSM_ASSERT("EncryptedData child element", encID->getEncryptedData()==NULL);
\r
44 TSM_ASSERT_EQUALS("# of EncryptedKey child elements", 0, encID->getEncryptedKeys().size());
\r
47 void testChildElementsUnmarshall() {
\r
48 auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
\r
49 NewEncryptedID* encID = dynamic_cast<NewEncryptedID*>(xo.get());
\r
50 TS_ASSERT(encID!=NULL);
\r
51 TSM_ASSERT("EncryptedData child element", encID->getEncryptedData()!=NULL);
\r
52 TSM_ASSERT_EQUALS("# of EncryptedKey child elements", 2, encID->getEncryptedKeys().size());
\r
55 void testSingleElementMarshall() {
\r
56 NewEncryptedID* encID=NewEncryptedIDBuilder::buildNewEncryptedID();
\r
57 assertEquals(expectedDOM, encID);
\r
60 void testChildElementsMarshall() {
\r
61 NewEncryptedID* encID=NewEncryptedIDBuilder::buildNewEncryptedID();
\r
62 // Do this just so don't have to redeclare the xenc namespace prefix on every child element in the control XML file
\r
63 Namespace* ns = new Namespace(xmltooling::XMLConstants::XMLENC_NS, xmltooling::XMLConstants::XMLENC_PREFIX);
\r
64 encID->addNamespace(*ns);
\r
65 encID->setEncryptedData(EncryptedDataBuilder::buildEncryptedData());
\r
66 encID->getEncryptedKeys().push_back(EncryptedKeyBuilder::buildEncryptedKey());
\r
67 encID->getEncryptedKeys().push_back(EncryptedKeyBuilder::buildEncryptedKey());
\r
68 assertEquals(expectedChildElementsDOM, encID);
\r