summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2010-10-12 10:54:35 -0400
committerBarry Warsaw2010-10-12 10:54:35 -0400
commit1ad87091c3fdbf4be7dec33fc31d3a2c767a8f35 (patch)
treeb572737570ba4f29d7e6c2495aed5e46f4897395 /src
parent9dd13dc84e39702c8abb0a4bf8d513bf3a35ebbd (diff)
downloadmailman-1ad87091c3fdbf4be7dec33fc31d3a2c767a8f35.tar.gz
mailman-1ad87091c3fdbf4be7dec33fc31d3a2c767a8f35.tar.zst
mailman-1ad87091c3fdbf4be7dec33fc31d3a2c767a8f35.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/rest/docs/basic.txt32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/mailman/rest/docs/basic.txt b/src/mailman/rest/docs/basic.txt
index 177082c4a..614b074ba 100644
--- a/src/mailman/rest/docs/basic.txt
+++ b/src/mailman/rest/docs/basic.txt
@@ -44,13 +44,33 @@ Invalid credentials
When you try to access the REST server using invalid credentials you will get
an appropriate HTTP 401 Unauthorized error.
+::
- >>> dump_json('http://localhost:8001/3.0/system',
- ... username='baduser', password='badpass')
- Traceback (most recent call last):
- ...
- HTTPError: HTTP Error 401: 401 Unauthorized
- ...
+ >>> from base64 import b64encode
+ >>> auth = b64encode('baduser:badpass')
+
+ >>> url = 'http://localhost:8001/3.0/system'
+ >>> headers = {
+ ... 'Content-Type': 'application/x-www-form-urlencode',
+ ... 'Authorization': 'Basic ' + auth,
+ ... }
+
+ >>> from httplib2 import Http
+ >>> response, content = Http().request(url, 'GET', None, headers)
+ >>> print content
+ 401 Unauthorized
+ <BLANKLINE>
+ User is not authorized for the REST API
+ <BLANKLINE>
+
+But with the right headers, the request succeeds.
+
+ >>> auth = b64encode('{0}:{1}'.format(config.webservice.admin_user,
+ ... config.webservice.admin_pass))
+ >>> headers['Authorization'] = 'Basic ' + auth
+ >>> response, content = Http().request(url, 'GET', None, headers)
+ >>> print response.status
+ 200
.. _REST: http://en.wikipedia.org/wiki/REST