-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip feat(api,webapp): add token domain policy and GUI functionality
Related: #347
- Loading branch information
1 parent
899d9fb
commit fa1b589
Showing
8 changed files
with
163 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 3.1.3 on 2020-11-23 19:39 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('desecapi', '0015_rrset_touched_index'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='token', | ||
name='user', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.CreateModel( | ||
name='TokenDomainPolicy', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('perm_dyndns', models.BooleanField(default=False)), | ||
('perm_other', models.BooleanField(default=False)), | ||
('domain', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='desecapi.domain')), | ||
('token', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='desecapi.token')), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='token', | ||
name='domain_policies', | ||
field=models.ManyToManyField(through='desecapi.TokenDomainPolicy', to='desecapi.Domain'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='tokendomainpolicy', | ||
constraint=models.UniqueConstraint(fields=('token', 'domain'), name='unique_entry'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='tokendomainpolicy', | ||
constraint=models.UniqueConstraint(condition=models.Q(domain__isnull=True), fields=('token',), name='unique_entry_null_domain'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from rest_framework import status | ||
|
||
from desecapi.models import Token | ||
from desecapi.tests.base import DomainOwnerTestCase | ||
|
||
|
||
class TokenDomainPolicyTestCase(DomainOwnerTestCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.token.perm_manage_tokens = True | ||
self.token.save() | ||
self.token2 = self.create_token(self.owner, name='testtoken') | ||
self.other_token = self.create_token(self.user) | ||
|
||
def test_list_domains(self): | ||
response = self.client.get(self.reverse('v1:domain-list')) | ||
self.assertStatus(response, status.HTTP_200_OK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
from ipaddress import IPv4Network | ||
|
||
from rest_framework import status | ||
|
||
from desecapi.models import Token | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters