Skip to content

Commit

Permalink
Merge branch 'prevent-collab-events-backup-restore' into 'main'
Browse files Browse the repository at this point in the history
Prevent creating collab events during backup restore

See merge request reportcreator/reportcreator!610
  • Loading branch information
MWedl committed Jul 8, 2024
2 parents 758bba7 + 2d98829 commit f9886ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/src/reportcreator_api/pentests/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def uploaded_file_deleted(sender, instance, *args, **kwargs):
@receiver(signals.post_save, sender=PentestProject)
@receiver(signals.post_save, sender=Comment)
@receiver(signals.post_save, sender=CommentAnswer)
@disable_for_loaddata
def collab_updated(sender, instance, created=False, *args, **kwargs):
from reportcreator_api.pentests.consumers import send_collab_event_project, send_collab_event_user
from reportcreator_api.pentests.serializers.notes import (
Expand Down
7 changes: 7 additions & 0 deletions api/src/reportcreator_api/tests/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from reportcreator_api.management.commands import restorebackup
from reportcreator_api.notifications.models import NotificationSpec
from reportcreator_api.pentests.models import UploadedImage
from reportcreator_api.pentests.models.collab import CollabClientInfo, CollabEvent
from reportcreator_api.pentests.models.common import LockInfo
from reportcreator_api.tests.mock import (
api_client,
create_archived_project,
Expand Down Expand Up @@ -230,6 +232,11 @@ def test_backup_restore(self):
assert fo.file.name == f['name']
assert fo.file.read() == f['content']

# No temporary DB data created
assert CollabEvent.objects.count() == 0
assert CollabClientInfo.objects.count() == 0
assert LockInfo.objects.count() == 0

# BackupLog entry created
assert list(BackupLog.objects.values_list('type', flat=True)) == [BackupLogType.RESTORE, BackupLogType.BACKUP, BackupLogType.SETUP]

Expand Down

0 comments on commit f9886ed

Please sign in to comment.