Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Authentication backend settings test

  • Loading branch information...
commit 9165b6444a7ba511a01e6399acd7c41d63d731b2 1 parent c3f7f85
@flashingpumpkin authored
View
5 socialregistration/contrib/facebook/tests.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from socialregistration.contrib.facebook.models import FacebookProfile
@@ -49,3 +50,7 @@ def setup_callback(self, MockFacebook, MockRequest):
MockFacebook.side_effect = get_mock_func(self.get_facebook_data)
response = self.client.get(self.get_setup_callback_url())
return response
+
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.facebook.auth.FacebookAuth' in settings.AUTHENTICATION_BACKENDS)
View
4 socialregistration/contrib/foursquare/tests.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from socialregistration.contrib.foursquare.models import FoursquareProfile
@@ -34,3 +35,6 @@ def create_profile(self, user):
FoursquareProfile.objects.create(user=user, foursquare='123')
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.foursquare.auth.FoursquareAuth' in settings.AUTHENTICATION_BACKENDS)
View
5 socialregistration/contrib/github/tests.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from socialregistration.contrib.github.models import GithubProfile
@@ -30,3 +31,7 @@ def get_setup_callback_mock_response(self, *args, **kwargs):
def create_profile(self, user):
GithubProfile.objects.create(user=user, github='123')
+
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.github.auth.GithubAuth' in settings.AUTHENTICATION_BACKENDS)
View
6 socialregistration/contrib/linkedin/tests.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from socialregistration.contrib.linkedin.models import LinkedInProfile
@@ -37,3 +38,8 @@ def get_setup_callback_mock_response(self, *args, **kwargs):
def create_profile(self, user):
LinkedInProfile.objects.create(user=user, linkedin_id='123')
+
+
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.linkedin.auth.LinkedInAuth' in settings.AUTHENTICATION_BACKENDS)
View
10 socialregistration/contrib/openid/tests.py
@@ -1,6 +1,6 @@
-from django.test import TestCase
-from django.conf import settings
from django import template
+from django.conf import settings
+from django.test import TestCase
class TestTemplateTag(TestCase):
@@ -13,3 +13,9 @@ def test_tag_renders_correctly(self):
self.assertTrue('https://www.google.com/accounts/o8/id' in template.Template(tpl).render(template.Context({'request': None})))
self.assertTrue('image/for/google.jpg' in template.Template(tpl).render(template.Context({'request': None})))
+
+
+
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.openid.auth.OpenIDAuth' in settings.AUTHENTICATION_BACKENDS)
View
5 socialregistration/contrib/tumblr/tests.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from socialregistration.contrib.tumblr.models import TumblrProfile
@@ -39,3 +40,7 @@ def get_setup_callback_mock_response(self, *args, **kwargs):
def create_profile(self, user):
TumblrProfile.objects.create(user=user, tumblr='123')
+
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.tumblr.auth.TumblrAuth' in settings.AUTHENTICATION_BACKENDS)
View
6 socialregistration/contrib/twitter/tests.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
from socialregistration.contrib.twitter.models import TwitterProfile
@@ -36,3 +37,8 @@ def get_setup_callback_mock_response(self, *args, **kwargs):
def create_profile(self, user):
TwitterProfile.objects.create(user=user, twitter_id='123')
+
+
+class TestAuthenticationBackend(TestCase):
+ def test_authentication_backend_should_be_configured_in_settings(self):
+ self.assertTrue('socialregistration.contrib.twitter.auth.TwitterAuth' in settings.AUTHENTICATION_BACKENDS)
View
19 socialregistration/tests.py
@@ -38,6 +38,11 @@ def wrapped(*args, **kwargs):
class OAuthTest(object):
+ """
+ Mixin for OAuth tests. This does not go out to the services that we're
+ testing but mocks instead the responses we *should* get back.
+ """
+
def get_redirect_url(self):
raise NotImplementedError
@@ -48,12 +53,26 @@ def get_callback_setup_url(self):
raise NotImplementedError
def get_redirect_mock_response(self, *args, **kwargs):
+ """
+ If the redirect view does any requests, this is the method that returns
+ the mocked response. In case of OAuth1 this will be the request token
+ response.
+ """
raise NotImplementedError
def get_callback_mock_response(self, *args, **kwargs):
+ """
+ If the callback view does any request, this is the method that returns
+ the mocked response. In case of OAuth{1,2} this will be the access token.
+ """
raise NotImplementedError
def get_setup_callback_mock_response(self, *args, **kwargs):
+ """
+ If the setup callback view does any requests, this is the method that
+ returns the mocked response. In case of OAuth{1,2} this will be the
+ user information that we'll be authenticating with.
+ """
raise NotImplementedError
def create_profile(self):
Please sign in to comment.
Something went wrong with that request. Please try again.