mozilla/kuma — pull request #658 by lmorchard (2012-10-17 05:21:48+00:00)
Title: bug 780038: PUT API for wiki edits

This good-sized PR is broken up into 2 parts:

1. A new `authkeys` app, which supports managing authentication keys useful for APIs, especially when users login with Persona and no longer have passwords

2. Wiki document URLs now accept HTTP PUT requests to alter content and metadata.

Since this PR introduces new models, this will require both a branch checkout and a run of `manage.py migrate`. There should be a dozen or so new tests that run all this stuff through its paces, and that will also require `FORCE_DB=1` at least once, to pick up the new models.

For a spot check, this will take a bit of work in the browser and a bit in a shell with curl:

1. Visit your profile, click "Manage API Keys", then click "Create a new key"
2. Type whatever you want into the description field, click "Create"
3. Make sure to copy and paste the key ID and secret into a notepad somewhere
4. Now, drop into a shell, and try PUT'ing edits to wiki pages like so:

KEY_ID="GWThYNoWyi45DAZQFkMQDoL6YzQ2SKk4NyrjeLKSR6M"
SECRET="aPZNUFrMe2kBgEomF8McppgPF2ZiliXXjMzIAyl35AE"
URL="https://developer-local.allizom.org/en-US/docs/User:lmorchard/Foo"
TYPE="Content-Type: application/json"
DATA='{"title":"Title of Foo","content":"HELLO WORLD"}'
curl -ksi -X PUT -H"$TYPE" -d"$DATA" -u"$KEY_ID:$SECRET" $URL

Replace the `KEY_ID` and `SECRET` values with what your new key produced. And, change the URL to one that doesn't exist on your dev machine, but give it a parent that does exist (ie. `User:{yourname}`) or just put the path at the root of the wiki. If you try PUT'ing to an URL that has missing parents in the path, you'll get a 404.

This PUT should result in a 201 Created response at first, then a 205 Reset Content for each content update.