Esempio n. 1
0
    def test_update__handle_mismatch(self):
        from openidalchemy.models import Association
        from openid import association

        assoc = Association('http://example.com', '<handle>', 'secret', int(time.time()), 3600, 'HMAC-SHA1')
        openid_assoc = association.Association('<otherhandle>', 'secret', int(time.time()), 7200, 'HMAC-SHA1')
        self.assertRaises(ValueError, lambda: assoc.update(openid_assoc))
Esempio n. 2
0
    def test_update(self):
        from openidalchemy.models import Association
        from openid import association

        assoc = Association('http://example.com', '<handle>', 'secret', 1234567, 3600, 'HMAC-SHA1')
        openid_assoc = association.Association('<handle>', 's3kr3t', 12345678, 7200, 'HMAC-SHA256')
        assoc.update(openid_assoc)

        self.assertEquals(assoc.handle, '<handle>')
        self.assertEquals(assoc.secret, 's3kr3t')
        self.assertEquals(assoc.issued, 12345678)
        self.assertEquals(assoc.lifetime, 7200)
        self.assertEquals(assoc.assoc_type, 'HMAC-SHA256')
Esempio n. 3
0
    def storeAssociation(self, server_url, association):
        """Set the association for the server URL."""
        assoc = self.session.query(AssociationModel).get((server_url, association.handle))

        if assoc is None:
            assoc = AssociationModel.fromOpenIdAssociation(server_url, association)
        else:
            assoc.update(association)

        self.session.add(assoc)
Esempio n. 4
0
    def test_fromOpenIdAssociation(self):
        from openidalchemy.models import Association
        from openid import association

        openid_assoc = association.Association('<handle>', 's3kr3t', 12345678, 7200, 'HMAC-SHA256')
        assoc = Association.fromOpenIdAssociation('http://example.com', openid_assoc)

        self.assertEquals(assoc.server_url, 'http://example.com')
        self.assertEquals(assoc.handle, '<handle>')
        self.assertEquals(assoc.secret, 's3kr3t')
        self.assertEquals(assoc.issued, 12345678)
        self.assertEquals(assoc.lifetime, 7200)
        self.assertEquals(assoc.assoc_type, 'HMAC-SHA256')