2 * Copyright 2001-2006 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <saml/saml2/core/Protocols.h>
19 #include <saml/util/SAMLConstants.h>
21 using namespace opensaml::saml2p;
22 using namespace opensaml::saml2;
24 class Scoping20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
25 int expectedProxycount;
29 expectedProxycount = 5;
30 singleElementFile = data_path + "saml2/core/impl/Scoping.xml";
31 singleElementOptionalAttributesFile = data_path + "saml2/core/impl/ScopingOptionalAttributes.xml";
32 childElementsFile = data_path + "saml2/core/impl/ScopingChildElements.xml";
33 SAMLObjectBaseTestCase::setUp();
37 SAMLObjectBaseTestCase::tearDown();
40 void testSingleElementUnmarshall() {
41 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
42 Scoping* scoping = dynamic_cast<Scoping*>(xo.get());
43 TS_ASSERT(scoping!=NULL);
45 TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first);
46 TS_ASSERT(scoping->getIDPList()==NULL);
47 TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size());
50 void testSingleElementOptionalAttributesUnmarshall() {
51 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
52 Scoping* scoping = dynamic_cast<Scoping*>(xo.get());
53 TS_ASSERT(scoping!=NULL);
55 TSM_ASSERT_EQUALS("ProxyCount attribute presence", true, scoping->getProxyCount().first);
56 TSM_ASSERT_EQUALS("ProxyCount attribute value", expectedProxycount, scoping->getProxyCount().second);
57 TS_ASSERT(scoping->getIDPList()==NULL);
58 TSM_ASSERT_EQUALS("# of RequesterID child elements", 0, scoping->getRequesterIDs().size());
61 void testChildElementsUnmarshall() {
62 auto_ptr<XMLObject> xo(unmarshallElement(childElementsFile));
63 Scoping* scoping= dynamic_cast<Scoping*>(xo.get());
64 TS_ASSERT(scoping!=NULL);
66 TSM_ASSERT_EQUALS("ProxyCount attribute presence", false, scoping->getProxyCount().first);
67 TS_ASSERT(scoping->getIDPList()!=NULL);
68 TSM_ASSERT_EQUALS("# of RequesterID child elements", 3, scoping->getRequesterIDs().size());
71 void testSingleElementMarshall() {
72 Scoping* scoping=ScopingBuilder::buildScoping();
73 assertEquals(expectedDOM, scoping);
76 void testSingleElementOptionalAttributesMarshall() {
77 Scoping* scoping=ScopingBuilder::buildScoping();
78 scoping->setProxyCount(expectedProxycount);
79 assertEquals(expectedOptionalAttributesDOM, scoping);
82 void testChildElementsMarshall() {
83 Scoping* scoping=ScopingBuilder::buildScoping();
84 scoping->setIDPList(IDPListBuilder::buildIDPList());
85 scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID());
86 scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID());
87 scoping->getRequesterIDs().push_back(RequesterIDBuilder::buildRequesterID());
88 assertEquals(expectedChildElementsDOM, scoping);