X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=samltest%2Fsaml2%2Fcore%2Fimpl%2FNameIDPolicy20Test.h;h=587e9ade0386111aca832ef7472982dec1eb3246;hb=e9554c255ad3c91c7c4976e7a1a54905903e66a2;hp=27418c2394dea931a09971c8d8b0ce5b3390a609;hpb=31bc751c4d57cbefbcda84e5a6afc7dffee22dcf;p=shibboleth%2Fcpp-opensaml.git diff --git a/samltest/saml2/core/impl/NameIDPolicy20Test.h b/samltest/saml2/core/impl/NameIDPolicy20Test.h index 27418c2..587e9ad 100644 --- a/samltest/saml2/core/impl/NameIDPolicy20Test.h +++ b/samltest/saml2/core/impl/NameIDPolicy20Test.h @@ -1,76 +1,76 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal.h" -#include -#include - -using namespace opensaml::saml2p; -using namespace opensaml::saml2; - -class NameIDPolicy20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedFormat; - XMLCh* expectedSPNameQualifier; - bool expectedAllowCreate; - -public: - void setUp() { - expectedFormat = XMLString::transcode("urn:string:format");; - expectedSPNameQualifier = XMLString::transcode("urn:string:spname"); - expectedAllowCreate=true; - - singleElementFile = data_path + "saml2/core/impl/NameIDPolicy.xml"; - singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDPolicyOptionalAttributes.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedFormat); - XMLString::release(&expectedSPNameQualifier); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - NameIDPolicy* policy = dynamic_cast(xo.get()); - TS_ASSERT(policy!=NULL); - TSM_ASSERT_EQUALS("AllowCreate attribute presence", false, policy->AllowCreate().first); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - NameIDPolicy* policy = dynamic_cast(xo.get()); - TS_ASSERT(policy!=NULL); - assertEquals("Format attribute", expectedFormat, policy->getFormat()); - assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, policy->getSPNameQualifier()); - TSM_ASSERT_EQUALS("AllowCreate attribute presence", true, policy->AllowCreate().first); - TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate().second); - } - - void testSingleElementMarshall() { - NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); - assertEquals(expectedDOM, policy); - } - - void testSingleElementOptionalAttributesMarshall() { - NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); - policy->setFormat(expectedFormat); - policy->setSPNameQualifier(expectedSPNameQualifier); - policy->AllowCreate(expectedAllowCreate); - assertEquals(expectedOptionalAttributesDOM, policy); - } - -}; +/* + * Copyright 2001-2010 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal.h" +#include +#include + +using namespace opensaml::saml2p; +using namespace opensaml::saml2; + +class NameIDPolicy20Test : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedFormat; + XMLCh* expectedSPNameQualifier; + bool expectedAllowCreate; + +public: + void setUp() { + expectedFormat = XMLString::transcode("urn:string:format");; + expectedSPNameQualifier = XMLString::transcode("urn:string:spname"); + expectedAllowCreate=true; + + singleElementFile = data_path + "saml2/core/impl/NameIDPolicy.xml"; + singleElementOptionalAttributesFile = data_path + "saml2/core/impl/NameIDPolicyOptionalAttributes.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedFormat); + XMLString::release(&expectedSPNameQualifier); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + NameIDPolicy* policy = dynamic_cast(xo.get()); + TS_ASSERT(policy!=nullptr); + TSM_ASSERT_EQUALS("AllowCreate attribute presence", xmlconstants::XML_BOOL_NULL, policy->getAllowCreate()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + NameIDPolicy* policy = dynamic_cast(xo.get()); + TS_ASSERT(policy!=nullptr); + assertEquals("Format attribute", expectedFormat, policy->getFormat()); + assertEquals("SPNameQualifier attribute", expectedSPNameQualifier, policy->getSPNameQualifier()); + TSM_ASSERT_DIFFERS("AllowCreate attribute presence", xmlconstants::XML_BOOL_NULL, policy->getAllowCreate()); + TSM_ASSERT_EQUALS("AllowCreate attribute value", expectedAllowCreate, policy->AllowCreate()); + } + + void testSingleElementMarshall() { + NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); + assertEquals(expectedDOM, policy); + } + + void testSingleElementOptionalAttributesMarshall() { + NameIDPolicy* policy=NameIDPolicyBuilder::buildNameIDPolicy(); + policy->setFormat(expectedFormat); + policy->setSPNameQualifier(expectedSPNameQualifier); + policy->AllowCreate(expectedAllowCreate); + assertEquals(expectedOptionalAttributesDOM, policy); + } + +};