示例#1
0
    def test_login(self):
        request = testing.DummyRequest(
            userdb=self.rundb.userdb,
            method="POST",
            params={
                "username": "******",
                "password": "******"
            },
        )
        response = login(request)
        self.assertTrue(
            "Invalid password" in request.session.pop_flash("error"))

        # Correct password, but still blocked from logging in
        request.params["password"] = "******"
        login(request)
        self.assertTrue("Blocked" in request.session.pop_flash("error"))

        # Unblock, then user can log in successfully
        user = self.rundb.userdb.get_user("JoeUser")
        user["blocked"] = False
        self.rundb.userdb.save_user(user)
        response = login(request)
        self.assertEqual(response.code, 302)
        self.assertTrue("The resource was found at" in str(response))
示例#2
0
    def test_logins(self):
        with testing.testConfig() as config:
            config.add_route('login', '/login')
            r = login(self.request)
            self.assertFalse('found' in str(r))

            self.params['password'] = '******'
            r = login(self.request)
            self.assertTrue('found' in str(r))
示例#3
0
  def test_logins(self):
    with testing.testConfig() as config:
      config.add_route('login', '/login')
      r= login(self.request)
      self.assertFalse('found' in str(r))

      self.params['password'] = '******'
      r= login(self.request)
      # Still blocked:
      self.assertFalse('found' in str(r))

      # Unblock:
      user = self.request.userdb.get_user('JoeUser')
      user['blocked'] = False
      self.request.userdb.save_user(user)
      r= login(self.request)
      self.assertTrue('found' in str(r))
示例#4
0
    def test_logins(self):
        with testing.testConfig() as config:
            config.add_route('login', '/login')
            r = login(self.request)
            self.assertFalse('found' in str(r))

            self.params['password'] = '******'
            r = login(self.request)
            # Still blocked:
            self.assertFalse('found' in str(r))

            # Unblock:
            user = self.request.userdb.get_user('JoeUser')
            user['blocked'] = False
            self.request.userdb.save_user(user)
            r = login(self.request)
            self.assertTrue('found' in str(r))
示例#5
0
    def test_login(self):
        request = testing.DummyRequest(userdb=self.rundb.userdb,
                                       method='POST',
                                       params={
                                           'username': '******',
                                           'password': '******'
                                       })
        response = login(request)
        self.assertTrue(
            'Invalid password' in request.session.pop_flash('error'))

        # Correct password, but still blocked from logging in
        request.params['password'] = '******'
        login(request)
        self.assertTrue('Blocked' in request.session.pop_flash('error'))

        # Unblock, then user can log in successfully
        user = self.rundb.userdb.get_user('JoeUser')
        user['blocked'] = False
        self.rundb.userdb.save_user(user)
        response = login(request)
        self.assertEqual(response.code, 302)
        self.assertTrue('The resource was found at' in str(response))