Ejemplo n.º 1
0
 def test_check_password_policy_compliance_warning(self):
     """
     Tests _enforce_password_policy_compliance succeeds with a warning thrown
     """
     enforce_compliance_on_login = '******'
     with patch(enforce_compliance_on_login) as mock_enforce_compliance_on_login:
         mock_enforce_compliance_on_login.side_effect = NonCompliantPasswordWarning('Test warning')
         response, _ = self._login_response(self.user_email, self.password)
         response_content = json.loads(response.content.decode('utf-8'))
         self.assertIn('Test warning', self.client.session['_messages'])
     self.assertTrue(response_content.get('success'))
Ejemplo n.º 2
0
 def test_check_password_policy_compliance_warning(self):
     """
     Tests _enforce_password_policy_compliance succeeds with a warning thrown
     """
     with patch('student.views.login.password_policy_compliance.enforce_compliance_on_login') as \
             mock_enforce_compliance_on_login:
         mock_enforce_compliance_on_login.side_effect = NonCompliantPasswordWarning(
             'Test warning')
         response, _ = self._login_response('*****@*****.**', 'test_password')
         response_content = json.loads(response.content)
         self.assertIn('Test warning', self.client.session['_messages'])
     self.assertTrue(response_content.get('success'))
Ejemplo n.º 3
0
 def test_auth_form_policy_enabled_with_warning(self):
     """
     Verify that the username and password are returned when compliance is
     enabled despite a NonCompliantPasswordWarning being thrown
     """
     # Need to mock messages here as it will fail due to a lack of requests on this unit test
     with mock.patch('openedx.core.djangoapps.password_policy.forms.messages') as mock_messages:
         mock_messages.return_value = True
         with mock.patch(
             'openedx.core.djangoapps.password_policy.forms.password_policy_compliance.enforce_compliance_on_login'
         ) as mock_enforce_compliance_on_login:
             mock_enforce_compliance_on_login.side_effect = NonCompliantPasswordWarning('Test warning')
             cleaned_data = self.auth_form.clean()
         self.assertEqual(cleaned_data.get('username'), self.user.username)
         self.assertTrue(cleaned_data.get('password'))