summaryrefslogtreecommitdiff
path: root/src/mailman/tests
diff options
context:
space:
mode:
authorroot2010-09-29 10:36:17 +0200
committerroot2010-09-29 10:36:17 +0200
commit14caf656788903a553c4a374b3f9a934a4014033 (patch)
treed00d26b5fd9ecccd0e6b4d909a6772e007ed5a3c /src/mailman/tests
parentba794763b95ebbb7786b7af49e9a359e403ae963 (diff)
downloadmailman-14caf656788903a553c4a374b3f9a934a4014033.tar.gz
mailman-14caf656788903a553c4a374b3f9a934a4014033.tar.zst
mailman-14caf656788903a553c4a374b3f9a934a4014033.zip
Diffstat (limited to 'src/mailman/tests')
-rw-r--r--src/mailman/tests/test_documentation.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mailman/tests/test_documentation.py b/src/mailman/tests/test_documentation.py
index c0f8dca20..2b3e417f3 100644
--- a/src/mailman/tests/test_documentation.py
+++ b/src/mailman/tests/test_documentation.py
@@ -39,6 +39,7 @@ from email import message_from_string
from httplib2 import Http
from urllib import urlencode
from urllib2 import HTTPError
+from base64 import encodestring
import mailman
@@ -109,7 +110,7 @@ def dump_msgdata(msgdata, *additional_skips):
print '{0:{2}}: {1}'.format(key, msgdata[key], longest)
-def call_http(url, data=None, method=None):
+def call_http(url, data=None, method=None, username="restadmin", password="restpass"):
"""'Call' a URL with a given HTTP method and return the resulting object.
The object will have been JSON decoded.
@@ -131,6 +132,7 @@ def call_http(url, data=None, method=None):
else:
method = 'POST'
method = method.upper()
+ headers['Authorization'] = 'Basic %s' % encodestring('%s:%s' % (username, password)).replace('\n', '')
response, content = Http().request(url, method, data, headers)
# If we did not get a 2xx status code, make this look like a urllib2
# exception, for backward compatibility with existing doctests.
@@ -143,7 +145,7 @@ def call_http(url, data=None, method=None):
return json.loads(content)
-def dump_json(url, data=None, method=None):
+def dump_json(url, data=None, method=None, username="restadmin", password="restpass"):
"""Print the JSON dictionary read from a URL.
:param url: The url to open, read, and print.
@@ -153,7 +155,7 @@ def dump_json(url, data=None, method=None):
:param method: Alternative HTTP method to use.
:type method: str
"""
- data = call_http(url, data, method)
+ data = call_http(url, data, method, username, password)
if data is None:
return
for key in sorted(data):