Fix repositories.get_all_permissions, add tests. closes #3546