While struggling with the forgery, thought I'd move on to actually testing
the auth. Unable to get the test to pass, I've continued to simplify it down
to this, still with no success:

    def test_valid_login(self):
        """Login form should authorize a user with valid credentials"""
        resp = self.app.get('/login', status=200)
        form = resp.form
        form['login'] = u'username'
        form['password'] = u'password'

        login_handler = form.submit(status=302)
        logged_in_page = login_handler.follow(status=200)

I have no problems logging in through a browser in my development
environment, and I have verified that the proper user with username
(username) and password (password) also exists in the test database.

On Fri, Aug 13, 2010 at 4:35 PM, Ryan McKillen <r...@ubercab.com> wrote:

> Hey all, I'm new to the Python world and was happy to find such a great
> framework for authentication and authorization. I used the quickstart plugin
> and was up and running without any difficulty.
> Writing functional tests for our Pylons app has proven to be a challenge. I
> decided to start by forging/bypassing the authentication with the help
> of repoze.who.plugins.testutil. Looking at the instructions at
> http://code.gustavonarea.net/repoze.who-testutil/HowTo/Reconfiguring.html,
> they don't seem to be written with the quickstart plugin in mind.
> My configuration consists of this in the middleware.py:
> app = add_auth(app)
> Which loads this add_auth function:
> def add_auth(app):
>     return setup_sql_auth(app, User, Group, Permission, Session,
>         login_url = '/login',
>         login_handler = '/authenticate',
>         post_login_url = '/dashboard',
>         logout_handler = '/logout',
>         post_logout_url = '/login',
>         cookie_secret = 'abc',
>         translations = {
>             'user_name': 'nickname',
>             'group_name': 'name',
>             'permission_name': 'name'})
> Can someone point me in the right direction?
> Thanks,
> Ryan
Repoze-dev mailing list

Reply via email to