Page MenuHomePhabricator

Write Python script to create new wiki user(s)
Closed, ResolvedPublic

Description

Author: jhall

Description:
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).
  1. 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


Version: wmf-deployment
Severity: enhancement
Whiteboard: gci2013 https://www.mediawiki.org/wiki/Google_Code-In#Candidate_tasks

Details

Reference
bz58980

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:27 AM
bzimport set Reference to bz58980.

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!

jhall wrote:

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 :)

jhall wrote:

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).