diff --git a/api/desecapi/tests/test_token_domain_policy.py b/api/desecapi/tests/test_token_domain_policy.py index 4bb681479..efe635348 100644 --- a/api/desecapi/tests/test_token_domain_policy.py +++ b/api/desecapi/tests/test_token_domain_policy.py @@ -725,17 +725,30 @@ def test_auto_policy_from_creation(self): def test_create_domain(self): self.token.auto_policy = True self.token.save() + self.token_manage.perm_create_domain = True + self.token_manage.save() - name = "domain.example" - with self.assertRequests(self.requests_desec_domain_creation(name)): + name_auto = "domain.example" + name_other = "other.example" + with self.assertRequests(self.requests_desec_domain_creation(name_other)): + response = self.client._request( + self.client.post, + self.reverse("v1:domain-list"), + using=self.token_manage, + data={"name": name_other}, + ) + self.assertStatus(response, status.HTTP_201_CREATED) + with self.assertRequests(self.requests_desec_domain_creation(name_auto)): response = self.client._request( self.client.post, self.reverse("v1:domain-list"), using=self.token, - data={"name": name}, + data={"name": name_auto}, ) self.assertStatus(response, status.HTTP_201_CREATED) self.assertEqual(self.token.tokendomainpolicy_set.count(), 2) - rrset = models.RRset(domain=models.Domain.objects.get(name=name)) + rrset = models.RRset(domain=models.Domain.objects.get(name=name_auto)) self.assertTrue(self.token.get_policy(rrset).perm_write) + rrset = models.RRset(domain=models.Domain.objects.get(name=name_other)) + self.assertFalse(self.token.get_policy(rrset).perm_write)