1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-31 06:40:39 +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.authentication import TokenAuthentication
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):
@ -27,6 +26,8 @@ class TwoFactorAuthView(APIView):
except User.DoesNotExist:
error_msg = "User %s not found" % email
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
from seahub_extra.two_factor import devices_for_user
devices = devices_for_user(_user)
if devices:
for device in devices:

View File

@ -1,20 +1,24 @@
import os
import pytest
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)
TRAVIS = 'TRAVIS' in os.environ
@pytest.mark.skipif(TRAVIS, reason="")
class TwoFactorAuthViewTest(BaseTestCase):
def setUp(self):
self.login_as(self.admin)
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.save()
from seahub_extra.two_factor import devices_for_user
devices = devices_for_user(self.admin)
i = 0
for device in devices_for_user(self.admin):