X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=blobdiff_plain;f=samltest%2Fsaml2%2Fprofile%2FSAML2PolicyTest.h;h=c5b80e0b3bfe99d76c141005daa70012da6ed438;hp=3f3b95826d53b6ccc0551bfee1ddfd6b932beed3;hb=69a716dedfd9e239bcc9206a7b8dc137b43f5f89;hpb=df39928338a40f7a2980406e9737893289673611 diff --git a/samltest/saml2/profile/SAML2PolicyTest.h b/samltest/saml2/profile/SAML2PolicyTest.h index 3f3b958..c5b80e0 100644 --- a/samltest/saml2/profile/SAML2PolicyTest.h +++ b/samltest/saml2/profile/SAML2PolicyTest.h @@ -24,18 +24,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 +51,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) {