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