Last modified: 2013-12-29 07:03:18 UTC
The Mediawiki API provides the ability to create new user accounts[1] For example, the following two Curl commands issued in sequence will create a new user at a Mediawiki instance running on "localhost": curl -c cookies.txt -X POST "http://localhost/mediawiki/api.php?action=createaccount&name=Tester&password=test1234&language=en&format=json&token=" curl -b cookies.txt -X POST "http://localhost/mediawiki/api.php?action=createaccount&name=Tester&password=test1234&language=en&format=json&token=<token provided in response to previous request>" As a proof-of-concept, create a Python script that will do the same thing, with two special functions: 1) The URL of the Mediawiki instance should be created from the value of an environment variable called "API_URL" (for example, using Python's "os.getenv" method). 2) The account name and password should be randomly generated alphanumeric strings, each with a length of 8 characters. [1] http://www.mediawiki.org/wiki/API:Account_creation
Why?
Script is available at https://gist.github.com/theopolisme/8143834 :) Like Sam, I am curious as to what this is going to be used for, though. Thanks!
Thanks Theopoliosme! This was actually intended as a task for Google Code-in students, but I guess you beat them to the punch!
You're very welcome. I actually *am* a GCI participant, interestingly enough :)
OK, I didn't realize you were a GCI participant Theopoliosme - thanks for working on this task! I ran into a minor error when running the script locally, and added that comment to the GCI task: http://www.google-melange.com/gci/task/view/google/gci2013/5788241391255552 In reference to the questions about WHY we want this script, it's to complement an existing Python script used to generated new wiki articles, and the scripts in tandem will eventually be used for running automated browser tests against new releases, with the goal that each test is "hermetic" and can run against a fresh Mediawiki install without assuming the presence of certain user accounts and articles (the test should create whatever user logins and article content it needs).