1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

fix a bug that prevents unpriveleged users from listing CredentialTypes

see: #6737
This commit is contained in:
Ryan Petrello 2017-06-27 16:45:46 -04:00
parent 70c11879a4
commit b0e51b42d8
2 changed files with 9 additions and 2 deletions

View File

@ -899,6 +899,9 @@ class CredentialTypeAccess(BaseAccess):
return False return False
return super(CredentialTypeAccess, self).get_method_capability(method, obj, parent_obj) return super(CredentialTypeAccess, self).get_method_capability(method, obj, parent_obj)
def get_queryset(self):
return self.model.objects.all()
class CredentialAccess(BaseAccess): class CredentialAccess(BaseAccess):
''' '''

View File

@ -14,16 +14,20 @@ def test_list_as_unauthorized_xfail(get):
@pytest.mark.django_db @pytest.mark.django_db
def test_list_as_normal_user(get, alice): def test_list_as_normal_user(get, alice):
ssh = CredentialType.defaults['ssh']()
ssh.save()
response = get(reverse('api:credential_type_list'), alice) response = get(reverse('api:credential_type_list'), alice)
assert response.status_code == 200 assert response.status_code == 200
assert response.data['count'] == 0 assert response.data['count'] == 1
@pytest.mark.django_db @pytest.mark.django_db
def test_list_as_admin(get, admin): def test_list_as_admin(get, admin):
ssh = CredentialType.defaults['ssh']()
ssh.save()
response = get(reverse('api:credential_type_list'), admin) response = get(reverse('api:credential_type_list'), admin)
assert response.status_code == 200 assert response.status_code == 200
assert response.data['count'] == 0 assert response.data['count'] == 1
@pytest.mark.django_db @pytest.mark.django_db