1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-18 06:57:52 +00:00

update test

This commit is contained in:
zming 2017-07-15 12:24:52 +08:00
parent 9efb26eca8
commit c0f512aca6
2 changed files with 10 additions and 5 deletions

View File

@ -10,7 +10,6 @@ from seahub.api2.throttling import UserRateThrottle
from seahub.api2.utils import json_response, api_error from seahub.api2.utils import json_response, api_error
from seahub.api2.authentication import TokenAuthentication from seahub.api2.authentication import TokenAuthentication
from seahub.utils.two_factor_auth import has_two_factor_auth, two_factor_auth_enabled from seahub.utils.two_factor_auth import has_two_factor_auth, two_factor_auth_enabled
from seahub_extra.two_factor import devices_for_user
class TwoFactorAuthView(APIView): class TwoFactorAuthView(APIView):
@ -27,6 +26,8 @@ class TwoFactorAuthView(APIView):
except User.DoesNotExist: except User.DoesNotExist:
error_msg = "User %s not found" % email error_msg = "User %s not found" % email
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
from seahub_extra.two_factor import devices_for_user
devices = devices_for_user(_user) devices = devices_for_user(_user)
if devices: if devices:
for device in devices: for device in devices:

View File

@ -1,20 +1,24 @@
import os
import pytest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from seahub.test_utils import BaseTestCase from seahub.test_utils import BaseTestCase
from seahub_extra.two_factor import devices_for_user
from seahub_extra.two_factor.models import (StaticDevice, TOTPDevice, TRAVIS = 'TRAVIS' in os.environ
PhoneDevice)
@pytest.mark.skipif(TRAVIS, reason="")
class TwoFactorAuthViewTest(BaseTestCase): class TwoFactorAuthViewTest(BaseTestCase):
def setUp(self): def setUp(self):
self.login_as(self.admin) self.login_as(self.admin)
def test_can_disable_two_factor_auth(self): def test_can_disable_two_factor_auth(self):
from seahub_extra.two_factor.models import (StaticDevice, TOTPDevice,
PhoneDevice)
totp = TOTPDevice(user=self.admin, name="", confirmed=1) totp = TOTPDevice(user=self.admin, name="", confirmed=1)
totp.save() totp.save()
from seahub_extra.two_factor import devices_for_user
devices = devices_for_user(self.admin) devices = devices_for_user(self.admin)
i = 0 i = 0
for device in devices_for_user(self.admin): for device in devices_for_user(self.admin):