Beispiel #1
0
def test_verify_identity_directive():
    class app(morepath.App):
        pass

    @app.verify_identity()
    def verify_identity(identity):
        return identity.password == 'right'

    identity = morepath.Identity('foo', password='******')
    assert not generic.verify_identity(identity, lookup=app().lookup)
    identity = morepath.Identity('foo', password='******')
    assert generic.verify_identity(identity, lookup=app().lookup)
Beispiel #2
0
def test_verify_identity_directive():
    class app(morepath.App):
        pass

    @app.verify_identity()
    def verify_identity(identity):
        return identity.password == 'right'

    dectate.commit(app)
    identity = morepath.Identity('foo', password='******')
    assert not generic.verify_identity(identity, lookup=app().lookup)
    identity = morepath.Identity('foo', password='******')
    assert generic.verify_identity(identity, lookup=app().lookup)
Beispiel #3
0
def test_verify_identity_directive():
    config = setup()
    app = morepath.App(testing_config=config)

    @app.verify_identity()
    def verify_identity(identity):
        return identity.password == 'right'

    config.commit()
    identity = morepath.Identity('foo', password='******')
    assert not generic.verify_identity(identity, lookup=app.lookup)
    identity = morepath.Identity('foo', password='******')
    assert generic.verify_identity(identity, lookup=app.lookup)
Beispiel #4
0
def test_default_verify_identity():
    class app(morepath.App):
        pass

    identity = morepath.Identity('foo')

    assert not generic.verify_identity(identity, lookup=app().lookup)
Beispiel #5
0
def test_default_verify_identity():
    config = setup()
    app = morepath.App(testing_config=config)
    config.commit()

    identity = morepath.Identity('foo')

    assert not generic.verify_identity(identity, lookup=app.lookup)
Beispiel #6
0
def test_default_verify_identity():
    class app(morepath.App):
        pass

    dectate.commit(app)

    identity = morepath.Identity('foo')

    assert not generic.verify_identity(identity, lookup=app().lookup)
Beispiel #7
0
    def identity(self):
        """Self-proclaimed identity of the user.

        The identity is established using the identity policy. Normally
        this would be an instance of :class:`morepath.security.Identity`.

        If no identity is claimed or established, or if the identity
        is not verified by the application, the identity is the the
        special value :attr:`morepath.security.NO_IDENTITY`.

        The identity can be used for authentication/authorization of
        the user, using Morepath permission directives.
        """
        # XXX annoying circular dependency
        from .security import NO_IDENTITY
        result = generic.identify(self, lookup=self.lookup,
                                  default=NO_IDENTITY)
        if not generic.verify_identity(result, lookup=self.lookup):
            return NO_IDENTITY
        return result