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 NameIDPolicy20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase {
\r
25 XMLCh* expectedFormat;
\r
26 XMLCh* expectedSPNameQualifier;
\r
27 bool expectedAllowCreate;
\r
31 expectedFormat = XMLString::transcode("urn:string:format");;
\r
32 expectedSPNameQualifier = XMLString::transcode("urn:string:spname");
\r
33 expectedAllowCreate=true;
\r
35 singleElementFile = data_path + "saml2/core/impl/NameIDPolicy.xml";
\r
36 singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDPolicyOptionalAttributes.xml";
\r
37 SAMLObjectBaseTestCase::setUp();
\r
41 XMLString::release(&expectedFormat);
\r
42 XMLString::release(&expectedSPNameQualifier);
\r
43 SAMLObjectBaseTestCase::tearDown();
\r
46 void testSingleElementUnmarshall() {
\r
47 auto_ptr<XMLObject> xo(unmarshallElement(singleElementFile));
\r
48 NameIDPolicy* policy = dynamic_cast<NameIDPolicy*>(xo.get());
\r
49 TS_ASSERT(policy!=NULL);
\r
50 TSM_ASSERT_EQUALS("AllowCreate attribute presence", false, policy->AllowCreate().first);
\r
53 void testSingleElementOptionalAttributesUnmarshall() {
\r
54 auto_ptr<XMLObject> xo(unmarshallElement(singleElementOptionalAttributesFile));
\r
55 NameIDPolicy* policy = dynamic_cast<NameIDPolicy*>(xo.get());
\r
56 TS_ASSERT(policy!=NULL);
\r
57 assertEquals("Format attribute", expectedFormat, policy->getFormat());
\r
58 assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, policy->getSPNameQualifier());
\r
59 TSM_ASSERT_EQUALS("AllowCreate attribute presence", true, policy->AllowCreate().first);
\r
60 TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate().second);
\r
63 void testSingleElementMarshall() {
\r
64 NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy();
\r
65 assertEquals(expectedDOM, policy);
\r
68 void testSingleElementOptionalAttributesMarshall() {
\r
69 NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy();
\r
70 policy->setFormat(expectedFormat);
\r
71 policy->setSPNameQualifier(expectedSPNameQualifier);
\r
72 policy->AllowCreate(expectedAllowCreate);
\r
73 assertEquals(expectedOptionalAttributesDOM, policy);
\r