コード例 #1
0
 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'))
コード例 #2
0
 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()
コード例 #3
0
 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()
コード例 #4
0
 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()
コード例 #5
0
 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()
コード例 #6
0
    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)
コード例 #7
0
 def setUp(self):
     self.user = UserFactory()
コード例 #8
0
 def setUp(self):
     self.user = UserFactory()
     self.factory = RequestFactory()
     self.url = reverse('auth_factories:console_otp:index')
     super(TestAuthenticationView, self).setUp()
コード例 #9
0
 def setUp(self):
     self.user = UserFactory(username="******")
コード例 #10
0
 def setUp(self):
     self.user = UserFactory()
     self.url = reverse('auth_factories:login')
     self.factory = RequestFactory()
コード例 #11
0
 def test_get_totp_image(self):
     manager = TOTPManager({}, UserFactory())
     self.assertTrue(manager.get_totp_image().startswith('data:image/png'))
コード例 #12
0
 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)
コード例 #13
0
 def test_get_totp(self):
     manager = TOTPManager({}, UserFactory())
     self.assertIsInstance(manager.get_totp(), pyotp.TOTP)
コード例 #14
0
 def setUp(self):
     self.user = UserFactory()
     self.session = self.client.session
コード例 #15
0
 def setUp(self):
     self.user = UserFactory()
     self.token = OTPPassword.objects.create(
         user=self.user, shared_secret="JBSWY3DPEHPK3PXP")
     self.totp = pyotp.TOTP("JBSWY3DPEHPK3PXP")
コード例 #16
0
    def setUp(self):
        self.user = UserFactory()
        self.url = reverse('auth_factories:totp:create')
        self.factory = RequestFactory()

        super(TestOTPPasswordCreateView, self).setUp()
コード例 #17
0
 def test_get_totp_secret(self):
     manager = TOTPManager({}, UserFactory())
     self.assertEquals(manager.get_totp_secret(), manager.get_totp_secret())
コード例 #18
0
 def setUp(self):
     self.user = UserFactory()
     self.url = reverse('auth_factories:list')