示例#1
0
    def testAccessors(self):
        """Test for Assertion accessors"""
        self.assertion.id = "assertion id"
        self.assertion.version = saml2.VERSION
        self.assertion.issue_instant = "2007-08-31T01:05:02Z"
        self.assertion.issuer = saml.issuer_from_string(saml2_data.TEST_ISSUER)
        self.assertion.signature = ds.signature_from_string(ds_data.TEST_SIGNATURE)
        self.assertion.subject = saml.subject_from_string(saml2_data.TEST_SUBJECT)
        self.assertion.conditions = saml.conditions_from_string(saml2_data.TEST_CONDITIONS)
        self.assertion.advice = saml.Advice()
        self.assertion.statement.append(saml.Statement())
        self.assertion.authn_statement.append(saml.authn_statement_from_string(saml2_data.TEST_AUTHN_STATEMENT))
        self.assertion.authz_decision_statement.append(saml.AuthzDecisionStatement())
        self.assertion.attribute_statement.append(
            saml.attribute_statement_from_string(saml2_data.TEST_ATTRIBUTE_STATEMENT)
        )

        new_assertion = saml.assertion_from_string(self.assertion.to_string())
        assert new_assertion.id == "assertion id"
        assert new_assertion.version == saml2.VERSION
        assert new_assertion.issue_instant == "2007-08-31T01:05:02Z"
        assert isinstance(new_assertion.issuer, saml.Issuer)
        assert isinstance(new_assertion.signature, ds.Signature)
        assert isinstance(new_assertion.subject, saml.Subject)
        assert isinstance(new_assertion.conditions, saml.Conditions)
        assert isinstance(new_assertion.advice, saml.Advice)
        assert isinstance(new_assertion.statement[0], saml.Statement)
        assert isinstance(new_assertion.authn_statement[0], saml.AuthnStatement)
        assert isinstance(new_assertion.authz_decision_statement[0], saml.AuthzDecisionStatement)
        assert isinstance(new_assertion.attribute_statement[0], saml.AttributeStatement)
示例#2
0
 def testUsingTestData(self):
     """Test conditions_from_string() using test data"""
     new_conditions = saml.conditions_from_string(saml2_data.TEST_CONDITIONS)
     assert new_conditions.not_before == "2007-08-31T01:05:02Z"
     assert new_conditions.not_on_or_after == "2007-09-14T01:05:02Z"
     assert isinstance(new_conditions.condition[0], saml.Condition)
     assert isinstance(new_conditions.audience_restriction[0], saml.AudienceRestriction)
     assert isinstance(new_conditions.one_time_use[0], saml.OneTimeUse)
     assert isinstance(new_conditions.proxy_restriction[0], saml.ProxyRestriction)
示例#3
0
 def testAccessors(self):
     """Test for Conditions accessors"""
     self.conditions.not_before = "2007-08-31T01:05:02Z"
     self.conditions.not_on_or_after = "2007-09-14T01:05:02Z"
     self.conditions.condition.append(saml.Condition())
     self.conditions.audience_restriction.append(saml.AudienceRestriction())
     self.conditions.one_time_use.append(saml.OneTimeUse())
     self.conditions.proxy_restriction.append(saml.ProxyRestriction())
     new_conditions = saml.conditions_from_string(self.conditions.to_string())
     assert new_conditions.not_before == "2007-08-31T01:05:02Z"
     assert new_conditions.not_on_or_after == "2007-09-14T01:05:02Z"
     assert isinstance(new_conditions.condition[0], saml.Condition)
     assert isinstance(new_conditions.audience_restriction[0], saml.AudienceRestriction)
     assert isinstance(new_conditions.one_time_use[0], saml.OneTimeUse)
     assert isinstance(new_conditions.proxy_restriction[0], saml.ProxyRestriction)