Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/olympia/scanners/migrations/0089_alter_scannerwebhook_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.2.17 on 2026-09-03 12:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scanners', '0088_alter_scannerqueryrule_run_on_specific_channel'),
]

operations = [
migrations.AlterField(
model_name='scannerwebhook',
name='name',
field=models.CharField(max_length=100, unique=True),
),
]
2 changes: 1 addition & 1 deletion src/olympia/scanners/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class Meta(AbstractScannerRule.Meta):


class ScannerWebhook(ModelBase):
name = models.CharField(max_length=100)
name = models.CharField(max_length=100, unique=True)
url = models.URLField(max_length=255)
api_key = models.CharField(max_length=255)
is_active = models.BooleanField(default=True)
Expand Down
11 changes: 11 additions & 0 deletions src/olympia/scanners/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest import mock

from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError

import pytest
import time_machine
Expand Down Expand Up @@ -849,3 +850,13 @@ def test_save_does_not_recreate_service_account_on_rename(self):

assert webhook.service_account == original_account
assert UserProfile.objects.count() == expected_count

def test_name_is_unique(self):
ScannerWebhook.objects.create(
name='some-name', url='https://example.com', api_key='secret'
)

with pytest.raises(IntegrityError):
ScannerWebhook.objects.create(
name='some-name', url='https://example.org', api_key='other-secret'
)
Loading