Add 'wikibase-query-run' permission and checks

Also add tests for api permissions
REQUIRES: I72b019d509985 in Wikibase

Bug: 56671
Change-Id: I4339cd7a8b908400e3a96197f5da5c639caf1556
Remove copied code in system tests

Change-Id: I3c67f8fc776cf15564239aebf6318bd9c3db8ed6