From 1c9c5d5c32656231acf5f14b5231f9274a2eb254 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 1 Sep 2014 10:07:05 +0200 Subject: [PATCH 1/2] Regression for #1810: Test login view renders --- rest_framework/urls.py | 2 +- tests/conftest.py | 1 + tests/test_authentication.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rest_framework/urls.py b/rest_framework/urls.py index 8fa3073e8..cfcee534b 100644 --- a/rest_framework/urls.py +++ b/rest_framework/urls.py @@ -6,7 +6,7 @@ your API requires authentication: urlpatterns = patterns('', ... - url(r'^auth', include('rest_framework.urls', namespace='rest_framework')) + url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')) ) The urls must be namespaced as 'rest_framework', and you should make sure diff --git a/tests/conftest.py b/tests/conftest.py index f3723aeae..4b33e19c1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,7 @@ def pytest_configure(): DEBUG_PROPAGATE_EXCEPTIONS=True, DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}, + SITE_ID=1, SECRET_KEY='not very secret in tests', USE_I18N=True, USE_L10N=True, diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 2b9d73e4c..8294189e0 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -57,7 +57,8 @@ urlpatterns = patterns( authentication_classes=[OAuthAuthentication], permission_classes=[permissions.TokenHasReadWriteScope] ) - ) + ), + url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')) ) @@ -134,6 +135,16 @@ class SessionAuthTests(TestCase): def tearDown(self): self.csrf_client.logout() + def test_login_view_renders_on_get(self): + """ + Ensure the login template renders for a basic GET. + + cf. [#1810](https://github.com/tomchristie/django-rest-framework/pull/1810) + """ + response = self.csrf_client.get('/auth/login/') + self.assertContains(response, '') + + def test_post_form_session_auth_failing_csrf(self): """ Ensure POSTing form over session authentication without CSRF token fails. From 0e51dab8f4cdfeb05b7c70a0ca74ffa90d01f512 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 1 Sep 2014 10:09:46 +0200 Subject: [PATCH 2/2] Comform to flake8 --- tests/test_authentication.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_authentication.py b/tests/test_authentication.py index 8294189e0..32041f9c1 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -144,7 +144,6 @@ class SessionAuthTests(TestCase): response = self.csrf_client.get('/auth/login/') self.assertContains(response, '') - def test_post_form_session_auth_failing_csrf(self): """ Ensure POSTing form over session authentication without CSRF token fails.