Commit 1dae7cab by Peter Baumgartner Committed by James Henstridge

Add trailing slashes to various URLs to match Django's general style.

Fixes bug #365765.
parent 69381adb
...@@ -150,8 +150,8 @@ class RelyingPartyTests(TestCase): ...@@ -150,8 +150,8 @@ class RelyingPartyTests(TestCase):
self.assertEquals(webresponse.code, 302) self.assertEquals(webresponse.code, 302)
redirect_to = webresponse.headers['location'] redirect_to = webresponse.headers['location']
self.assertTrue(redirect_to.startswith( self.assertTrue(redirect_to.startswith(
'http://testserver/openid/complete')) 'http://testserver/openid/complete/'))
return self.client.get('/openid/complete', return self.client.get('/openid/complete/',
dict(cgi.parse_qsl(redirect_to.split('?', 1)[1]))) dict(cgi.parse_qsl(redirect_to.split('?', 1)[1])))
def test_login(self): def test_login(self):
...@@ -163,27 +163,27 @@ class RelyingPartyTests(TestCase): ...@@ -163,27 +163,27 @@ class RelyingPartyTests(TestCase):
useropenid.save() useropenid.save()
# The login form is displayed: # The login form is displayed:
response = self.client.get('/openid/login') response = self.client.get('/openid/login/')
self.assertTemplateUsed(response, 'openid/login.html') self.assertTemplateUsed(response, 'openid/login.html')
# Posting in an identity URL begins the authentication request: # Posting in an identity URL begins the authentication request:
response = self.client.post('/openid/login', response = self.client.post('/openid/login/',
{'openid_identifier': 'http://example.com/identity', {'openid_identifier': 'http://example.com/identity',
'next': '/getuser'}) 'next': '/getuser/'})
self.assertContains(response, 'OpenID transaction in progress') self.assertContains(response, 'OpenID transaction in progress')
openid_request = self.provider.parseFormPost(response.content) openid_request = self.provider.parseFormPost(response.content)
self.assertEquals(openid_request.mode, 'checkid_setup') self.assertEquals(openid_request.mode, 'checkid_setup')
self.assertTrue(openid_request.return_to.startswith( self.assertTrue(openid_request.return_to.startswith(
'http://testserver/openid/complete')) 'http://testserver/openid/complete/'))
# Complete the request. The user is redirected to the next URL. # Complete the request. The user is redirected to the next URL.
openid_response = openid_request.answer(True) openid_response = openid_request.answer(True)
response = self.complete(openid_response) response = self.complete(openid_response)
self.assertRedirects(response, 'http://testserver/getuser') self.assertRedirects(response, 'http://testserver/getuser/')
# And they are now logged in: # And they are now logged in:
response = self.client.get('/getuser') response = self.client.get('/getuser/')
self.assertEquals(response.content, 'someuser') self.assertEquals(response.content, 'someuser')
def test_login_sso(self): def test_login_sso(self):
...@@ -197,22 +197,22 @@ class RelyingPartyTests(TestCase): ...@@ -197,22 +197,22 @@ class RelyingPartyTests(TestCase):
# Requesting the login form immediately begins an # Requesting the login form immediately begins an
# authentication request. # authentication request.
response = self.client.get('/openid/login', {'next': '/getuser'}) response = self.client.get('/openid/login/', {'next': '/getuser/'})
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertContains(response, 'OpenID transaction in progress') self.assertContains(response, 'OpenID transaction in progress')
openid_request = self.provider.parseFormPost(response.content) openid_request = self.provider.parseFormPost(response.content)
self.assertEquals(openid_request.mode, 'checkid_setup') self.assertEquals(openid_request.mode, 'checkid_setup')
self.assertTrue(openid_request.return_to.startswith( self.assertTrue(openid_request.return_to.startswith(
'http://testserver/openid/complete')) 'http://testserver/openid/complete/'))
# Complete the request. The user is redirected to the next URL. # Complete the request. The user is redirected to the next URL.
openid_response = openid_request.answer(True) openid_response = openid_request.answer(True)
response = self.complete(openid_response) response = self.complete(openid_response)
self.assertRedirects(response, 'http://testserver/getuser') self.assertRedirects(response, 'http://testserver/getuser/')
# And they are now logged in: # And they are now logged in:
response = self.client.get('/getuser') response = self.client.get('/getuser/')
self.assertEquals(response.content, 'someuser') self.assertEquals(response.content, 'someuser')
def test_login_create_users(self): def test_login_create_users(self):
...@@ -221,9 +221,9 @@ class RelyingPartyTests(TestCase): ...@@ -221,9 +221,9 @@ class RelyingPartyTests(TestCase):
User.objects.create_user('someuser', 'someone@example.com') User.objects.create_user('someuser', 'someone@example.com')
# Posting in an identity URL begins the authentication request: # Posting in an identity URL begins the authentication request:
response = self.client.post('/openid/login', response = self.client.post('/openid/login/',
{'openid_identifier': 'http://example.com/identity', {'openid_identifier': 'http://example.com/identity',
'next': '/getuser'}) 'next': '/getuser/'})
self.assertContains(response, 'OpenID transaction in progress') self.assertContains(response, 'OpenID transaction in progress')
# Complete the request, passing back some simple registration # Complete the request, passing back some simple registration
...@@ -236,11 +236,11 @@ class RelyingPartyTests(TestCase): ...@@ -236,11 +236,11 @@ class RelyingPartyTests(TestCase):
'email': 'foo@example.com'}) 'email': 'foo@example.com'})
openid_response.addExtension(sreg_response) openid_response.addExtension(sreg_response)
response = self.complete(openid_response) response = self.complete(openid_response)
self.assertRedirects(response, 'http://testserver/getuser') self.assertRedirects(response, 'http://testserver/getuser/')
# And they are now logged in as a new user (they haven't taken # And they are now logged in as a new user (they haven't taken
# over the existing "someuser" user). # over the existing "someuser" user).
response = self.client.get('/getuser') response = self.client.get('/getuser/')
self.assertEquals(response.content, 'someuser2') self.assertEquals(response.content, 'someuser2')
# Check the details of the new user. # Check the details of the new user.
...@@ -259,9 +259,9 @@ class RelyingPartyTests(TestCase): ...@@ -259,9 +259,9 @@ class RelyingPartyTests(TestCase):
useropenid.save() useropenid.save()
# Posting in an identity URL begins the authentication request: # Posting in an identity URL begins the authentication request:
response = self.client.post('/openid/login', response = self.client.post('/openid/login/',
{'openid_identifier': 'http://example.com/identity', {'openid_identifier': 'http://example.com/identity',
'next': '/getuser'}) 'next': '/getuser/'})
self.assertContains(response, 'OpenID transaction in progress') self.assertContains(response, 'OpenID transaction in progress')
# Complete the request, passing back some simple registration # Complete the request, passing back some simple registration
...@@ -274,11 +274,11 @@ class RelyingPartyTests(TestCase): ...@@ -274,11 +274,11 @@ class RelyingPartyTests(TestCase):
'email': 'foo@example.com'}) 'email': 'foo@example.com'})
openid_response.addExtension(sreg_response) openid_response.addExtension(sreg_response)
response = self.complete(openid_response) response = self.complete(openid_response)
self.assertRedirects(response, 'http://testserver/getuser') self.assertRedirects(response, 'http://testserver/getuser/')
# And they are now logged in as testuser (the passed in # And they are now logged in as testuser (the passed in
# nickname has not caused the username to change). # nickname has not caused the username to change).
response = self.client.get('/getuser') response = self.client.get('/getuser/')
self.assertEquals(response.content, 'testuser') self.assertEquals(response.content, 'testuser')
# The user's full name and email have been updated. # The user's full name and email have been updated.
...@@ -304,9 +304,9 @@ class RelyingPartyTests(TestCase): ...@@ -304,9 +304,9 @@ class RelyingPartyTests(TestCase):
useropenid.save() useropenid.save()
# Posting in an identity URL begins the authentication request: # Posting in an identity URL begins the authentication request:
response = self.client.post('/openid/login', response = self.client.post('/openid/login/',
{'openid_identifier': 'http://example.com/identity', {'openid_identifier': 'http://example.com/identity',
'next': '/getuser'}) 'next': '/getuser/'})
self.assertContains(response, 'OpenID transaction in progress') self.assertContains(response, 'OpenID transaction in progress')
# Complete the request # Complete the request
...@@ -317,10 +317,10 @@ class RelyingPartyTests(TestCase): ...@@ -317,10 +317,10 @@ class RelyingPartyTests(TestCase):
teams_request, 'teamname,some-other-team') teams_request, 'teamname,some-other-team')
openid_response.addExtension(teams_response) openid_response.addExtension(teams_response)
response = self.complete(openid_response) response = self.complete(openid_response)
self.assertRedirects(response, 'http://testserver/getuser') self.assertRedirects(response, 'http://testserver/getuser/')
# And they are now logged in as testuser # And they are now logged in as testuser
response = self.client.get('/getuser') response = self.client.get('/getuser/')
self.assertEquals(response.content, 'testuser') self.assertEquals(response.content, 'testuser')
# The user's groups have been updated. # The user's groups have been updated.
......
...@@ -34,6 +34,6 @@ def get_user(request): ...@@ -34,6 +34,6 @@ def get_user(request):
return HttpResponse(request.user.username) return HttpResponse(request.user.username)
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^getuser', get_user), (r'^getuser/$', get_user),
(r'^openid/', include('django_openid_auth.urls')), (r'^openid/', include('django_openid_auth.urls')),
) )
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
from django.conf.urls.defaults import * from django.conf.urls.defaults import *
urlpatterns = patterns('django_openid_auth.views', urlpatterns = patterns('django_openid_auth.views',
(r'^login$', 'login_begin'), (r'^login/$', 'login_begin'),
(r'^complete$', 'login_complete'), (r'^complete/$', 'login_complete'),
url(r'^logo$', 'logo', name='openid-logo'), url(r'^logo.gif$', 'logo', name='openid-logo'),
) )
...@@ -38,7 +38,7 @@ admin.autodiscover() ...@@ -38,7 +38,7 @@ admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^$', views.index), (r'^$', views.index),
(r'^openid/', include('django_openid_auth.urls')), (r'^openid/', include('django_openid_auth.urls')),
(r'^logout$', 'django.contrib.auth.views.logout'), (r'^logout/$', 'django.contrib.auth.views.logout'),
(r'^private/$', views.require_authentication), (r'^private/$', views.require_authentication),
(r'^admin/(.*)', admin.site.root), (r'^admin/(.*)', admin.site.root),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment