mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
filter Insights credentials from /api/v1/credentials/
see: #6978 see: #6088
This commit is contained in:
parent
bc869284f7
commit
28f44c3ab0
@ -39,9 +39,11 @@ class V1CredentialFilterBackend(BaseFilterBackend):
|
||||
'''
|
||||
|
||||
def filter_queryset(self, request, queryset, view):
|
||||
# TODO: remove in 3.3
|
||||
from awx.api.versioning import get_request_version
|
||||
if get_request_version(request) == 1:
|
||||
queryset = queryset.filter(credential_type__managed_by_tower=True)
|
||||
queryset = queryset.filter(~Q(credential_type__kind='insights'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
||||
@ -67,6 +67,29 @@ def test_filter_by_v1_kind_with_vault(get, admin, organization):
|
||||
assert response.data['count'] == 2
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_insights_credentials_not_in_v1_api_list(get, admin, organization):
|
||||
credential_type = CredentialType.defaults['insights']()
|
||||
credential_type.save()
|
||||
cred = Credential(
|
||||
credential_type=credential_type,
|
||||
name='Best credential ever',
|
||||
organization=organization,
|
||||
inputs={
|
||||
'username': u'joe',
|
||||
'password': u'secret'
|
||||
}
|
||||
)
|
||||
cred.save()
|
||||
|
||||
response = get(
|
||||
reverse('api:credential_list', kwargs={'version': 'v1'}),
|
||||
admin
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.data['count'] == 0
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_custom_credentials_not_in_v1_api_list(get, admin, organization):
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user