@@ -43,7 +43,11 @@ def client():
43
43
44
44
[user:demo-example-org]
45
45
key = dd70d1b0eccd79a0cf5d79ddf6672dce
46
- allow-suffix-creation = example.org.
46
+ allow-suffix-creation = example.org. .example.test.
47
+
48
+ [user:demo-example-net]
49
+ key = a70f4f5fe78ea2e89b53c8b3ee133fdf
50
+ allow-suffix-creation = example.net.
47
51
"""
48
52
49
53
pdns_db_file , pdns_db_path = tempfile .mkstemp ()
@@ -147,10 +151,14 @@ def test_api_auth(client):
147
151
assert response .status_code > 400
148
152
149
153
def test_api_zone_create (client ):
150
- # zone that the user is not allowed to create
154
+ # zone that the user is not allowed to create because it is not listed at all
151
155
response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "example.com." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
152
156
assert response .status_code > 400
153
157
158
+ # zone that the user is not allowed to create but which does share a common prefix with one they can create
159
+ response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "fooexample.org." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
160
+ assert response .status_code > 400
161
+
154
162
# zone belonging to another user
155
163
response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "example.net." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
156
164
assert response .status_code > 400
@@ -163,6 +171,14 @@ def test_api_zone_create(client):
163
171
response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "example.org." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
164
172
assert response .status_code > 400
165
173
174
+ # suffix matching a wildcard domain
175
+ response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "bar.example.test." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
176
+ assert response .status_code < 400
177
+
178
+ # disallow suffix on non-wildcard domain
179
+ response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "bar.example.org." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
180
+ assert response .status_code > 400
181
+
166
182
def test_api_zone_list (client ):
167
183
# create a zone to use for testing
168
184
response = client .post ('/api/v1/servers/localhost/zones' , headers = api_key_header (client ), json = {"masters" : [], "name" : "example.org." , "nameservers" : ["ns1.example.org." ], "kind" : "MASTER" , "soa_edit_api" : "INCEPTION-INCREMENT" })
0 commit comments