Skip to content

Instantly share code, notes, and snippets.

@armandomiani
Created November 13, 2019 06:13
Show Gist options
  • Select an option

  • Save armandomiani/ac8c8a17b29961ef6178d9ee27e9eaa7 to your computer and use it in GitHub Desktop.

Select an option

Save armandomiani/ac8c8a17b29961ef6178d9ee27e9eaa7 to your computer and use it in GitHub Desktop.

Revisions

  1. armandomiani created this gist Nov 13, 2019.
    17 changes: 17 additions & 0 deletions tests.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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}"