Skip to content

Instantly share code, notes, and snippets.

@armandomiani
Created November 13, 2019 06:13
Show Gist options
  • Save armandomiani/ac8c8a17b29961ef6178d9ee27e9eaa7 to your computer and use it in GitHub Desktop.
Save armandomiani/ac8c8a17b29961ef6178d9ee27e9eaa7 to your computer and use it in GitHub Desktop.
MediaWiki Functional Tests
apt-get install -y jq
https://gist.github.com/subfuzion/08c5d85437d5d4f00e58
# Test 301 and redirection
curl -L -I -s http://localhost | grep -E "^HTTP/1.1 301|^Location: .*/Main_Page.*$"
# api test
LOGIN_TOKEN=$(curl "http://localhost/api.php?action=query&meta=tokens&format=json&type=login" | jq -r '.query.tokens.logintoken')
CSRF_TOKEN=$(curl "http://localhost/api.php?action=query&meta=tokens&format=json | jq -r ''
ACCESS_TOKEN=$(curl -X POST "http://localhost/api.php?action=login&lgname=Admin&format=json" -d "lgpassword=mediawiki1234&lgtoken=${LOGIN_TOKEN}" | jq -r '.login.token')
curl "http://localhost/api.php?action=query&list=allpages&format=json" | jq -r '.query.allpages[0].title'
curl -X POST "http://localhost/api.php?action=edit&format=json&title=Main_Page&appendtext=Hello" -d "token=${ACCESS_TOKEN}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment