Commits

Peter Sagerson committed a0dff19

Fix test organization for Django 1.6 discovery.

Comments (0)

Files changed (10)

django-otp-agents/otp_agents/test/__init__.py

Empty file added.

django-otp-agents/otp_agents/test/urls.py

+from django.conf.urls import patterns, url
+
+from . import views
+
+
+urlpatterns = patterns(
+    '',
+
+    url(r'^login/$', 'django.contrib.auth.views.login'),
+    url(r'^verify/$', 'django_otp.views.login'),
+    url(r'^trust/$', 'otp_agents.views.login'),
+    url(r'^logout/$', 'django.contrib.auth.views.logout'),
+
+    url(r'^otp/$', views.otp_view),
+    url(r'^otp2/$', views.otp_view_2),
+    url(r'^otp_advised/$', views.otp_advised_view),
+    url(r'^otp_advised_2/$', views.otp_advised_view_2),
+    url(r'^agent/$', views.agent_view),
+)

django-otp-agents/otp_agents/test/views.py

+from django.http import HttpResponse
+
+from otp_agents.decorators import otp_required
+
+
+@otp_required
+def otp_view(request):
+    return HttpResponse()
+
+
+@otp_required()
+def otp_view_2(request):
+    return HttpResponse()
+
+
+@otp_required(if_configured=True, accept_trusted_agent=True)
+def otp_advised_view(request):
+    return HttpResponse()
+
+
+@otp_required(if_configured=True)
+def otp_advised_view_2(request):
+    return HttpResponse()
+
+
+@otp_required(accept_trusted_agent=True)
+def agent_view(request):
+    return HttpResponse()

django-otp-agents/otp_agents/tests.py

+import django
+from django.db import IntegrityError
+from django.db.models import get_app
+from django.utils.unittest import skipIf
+
+from django_otp.tests import TestCase
+
+
+@skipIf(django.VERSION < (1, 4), "Requires Django 1.4")
+class OTPAgentsTestCase(TestCase):
+    urls = 'otp_agents.test.urls'
+
+    def setUp(self):
+        try:
+            get_app('otp_static')
+        except:
+            self.skipTest("Requires django_otp.plugins.otp_static")
+
+        try:
+            self.alice = self.create_user('alice', 'alice')
+        except IntegrityError:
+            self.skipTest("Unable to create a test user")
+        else:
+            device = self.alice.staticdevice_set.create()
+            device.token_set.create(token='alice1')
+            device.token_set.create(token='alice2')
+
+    def test_otp_anonymous(self):
+        response = self.client.get('/otp/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_otp_authenticated(self):
+        self.login()
+        response = self.client.get('/otp/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_otp_verified(self):
+        self.verify()
+        response = self.client.get('/otp/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_otp_trusted(self):
+        self.trust(True)
+        self.logout()
+        self.login()
+        response = self.client.get('/otp/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_otp2_verified(self):
+        self.verify()
+        response = self.client.get('/otp2/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_otp_advised_anonymous(self):
+        response = self.client.get('/otp_advised/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_otp_advised_unconfigured(self):
+        self.alice.staticdevice_set.all().delete()
+        self.login()
+        response = self.client.get('/otp_advised/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_otp_advised_unconfigured_2(self):
+        self.alice.staticdevice_set.all().delete()
+        self.login()
+        response = self.client.get('/otp_advised_2/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_otp_advised_authenticated(self):
+        self.login()
+        response = self.client.get('/otp_advised/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_otp_advised_verified(self):
+        self.verify()
+        response = self.client.get('/otp_advised/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_agent_anonymous(self):
+        response = self.client.get('/agent/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_agent_authenticated(self):
+        response = self.client.get('/agent/')
+
+        self.assertEqual(response.status_code, 302)
+
+    def test_agent_verified(self):
+        self.verify()
+        response = self.client.get('/agent/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_agent_trusted_session(self):
+        self.trust(False)
+        response = self.client.get('/agent/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_agent_trusted(self):
+        self.trust(True)
+        self.logout()
+        self.login()
+        response = self.client.get('/agent/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def test_two_step_trust(self):
+        self.login()
+        self.add_trust(True)
+        self.logout()
+        self.login()
+        response = self.client.get('/agent/')
+
+        self.assertEqual(response.status_code, 200)
+
+    def login(self):
+        params = {
+            'username': 'alice',
+            'password': 'alice',
+        }
+
+        response = self.client.post('/login/', params)
+
+        self.assertEqual(response.status_code, 302)
+
+    def verify(self):
+        params = {
+            'username': 'alice',
+            'password': 'alice',
+            'otp_token': 'alice1',
+        }
+
+        response = self.client.post('/verify/', params)
+
+        self.assertEqual(response.status_code, 302)
+
+    def trust(self, persist=False):
+        params = {
+            'username': 'alice',
+            'password': 'alice',
+            'otp_token': 'alice1',
+            'otp_trust_agent': '1' if persist else '',
+        }
+
+        response = self.client.post('/trust/', params)
+
+        self.assertEqual(response.status_code, 302)
+
+    def add_trust(self, persist=False):
+        params = {
+            'otp_device': 'django_otp.plugins.otp_static.models.StaticDevice/1',
+            'otp_token': 'alice1',
+            'otp_trust_agent': '1' if persist else '',
+        }
+
+        response = self.client.post('/trust/', params)
+
+        self.assertEqual(response.status_code, 302)
+
+    def logout(self):
+        response = self.client.post('/logout/')
+
+        self.assertEqual(response.status_code, 200)

django-otp-agents/otp_agents/tests/__init__.py

-import django
-from django.db import IntegrityError
-from django.db.models import get_app
-from django.utils.unittest import skipIf
-
-from django_otp.tests import TestCase
-
-
-@skipIf(django.VERSION < (1, 4), u"Requires Django 1.4")
-class OTPAgentsTestCase(TestCase):
-    urls = 'otp_agents.tests.urls'
-
-    def setUp(self):
-        try:
-            get_app('otp_static')
-        except:
-            self.skipTest("Requires django_otp.plugins.otp_static")
-
-        try:
-            self.alice = self.create_user('alice', 'alice')
-        except IntegrityError:
-            self.skipTest("Unable to create a test user")
-        else:
-            device = self.alice.staticdevice_set.create()
-            device.token_set.create(token='alice1')
-            device.token_set.create(token='alice2')
-
-    def test_otp_anonymous(self):
-        response = self.client.get('/otp/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_otp_authenticated(self):
-        self.login()
-        response = self.client.get('/otp/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_otp_verified(self):
-        self.verify()
-        response = self.client.get('/otp/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_otp_trusted(self):
-        self.trust(True)
-        self.logout()
-        self.login()
-        response = self.client.get('/otp/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_otp2_verified(self):
-        self.verify()
-        response = self.client.get('/otp2/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_otp_advised_anonymous(self):
-        response = self.client.get('/otp_advised/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_otp_advised_unconfigured(self):
-        self.alice.staticdevice_set.all().delete()
-        self.login()
-        response = self.client.get('/otp_advised/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_otp_advised_unconfigured_2(self):
-        self.alice.staticdevice_set.all().delete()
-        self.login()
-        response = self.client.get('/otp_advised_2/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_otp_advised_authenticated(self):
-        self.login()
-        response = self.client.get('/otp_advised/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_otp_advised_verified(self):
-        self.verify()
-        response = self.client.get('/otp_advised/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_agent_anonymous(self):
-        response = self.client.get('/agent/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_agent_authenticated(self):
-        response = self.client.get('/agent/')
-
-        self.assertEqual(response.status_code, 302)
-
-    def test_agent_verified(self):
-        self.verify()
-        response = self.client.get('/agent/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_agent_trusted_session(self):
-        self.trust(False)
-        response = self.client.get('/agent/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_agent_trusted(self):
-        self.trust(True)
-        self.logout()
-        self.login()
-        response = self.client.get('/agent/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def test_two_step_trust(self):
-        self.login()
-        self.add_trust(True)
-        self.logout()
-        self.login()
-        response = self.client.get('/agent/')
-
-        self.assertEqual(response.status_code, 200)
-
-    def login(self):
-        params = {
-            'username': 'alice',
-            'password': 'alice',
-        }
-
-        response = self.client.post('/login/', params)
-
-        self.assertEqual(response.status_code, 302)
-
-    def verify(self):
-        params = {
-            'username': 'alice',
-            'password': 'alice',
-            'otp_token': 'alice1',
-        }
-
-        response = self.client.post('/verify/', params)
-
-        self.assertEqual(response.status_code, 302)
-
-    def trust(self, persist=False):
-        params = {
-            'username': 'alice',
-            'password': 'alice',
-            'otp_token': 'alice1',
-            'otp_trust_agent': '1' if persist else '',
-        }
-
-        response = self.client.post('/trust/', params)
-
-        self.assertEqual(response.status_code, 302)
-
-    def add_trust(self, persist=False):
-        params = {
-            'otp_device': 'django_otp.plugins.otp_static.models.StaticDevice/1',
-            'otp_token': 'alice1',
-            'otp_trust_agent': '1' if persist else '',
-        }
-
-        response = self.client.post('/trust/', params)
-
-        self.assertEqual(response.status_code, 302)
-
-    def logout(self):
-        response = self.client.post('/logout/')
-
-        self.assertEqual(response.status_code, 200)

django-otp-agents/otp_agents/tests/urls.py

-from django.conf.urls import patterns, url
-
-from . import views
-
-
-urlpatterns = patterns(
-    '',
-
-    url(r'^login/$', 'django.contrib.auth.views.login'),
-    url(r'^verify/$', 'django_otp.views.login'),
-    url(r'^trust/$', 'otp_agents.views.login'),
-    url(r'^logout/$', 'django.contrib.auth.views.logout'),
-
-    url(r'^otp/$', views.otp_view),
-    url(r'^otp2/$', views.otp_view_2),
-    url(r'^otp_advised/$', views.otp_advised_view),
-    url(r'^otp_advised_2/$', views.otp_advised_view_2),
-    url(r'^agent/$', views.agent_view),
-)

django-otp-agents/otp_agents/tests/views.py

-from django.http import HttpResponse
-
-from otp_agents.decorators import otp_required
-
-
-@otp_required
-def otp_view(request):
-    return HttpResponse()
-
-
-@otp_required()
-def otp_view_2(request):
-    return HttpResponse()
-
-
-@otp_required(if_configured=True, accept_trusted_agent=True)
-def otp_advised_view(request):
-    return HttpResponse()
-
-
-@otp_required(if_configured=True)
-def otp_advised_view_2(request):
-    return HttpResponse()
-
-
-@otp_required(accept_trusted_agent=True)
-def agent_view(request):
-    return HttpResponse()

test/custom_user/testproj/settings.py

 
 SECRET_KEY = '9xZjgb6lM998dPRNQ3j7au86X5ZL17Jtme5N910Cp06u7j0QLWara6BH7N90clGQ'
 
-ROOT_URLCONF = 'test15.urls'
+ROOT_URLCONF = 'testproj.urls'
 
 AUTH_USER_MODEL = 'app.TestUser'

test/exotic_user/testproj/settings.py

 
 SECRET_KEY = '9xZjgb6lM998dPRNQ3j7au86X5ZL17Jtme5N910Cp06u7j0QLWara6BH7N90clGQ'
 
-ROOT_URLCONF = 'test15.urls'
+ROOT_URLCONF = 'testproj.urls'
 
 AUTH_USER_MODEL = 'app.TestUser'
           py33-django16,
 
 [testenv]
-basepython = python2.7
 changedir = default_user
 commands = {envbindir}/coverage run -a ./manage.py test django_otp otp_hotp otp_totp otp_static otp_email otp_yubikey otp_twilio otp_agents
 deps = coverage
        django<1.5
 
 [testenv:py27-django15]
+basepython = python2.7
 deps = {[testenv]deps}
        django<1.6
 
 [testenv:py27-django15-custom]
+basepython = python2.7
 changedir = custom_user
 commands = {envbindir}/coverage run -a ./manage.py test django_otp otp_hotp otp_totp otp_static otp_email
 deps = coverage
        django<1.6
 
 [testenv:py27-django15-exotic]
+basepython = python2.7
 changedir = exotic_user
 commands = {envbindir}/coverage run -a ./manage.py test django_otp otp_hotp otp_totp otp_static otp_email
 deps = coverage
        django<1.6
 
 [testenv:py27-django16]
-commands = {envbindir}/coverage run -a ./manage.py test \
-    django_otp \
-    django_otp.plugins.otp_hotp \
-    django_otp.plugins.otp_totp \
-    django_otp.plugins.otp_static \
-    django_otp.plugins.otp_email \
-    otp_yubikey \
-    otp_twilio \
-    otp_agents
+basepython = python2.7
+commands = {envbindir}/coverage run -a ./manage.py test django_otp otp_yubikey otp_twilio otp_agents
 deps = {[testenv]deps}
-       https://www.djangoproject.com/m/releases/1.6/Django-1.6b2.tar.gz
+       https://www.djangoproject.com/m/releases/1.6/Django-1.6b3.tar.gz
 
 [testenv:py32-django16]
 basepython = python3.2
-commands = {envbindir}/coverage run -a ./manage.py test \
-    django_otp \
-    django_otp.plugins.otp_hotp \
-    django_otp.plugins.otp_totp \
-    django_otp.plugins.otp_static \
-    django_otp.plugins.otp_email \
-    otp_yubikey \
-    otp_twilio \
-    otp_agents
+commands = {envbindir}/coverage run -a ./manage.py test django_otp otp_yubikey otp_twilio otp_agents
 deps = {[testenv]deps}
-       https://www.djangoproject.com/m/releases/1.6/Django-1.6b2.tar.gz
+       https://www.djangoproject.com/m/releases/1.6/Django-1.6b3.tar.gz
 
 [testenv:py33-django16]
 basepython = python3.3
-commands = {envbindir}/coverage run -a ./manage.py test \
-    django_otp \
-    django_otp.plugins.otp_hotp \
-    django_otp.plugins.otp_totp \
-    django_otp.plugins.otp_static \
-    django_otp.plugins.otp_email \
-    otp_yubikey \
-    otp_twilio \
-    otp_agents
+commands = {envbindir}/coverage run -a ./manage.py test django_otp otp_yubikey otp_twilio otp_agents
 deps = {[testenv]deps}
-       https://www.djangoproject.com/m/releases/1.6/Django-1.6b2.tar.gz
+       https://www.djangoproject.com/m/releases/1.6/Django-1.6b3.tar.gz