Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced testing environment, added first failing test for simplest c…
…ase.
- Loading branch information
almad
committed
Oct 21, 2008
1 parent
e5d9ffa
commit 797c4a5
Showing
12 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
Support for HTTP digest client. | ||
""" | ||
|
||
from md5 import md5 | ||
from django.test.client import Client | ||
|
||
__all__ = ["HttpDigestClient"] | ||
|
||
class HttpDigestClient(Client): | ||
""" Extend Django's client for HTTP digest support """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
This is only dummy module. djangohttpdigest do not require to be | ||
django app installed in INSTALLED_APPS. | ||
But some people seems to be used to it, and we're using it in our | ||
testproject, too. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from test_simple_digest import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.test import TestCase | ||
from djangohttpdigest.client import HttpDigestClient | ||
|
||
class TestSimpleDigest(TestCase): | ||
|
||
def test_simple_authorization(self): | ||
""" Test view protected by simple realm-username-password decorator """ | ||
path = '/testapi/simpleprotected/' | ||
|
||
# first test that using normal client, path is protected and returns 401 | ||
response = self.client.get(path) | ||
self.assertEquals(401, response.status_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../djangohttpdigest/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('testapi.views', | ||
url('simpleprotected', 'simpleprotected'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.http import HttpResponse | ||
|
||
def simpleprotected(request): | ||
""" | ||
This is example of far too simply protected value | ||
Required credentials are given as argument to decorator, | ||
view returns 401 on failure or for challenge, 200 with empty body | ||
on successfull authorization. | ||
""" | ||
|
||
return HttpResponse('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('', | ||
url('^testapi/', include('testapi.urls')), | ||
) |