Пример #1
0
    def testAccessors(self):
        """Test for AuthnStatement accessors"""
        self.authn_statem.authn_instant = "2007-08-31T01:05:02Z"
        self.authn_statem.session_not_on_or_after = "2007-09-14T01:05:02Z"
        self.authn_statem.session_index = "sessionindex"
        self.authn_statem.authn_context = saml.AuthnContext()
        self.authn_statem.authn_context.authn_context_class_ref = saml.authn_context_class_ref_from_string(
            saml2_data.TEST_AUTHN_CONTEXT_CLASS_REF
        )
        self.authn_statem.authn_context.authn_context_decl_ref = saml.authn_context_decl_ref_from_string(
            saml2_data.TEST_AUTHN_CONTEXT_DECL_REF
        )
        self.authn_statem.authn_context.authn_context_decl = saml.authn_context_decl_from_string(
            saml2_data.TEST_AUTHN_CONTEXT_DECL
        )
        self.authn_statem.authn_context.authenticating_authority.append(
            saml.authenticating_authority_from_string(saml2_data.TEST_AUTHENTICATING_AUTHORITY)
        )

        new_as = saml.authn_statement_from_string(self.authn_statem.to_string())
        assert new_as.authn_instant == "2007-08-31T01:05:02Z"
        assert new_as.session_index == "sessionindex"
        assert new_as.session_not_on_or_after == "2007-09-14T01:05:02Z"
        assert (
            new_as.authn_context.authn_context_class_ref.text.strip() == "http://www.example.com/authnContextClassRef"
        )
        assert new_as.authn_context.authn_context_decl_ref.text.strip() == "http://www.example.com/authnContextDeclRef"
        assert new_as.authn_context.authn_context_decl.text.strip() == "http://www.example.com/authnContextDecl"
        assert (
            new_as.authn_context.authenticating_authority[0].text.strip()
            == "http://www.example.com/authenticatingAuthority"
        )
        assert self.authn_statem.to_string() == new_as.to_string()
Пример #2
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)
Пример #3
0
 def testUsingTestData(self):
     """Test authn_statement_from_string() using test data"""
     authn_statem = saml.authn_statement_from_string(saml2_data.TEST_AUTHN_STATEMENT)
     assert authn_statem.authn_instant == "2007-08-31T01:05:02Z"
     assert authn_statem.session_not_on_or_after == "2007-09-14T01:05:02Z"
     assert authn_statem.authn_context.authn_context_class_ref.text.strip() == saml.AUTHN_PASSWORD