Beispiel #1
0
  def setUpClass(cls):
    if not ENABLE_ORGANIZATIONS.get():  # Skip for now as depends on DB changes
      raise SkipTest

    cls.user1 = create_user('*****@*****.**', 'test', is_superuser=False)
    cls.user2 = create_user('*****@*****.**', 'test', is_superuser=True)
    cls.user3 = create_user('*****@*****.**', 'test', is_superuser=False)
    cls.user4 = create_user('*****@*****.**', 'test', is_superuser=False)

    cls.client1 = make_logged_in_client(username=cls.user1.username)
    cls.client2 = make_logged_in_client(username=cls.user2.username)
Beispiel #2
0
    def test_login_long_username(self):
        self.reset.append(
            conf.AUTH.BACKEND.set_for_testing(
                ["desktop.auth.backend.AllowFirstUserDjangoBackend"]))

        c = Client()

        username = '******' * 15
        user = create_user(username=username,
                           password='******',
                           is_superuser=False)

        response = c.post('/hue/accounts/login/', {
            'username': username,
            'password': '******'
        })
        assert_equal(302, response.status_code)

        username = '******' * 145
        user = create_user(username=username,
                           password='******',
                           is_superuser=False)
        response = c.post('/hue/accounts/login/', {
            'username': username,
            'password': '******'
        })
        assert_equal(302, response.status_code)

        # 250 is currently the max in the official Django User model.
        # We can't create a previou user with more characters as the DB will truncate anyway.
        username = '******' * 255
        response = c.post('/hue/accounts/login/', {
            'username': username,
            'password': '******'
        })
        assert_equal(200, response.status_code)
        assert_true(response.context[0]['login_errors'])