AAP-39778[Backport][release_4.6] Add DAB Feature Flag common API (#6833)

* [AAP-39138] - Add DAB Feature Flag common API (#15786)
* Update django-ansible-base reference to ansible-automation-platform/django-ansible-base@stable-2.5

---------

Co-authored-by: Zack Kayyali <zkayyali@redhat.com>
This commit is contained in:
Hao Liu 2025-02-12 15:47:06 -05:00 committed by GitHub
parent 397fb297bf
commit ccb6360a96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,36 @@
import pytest
from django.test import override_settings
from awx.main.models import User
@override_settings(FLAGS={})
@pytest.mark.django_db
def test_feature_flags_list_endpoint(get):
bob = User.objects.create(username='bob', password='test_user', is_superuser=False)
url = "/api/v2/feature_flags_state/"
response = get(url, user=bob, expect=200)
assert len(response.data) == 0
@override_settings(
FLAGS={
"FEATURE_SOME_PLATFORM_FLAG_ENABLED": [
{"condition": "boolean", "value": False},
{"condition": "before date", "value": "2022-06-01T12:00Z"},
],
"FEATURE_SOME_PLATFORM_FLAG_FOO_ENABLED": [
{"condition": "boolean", "value": True},
],
}
)
@pytest.mark.django_db
def test_feature_flags_list_endpoint_override(get):
bob = User.objects.create(username='bob', password='test_user', is_superuser=False)
url = "/api/v2/feature_flags_state/"
response = get(url, user=bob, expect=200)
assert len(response.data) == 2
assert response.data["FEATURE_SOME_PLATFORM_FLAG_ENABLED"] is False
assert response.data["FEATURE_SOME_PLATFORM_FLAG_FOO_ENABLED"] is True

View File

@ -366,6 +366,7 @@ INSTALLED_APPS = [
'ansible_base.jwt_consumer',
'ansible_base.resource_registry',
'ansible_base.rbac',
'ansible_base.feature_flags',
'flags',
]

View File

@ -1,4 +1,4 @@
git+https://github.com/ansible/system-certifi.git@devel#egg=certifi
# Remove pbr from requirements.in when moving ansible-runner to requirements.in
git+https://github.com/ansible/python3-saml.git@devel#egg=python3-saml
django-ansible-base @ git+https://github.com/ansible/django-ansible-base@2024.10.17#egg=django-ansible-base[rest_filters,jwt_consumer,resource_registry,rbac]
django-ansible-base @ git+https://github.com/ansible-automation-platform/django-ansible-base@stable-2.5#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac,feature-flags]