def test_save_for_password_provided(self): user = UserFactory(username='******', password='******') form = PasswordSettingsForm(data={'password': '******', 'retry_password': '******', 'status': True}, instance=PasswordSettings(user=user), user=user) form.is_valid() form.save() self.assertTrue(user.check_password('foo'))
def test_clean_for_invalid_password(self): user = UserFactory(username='******', password='******') form = PasswordForm(data={'password': '******'}, user=user) self.assertFalse(form.is_valid()) with self.assertRaises(forms.ValidationError): form.clean()
def test_clean_for_valid_password(self): user = UserFactory(username='******', password='******') form = PasswordForm(data={'password': '******'}, user=user) self.assertTrue(form.is_bound) self.assertTrue(form.is_valid(), form.errors) form.clean()
def test_clean_for_match_password(self): user = UserFactory(username='******', password='******') form = PasswordSettingsForm(data={'password': '******', 'retry_password': '******', 'status': True}, user=user) form.is_valid() form.clean()
def test_clean_for_mismatch_password(self): user = UserFactory(username='******', password='******') form = PasswordSettingsForm(data={'password': '******', 'retry_password': '******', 'status': True}, user=user) form.is_valid() with self.assertRaises(forms.ValidationError): form.clean()
def test_is_enabled(self): factory = PasswordFactory() user = UserFactory() # Enabled by default self.assertEqual(factory.is_enabled(user), True) # Enabled by user ps = PasswordSettings.objects.create(user=user, status=True) self.assertEqual(factory.is_enabled(user), True) # Disabled by user ps.status = False ps.save() self.assertEqual(factory.is_enabled(user), False)
def setUp(self): self.user = UserFactory()
def setUp(self): self.user = UserFactory() self.factory = RequestFactory() self.url = reverse('auth_factories:console_otp:index') super(TestAuthenticationView, self).setUp()
def setUp(self): self.user = UserFactory(username="******")
def setUp(self): self.user = UserFactory() self.url = reverse('auth_factories:login') self.factory = RequestFactory()
def test_get_totp_image(self): manager = TOTPManager({}, UserFactory()) self.assertTrue(manager.get_totp_image().startswith('data:image/png'))
def test_get_totp_uri(self): user = UserFactory() manager = TOTPManager({}, user) uri = manager.get_totp_uri() self.assertTrue(uri.startswith("otpauth://")) self.assertIn(user.username, uri)
def test_get_totp(self): manager = TOTPManager({}, UserFactory()) self.assertIsInstance(manager.get_totp(), pyotp.TOTP)
def setUp(self): self.user = UserFactory() self.session = self.client.session
def setUp(self): self.user = UserFactory() self.token = OTPPassword.objects.create( user=self.user, shared_secret="JBSWY3DPEHPK3PXP") self.totp = pyotp.TOTP("JBSWY3DPEHPK3PXP")
def setUp(self): self.user = UserFactory() self.url = reverse('auth_factories:totp:create') self.factory = RequestFactory() super(TestOTPPasswordCreateView, self).setUp()
def test_get_totp_secret(self): manager = TOTPManager({}, UserFactory()) self.assertEquals(manager.get_totp_secret(), manager.get_totp_secret())
def setUp(self): self.user = UserFactory() self.url = reverse('auth_factories:list')