    async def login_user(self, name):
        """Login a user by name, returning her cookies."""
        base_url = public_url(self)
        s = AsyncSession()
        if self.internal_ssl:
            s.verify = self.external_certs['files']['ca']
        login_url = base_url + 'hub/login'
        r = await s.get(login_url)
        r.raise_for_status()
        xsrf = r.cookies['_xsrf']

        r = await s.post(
            url_concat(login_url, {"_xsrf": xsrf}),
            data={'username': name, 'password': name},
            allow_redirects=False,
        )
        r.raise_for_status()
        # make second request to get updated xsrf cookie
        r2 = await s.get(
            url_path_join(base_url, "hub/home"),
            allow_redirects=False,
        )
        assert r2.status_code == 200
        assert sorted(s.cookies.keys()) == [
            '_xsrf',
            'jupyterhub-hub-login',
            'jupyterhub-session-id',
        ]
        return s.cookies
Login a user by name, returning her cookies.
jupyterhub/tests/mocking.py