X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=samltest%2Fsaml1%2Fcore%2Fimpl%2FAuthenticationStatementTest.h;h=3a5a41db9c18815dc9df8d0596ed781f119b6bc5;hb=932cfaae2176c2eba1a9938dc420591a9551a7f3;hp=26e583dd0471298439be568e6e499c3e9e6db270;hpb=2c235cac370df082dd2f1462a06fcf6148b6b319;p=shibboleth%2Fcpp-opensaml.git diff --git a/samltest/saml1/core/impl/AuthenticationStatementTest.h b/samltest/saml1/core/impl/AuthenticationStatementTest.h index 26e583d..3a5a41d 100644 --- a/samltest/saml1/core/impl/AuthenticationStatementTest.h +++ b/samltest/saml1/core/impl/AuthenticationStatementTest.h @@ -1,93 +1,96 @@ -/* - * 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 - -using namespace opensaml::saml1; - -class AuthenticationStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { - XMLCh* expectedAuthenticationMethod; - XMLCh* expectedAuthenticationInstant; - -public: - void setUp() { - expectedAuthenticationInstant=XMLString::transcode("1970-01-02T01:01:02.123Z"); - expectedAuthenticationMethod=XMLString::transcode("trustme"); - singleElementFile = data_path + "saml1/core/impl/singleAuthenticationStatement.xml"; - singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAuthenticationStatementAttributes.xml"; - childElementsFile = data_path + "saml1/core/impl/AuthenticationStatementWithChildren.xml"; - SAMLObjectBaseTestCase::setUp(); - } - - void tearDown() { - XMLString::release(&expectedAuthenticationInstant); - XMLString::release(&expectedAuthenticationMethod); - SAMLObjectBaseTestCase::tearDown(); - } - - void testSingleElementUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementFile)); - AuthenticationStatement& as = dynamic_cast(*xo.get()); - TSM_ASSERT("AuthenticationMethod attribute present", as.getAuthenticationMethod()==NULL); - TSM_ASSERT("AuthenticationInstant attribute present", as.getAuthenticationInstant()==NULL); - - TSM_ASSERT("Subject element", as.getSubject()==NULL); - TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()==NULL); - TSM_ASSERT_EQUALS("AuthorityBinding element count", 0, as.getAuthorityBindings().size()); - } - - void testSingleElementOptionalAttributesUnmarshall() { - auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); - AuthenticationStatement& as = dynamic_cast(*xo.get()); - - TSM_ASSERT_SAME_DATA("AuthenticationMethod attribute", expectedAuthenticationMethod, as.getAuthenticationMethod(), XMLString::stringLen(expectedAuthenticationMethod)); - TSM_ASSERT_SAME_DATA("AuthenticationInstant attribute", expectedAuthenticationInstant, as.getAuthenticationInstant()->getRawData(), XMLString::stringLen(expectedAuthenticationInstant)); - } - - void testChildElementsUnmarshall() { - auto_ptr xo(unmarshallElement(childElementsFile)); - AuthenticationStatement& as = dynamic_cast(*xo.get()); - - TSM_ASSERT("Subject element", as.getSubject()!=NULL); - TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()!=NULL); - - TSM_ASSERT_EQUALS("AuthorityBinding element count", 2, as.getAuthorityBindings().size()); - as.getAuthorityBindings().erase(as.getAuthorityBindings().begin()); - TSM_ASSERT_EQUALS("AuthorityBinding element count", 1, as.getAuthorityBindings().size()); - } - - void testSingleElementMarshall() { - assertEquals(expectedDOM, AuthenticationStatementBuilder::buildAuthenticationStatement()); - } - - void testSingleElementOptionalAttributesMarshall() { - AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); - as->setAuthenticationInstant(expectedAuthenticationInstant); - as->setAuthenticationMethod(expectedAuthenticationMethod); - assertEquals(expectedOptionalAttributesDOM, as); - } - - void testChildElementsMarshall() { - AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); - as->setSubject(SubjectBuilder::buildSubject()); - as->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); - as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); - as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); - assertEquals(expectedChildElementsDOM, as); - } - -}; +/* + * Copyright 2001-2007 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 + +using namespace opensaml::saml1; + +class AuthenticationStatementTest : public CxxTest::TestSuite, public SAMLObjectBaseTestCase { + XMLCh* expectedAuthenticationMethod; + XMLCh* expectedAuthenticationInstant; + +public: + void setUp() { + expectedAuthenticationInstant=XMLString::transcode("1970-01-02T01:01:02.123Z"); + expectedAuthenticationMethod=XMLString::transcode("trustme"); + singleElementFile = data_path + "saml1/core/impl/singleAuthenticationStatement.xml"; + singleElementOptionalAttributesFile = data_path + "saml1/core/impl/singleAuthenticationStatementAttributes.xml"; + childElementsFile = data_path + "saml1/core/impl/AuthenticationStatementWithChildren.xml"; + SAMLObjectBaseTestCase::setUp(); + } + + void tearDown() { + XMLString::release(&expectedAuthenticationInstant); + XMLString::release(&expectedAuthenticationMethod); + SAMLObjectBaseTestCase::tearDown(); + } + + void testSingleElementUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementFile)); + AuthenticationStatement& as = dynamic_cast(*xo.get()); + TSM_ASSERT("AuthenticationMethod attribute present", as.getAuthenticationMethod()==NULL); + TSM_ASSERT("AuthenticationInstant attribute present", as.getAuthenticationInstant()==NULL); + + TSM_ASSERT("Subject element", as.getSubject()==NULL); + TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()==NULL); + TSM_ASSERT_EQUALS("AuthorityBinding element count", 0, as.getAuthorityBindings().size()); + } + + void testSingleElementOptionalAttributesUnmarshall() { + auto_ptr xo(unmarshallElement(singleElementOptionalAttributesFile)); + AuthenticationStatement& as = dynamic_cast(*xo.get()); + + assertEquals("AuthenticationMethod attribute", expectedAuthenticationMethod, as.getAuthenticationMethod()); + assertEquals("AuthenticationInstant attribute", expectedAuthenticationInstant, as.getAuthenticationInstant()->getRawData()); + } + + void testChildElementsUnmarshall() { + auto_ptr xo(unmarshallElement(childElementsFile)); + AuthenticationStatement& as1 = dynamic_cast(*xo.get()); + as1.releaseThisAndChildrenDOM(); + auto_ptr as2(as1.cloneAuthenticationStatement()); + AuthenticationStatement& as=*as2.get(); + + TSM_ASSERT("Subject element", as.getSubject()!=NULL); + TSM_ASSERT("SubjectLocality element", as.getSubjectLocality()!=NULL); + + TSM_ASSERT_EQUALS("AuthorityBinding element count", 2, as.getAuthorityBindings().size()); + as.getAuthorityBindings().erase(as.getAuthorityBindings().begin()); + TSM_ASSERT_EQUALS("AuthorityBinding element count", 1, as.getAuthorityBindings().size()); + } + + void testSingleElementMarshall() { + assertEquals(expectedDOM, AuthenticationStatementBuilder::buildAuthenticationStatement()); + } + + void testSingleElementOptionalAttributesMarshall() { + AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); + as->setAuthenticationInstant(expectedAuthenticationInstant); + as->setAuthenticationMethod(expectedAuthenticationMethod); + assertEquals(expectedOptionalAttributesDOM, as); + } + + void testChildElementsMarshall() { + AuthenticationStatement* as=AuthenticationStatementBuilder::buildAuthenticationStatement(); + as->setSubject(SubjectBuilder::buildSubject()); + as->setSubjectLocality(SubjectLocalityBuilder::buildSubjectLocality()); + as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); + as->getAuthorityBindings().push_back(AuthorityBindingBuilder::buildAuthorityBinding()); + assertEquals(expectedChildElementsDOM, as); + } + +};