diff --git a/awx/main/signals.py b/awx/main/signals.py index 52bd5e55c0..5021f53290 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -400,6 +400,12 @@ model_serializer_mapping = { AdHocCommand: AdHocCommandSerializer, NotificationTemplate: NotificationTemplateSerializer, Notification: NotificationSerializer, + CredentialType: CredentialTypeSerializer, + Schedule: ScheduleSerializer, + Label: LabelSerializer, + WorkflowJobTemplate: WorkflowJobTemplateSerializer, + WorkflowJobTemplateNode: WorkflowJobTemplateNodeSerializer, + WorkflowJob: WorkflowJobSerializer, } diff --git a/awx/main/tests/functional/models/test_activity_stream.py b/awx/main/tests/functional/models/test_activity_stream.py index 7253999fb7..f13ce48f20 100644 --- a/awx/main/tests/functional/models/test_activity_stream.py +++ b/awx/main/tests/functional/models/test_activity_stream.py @@ -16,6 +16,7 @@ from awx.main.models import ( # other AWX from awx.main.utils import model_to_dict +from awx.main.utils.common import get_allowed_fields from awx.api.serializers import InventorySourceSerializer # Django @@ -181,3 +182,20 @@ def test_annon_user_action(): inv = Inventory.objects.create(name='ainventory') entry = inv.activitystream_set.filter(operation='create').first() assert not entry.actor + + +@pytest.mark.django_db +def test_modified_not_allowed_field(somecloud_type): + ''' + If this test fails, that means that read-only fields are showing + up in the activity stream serialization of an instance. + + That _probably_ means that you just connected a new model to the + activity_stream_registrar, but did not add its serializer to + the model->serializer mapping. + ''' + from awx.main.signals import model_serializer_mapping + from awx.main.registrar import activity_stream_registrar + + for Model in activity_stream_registrar.models: + assert 'modified' not in get_allowed_fields(Model(), model_serializer_mapping), Model