mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 00:20:07 +00:00
two-factor-auth
This commit is contained in:
37
tests/api/endpoints/admin/test_two_factor_auth.py
Normal file
37
tests/api/endpoints/admin/test_two_factor_auth.py
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from seahub.test_utils import BaseTestCase
|
||||
from seahub_extra.two_factor import devices_for_user
|
||||
from seahub_extra.two_factor.models import (StaticDevice, TOTPDevice,
|
||||
PhoneDevice)
|
||||
|
||||
|
||||
class TwoFactorAuthViewTest(BaseTestCase):
|
||||
def setUp(self):
|
||||
self.login_as(self.admin)
|
||||
|
||||
def test_can_disable_two_factor_auth(self):
|
||||
totp = TOTPDevice(user=self.admin, name="", confirmed=1)
|
||||
totp.save()
|
||||
|
||||
devices = devices_for_user(self.admin)
|
||||
i = 0
|
||||
for device in devices_for_user(self.admin):
|
||||
if device:
|
||||
i+=1
|
||||
assert i > 0
|
||||
resp = self.client.delete(reverse('two-factor-auth-view', args=[str(self.admin.username)]))
|
||||
assert resp.status_code == 200
|
||||
i = 0
|
||||
for device in devices_for_user(self.admin):
|
||||
if device:
|
||||
i+=1
|
||||
assert i == 0
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
for device in devices_for_user(self.admin):
|
||||
device.delete()
|
||||
except:
|
||||
pass
|
Reference in New Issue
Block a user