def test_validate_token(self): request = self.factory.get( self.url, {'state': 'aw1231jass'} #forged token ) request.user = self.user view = AuthReturnView(request=request) valid = view.validate_token() self.assertFalse(valid) #generate valid token for user token = xsrfutil.generate_token( settings.SECRET_KEY, self.user ) request = self.factory.get( self.url, {'state': token} #valid token ) request.user = self.user view = AuthReturnView(request=request) valid = view.validate_token() self.assertTrue(valid)
def test_validate_token(self): request = self.factory.get( self.url, {'state': 'aw1231jass'} #forged token ) request.user = self.user view = AuthReturnView(request=request) valid = view.validate_token() self.assertFalse(valid) #generate valid token for user token = xsrfutil.generate_token(settings.SECRET_KEY, self.user) request = self.factory.get( self.url, {'state': token} #valid token ) request.user = self.user view = AuthReturnView(request=request) valid = view.validate_token() self.assertTrue(valid)
def initiate_view(self): view = AuthReturnView(request=self.request) return view
from django.conf.urls.defaults import patterns, include, url from google_oauth.views import AuthCredentials, AuthReturnView urlpatterns = patterns( '', url(r'^$', AuthCredentials.as_view(), name="google_auth"), url(r'^oauth2callback', AuthReturnView.as_view(), name="google_auth_return"), )
from django.conf.urls.defaults import patterns, include, url from google_oauth.views import AuthCredentials, AuthReturnView urlpatterns = patterns( "", url(r"^$", AuthCredentials.as_view(), name="google_auth"), url(r"^oauth2callback", AuthReturnView.as_view(), name="google_auth_return"), )
from django.conf.urls import patterns, include, url from google_oauth.views import AuthCredentials, AuthReturnView urlpatterns = patterns('', url(r'^$', AuthCredentials.as_view(), name="google_auth"), url(r'^oauth2callback', AuthReturnView.as_view(), name="google_auth_return"), )