Skip to content

Commit 5a02ba0

Browse files
fixup! fix(api): catch duplicate records in RRset on database layer
1 parent d6b68e8 commit 5a02ba0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

api/desecapi/tests/test_rrsets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.core.exceptions import ValidationError
99
from django.core.management import call_command
1010
from django.db import IntegrityError
11+
from psycopg.errors import ExclusionViolation
1112
from rest_framework import status
1213

1314
from desecapi.models import BlockedSubnet, Domain, RR, RRset
@@ -18,14 +19,15 @@
1819
class UnauthenticatedRRSetTestCase(DesecTestCase):
1920
def test_unique_record_in_rrset(self):
2021
domain = self.create_domain()
21-
with self.assertRaises(IntegrityError):
22+
with self.assertRaises(IntegrityError) as cm:
2223
RRset.objects.create(
2324
domain=domain,
2425
subname="foo",
2526
type="A",
26-
ttl=300,
27+
ttl=3600,
2728
contents=["1.2.3.4"] * 2,
2829
)
30+
self.assertIsInstance(cm.exception.__cause__, ExclusionViolation)
2931

3032
def test_unauthorized_access(self):
3133
url = self.reverse("v1:rrsets", name="example.com")

0 commit comments

Comments
 (0)