def test_login_lockout(self):
        form = EmailAuthenticationForm(data={'username': self.username, 'password': self.password})
        self.assertEqual(form.is_valid(), True)

        # attempt with bad credentials 5 times to lock out
        for i in range(5):
            form2 = EmailAuthenticationForm(data={'username': self.username, 'password': '******'})
            form2.is_valid()

        form3 = EmailAuthenticationForm(data={'username': self.username, 'password': self.password})
        self.assertEqual(form3.is_valid(), False)
    def test_login_lockout(self):
        form = EmailAuthenticationForm(data={'username': self.username, 'password': self.password})
        self.assertEqual(form.is_valid(), True)

        # attempt with bad credentials 5 times to lock out
        for i in range(5):
            form2 = EmailAuthenticationForm(data={'username': self.username, 'password': '******'})
            form2.is_valid()

        form3 = EmailAuthenticationForm(data={'username': self.username, 'password': self.password})
        self.assertEqual(form3.is_valid(), False)
Beispiel #3
0
 def test_form_has_no_extra_widget_attributes_when_sso_is_not_enforced(self):
     """
     Ensure that the attributes remain the same on the widgets of username
     and password in EmailAuthenticationForm when ENFORCE_SSO_LOGIN = False
     """
     form = EmailAuthenticationForm()
     self.assertEqual(
         form.fields['username'].widget.attrs,
         {
             'class': 'form-control',
             'maxlength': 150,
         }
     )
     self.assertEqual(
         form.fields['password'].widget.attrs,
         {
             'class': 'form-control',
         }
     )
Beispiel #4
0
 def test_form_has_extra_widget_attributes_when_sso_is_enforced(self):
     """
     Ensure that the attributes are inserted into the username and password
     widgets of the EmailAuthenticationForm when ENFORCE_SSO_LOGIN = True
     """
     form = EmailAuthenticationForm()
     self.assertEqual(
         form.fields['username'].widget.attrs,
         {
             'class': 'form-control',
             'data-bind': 'textInput: authUsername, onEnterKey: continueOnEnter',
             'placeholder': "Enter email address",
         }
     )
     self.assertEqual(
         form.fields['password'].widget.attrs,
         {
             'class': 'form-control',
             'placeholder': "Enter password",
         }
     )
Beispiel #5
0
 def test_form_username_max_length(self):
     username = EmailAuthenticationForm().fields["username"]
     self.assertEqual(username.max_length, username.widget.attrs["maxlength"])