want a way to make a TestBrowser logged in as a particular user

Bug #646563 reported by Martin Pool
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

I'd like to use a TestBrowser to examine what happens when I'm logged in as a member of ~admins. According to lifeless, there is no builtin way to do this: you would think you could call BrowserTestCase.getUserBrowser(url, user=user), but that seems not to work because it defaults to anonymous if no password is provided.

At the moment in lp:~mbp/launchpad/flags-gui I have this:

    def getFeaturePageBrowserAsAdmin(self):
        root = getUtility(ILaunchpadRoot)
        url = canonical_url(root, view_name='+feature-rules')
        # XXX: To make a UserBrowser, you must know the password. This should
        # be separated out into test infrastructure -- mbp 20100923.
        user = self.factory.makePerson(password='test')
        admin_team = getUtility(ILaunchpadCelebrities).admin
        with person_logged_in(admin_team.teamowner):
            admin_team.addMember(user, reviewer=admin_team.teamowner)
        return self.getUserBrowser(url, user=user, password='test')

Perhaps there's a builtin way to do it or perhaps this can be lifted into somewhere else.

Revision history for this message
Gary Poster (gary) wrote :

I don't know of a built-in way to do this.

When we rip out passwords from the DB, this should be done as a side-effect (see bug 629167 / step 2 of https://dev.launchpad.net/LEP/OpenIdRoadmap). I could mark this as a dupe of that bug, but I'll just point the two at each other instead.

Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 646563] Re: want a way to make a TestBrowser logged in as a particular user

Robert suggested offline that we could change that code so that as a
side effect it resets the password of the user, then uses that known
password to create a browser. This is a bit gross, but perhaps most
tests that would want to use this wouldn't care.

--
Martin

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.