X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=samltest%2Fsaml2%2Fprofile%2FSAML2PolicyTest.h;h=82e02fcaee5943a568367b71acd5a7fbfeefbeb1;hb=bffe345d60acc05377a243f42f042b98d1e41b9c;hp=3f3b95826d53b6ccc0551bfee1ddfd6b932beed3;hpb=df39928338a40f7a2980406e9737893289673611;p=shibboleth%2Fcpp-opensaml.git diff --git a/samltest/saml2/profile/SAML2PolicyTest.h b/samltest/saml2/profile/SAML2PolicyTest.h index 3f3b958..82e02fc 100644 --- a/samltest/saml2/profile/SAML2PolicyTest.h +++ b/samltest/saml2/profile/SAML2PolicyTest.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include "internal.h" #include +#include #include #include @@ -24,18 +25,18 @@ using namespace opensaml; class SAML2PolicyTest : public CxxTest::TestSuite { SecurityPolicy* m_policy; - SecurityPolicyRule* m_rule; + vector m_rules; public: void setUp() { m_policy = NULL; - m_rule = NULL; - m_rule = SAMLConfig::getConfig().SecurityPolicyRuleManager.newPlugin(CONDITIONS_POLICY_RULE, NULL); + m_rules.push_back(SAMLConfig::getConfig().SecurityPolicyRuleManager.newPlugin(CONDITIONS_POLICY_RULE, NULL)); + m_rules.push_back(SAMLConfig::getConfig().SecurityPolicyRuleManager.newPlugin(BEARER_POLICY_RULE, NULL)); m_policy = new SecurityPolicy(); - m_policy->getRules().push_back(m_rule); + m_policy->getRules().assign(m_rules.begin(), m_rules.end()); } void tearDown() { - delete m_rule; + for_each(m_rules.begin(), m_rules.end(), xmltooling::cleanup()); delete m_policy; } @@ -51,10 +52,18 @@ public: ); janitor.release(); + auto_ptr_XMLCh requestID("_12345"); + m_policy->setCorrelationID(requestID.get()); + TSM_ASSERT_THROWS("Policy should have tripped on AudienceRestriction", m_policy->evaluate(*assertion.get()), SecurityPolicyException); auto_ptr_XMLCh recipient("https://sp.example.org"); m_policy->getAudiences().push_back(recipient.get()); + TSM_ASSERT_THROWS("Policy should have tripped on InResponseTo correlation", m_policy->evaluate(*assertion.get()), SecurityPolicyException); + + dynamic_cast( + assertion->getSubject()->getSubjectConfirmations().front()->getSubjectConfirmationData() + )->setInResponseTo(requestID.get()); m_policy->evaluate(*assertion.get()); } catch (exception& ex) {