mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 22:35:08 -02:30
fix bug introduced with anon user activity stream entries
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import mock
|
||||
|
||||
import json
|
||||
|
||||
@@ -9,6 +10,7 @@ from awx.main.models import (
|
||||
JobTemplate,
|
||||
Credential,
|
||||
CredentialType,
|
||||
Inventory,
|
||||
InventorySource
|
||||
)
|
||||
|
||||
@@ -16,6 +18,9 @@ from awx.main.models import (
|
||||
from awx.main.utils import model_to_dict
|
||||
from awx.api.serializers import InventorySourceSerializer
|
||||
|
||||
# Django
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
|
||||
# Django-CRUM
|
||||
from crum import impersonate
|
||||
|
||||
@@ -168,3 +173,12 @@ def test_activity_stream_actor(admin_user):
|
||||
o = Organization.objects.create(name='test organization')
|
||||
entry = o.activitystream_set.get(operation='create')
|
||||
assert entry.actor == admin_user
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_annon_user_action():
|
||||
with mock.patch('awx.main.signals.get_current_user') as u_mock:
|
||||
u_mock.return_value = AnonymousUser()
|
||||
inv = Inventory.objects.create(name='ainventory')
|
||||
entry = inv.activitystream_set.filter(operation='create').first()
|
||||
assert not entry.actor
|
||||
|
||||
Reference in New Issue
Block a user