Skip to content

Commit 7d38872

Browse files
alielMHHukiewitz
authored andcommitted
* Custom Domain, raise exception at the end of checks
1 parent 89f470c commit 7d38872

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/aleph/sdk/domain.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ async def check_domain(
187187
Returns:
188188
A dictionary containing the status of the domain configuration.
189189
"""
190-
status = {"cname": False, "owner_proof": False}
190+
status = {}
191191

192192
dns_rules = self.get_required_dns_rules(hostname, target, owner)
193-
193+
resolver = await self.get_resolver_for(hostname)
194194
for dns_rule in dns_rules:
195195
status[dns_rule.name] = False
196196

@@ -199,26 +199,25 @@ async def check_domain(
199199
record_value = dns_rule.dns["value"]
200200

201201
try:
202-
resolver = await self.get_resolver_for(hostname)
203202
entries = await resolver.query(record_name, record_type.upper())
204203
except aiodns.error.DNSError:
205204
# Continue checks
206205
entries = None
207206

208-
if entries and record_type == "txt":
209-
for entry in entries:
210-
if hasattr(entry, "text") and entry.text == record_value:
211-
break
212-
else:
213-
return dns_rule.raise_error(status)
214-
elif (
215-
entries is None
216-
or not hasattr(entries, record_type)
217-
or getattr(entries, record_type) != record_value
218-
):
219-
return dns_rule.raise_error(status)
220-
221-
status[dns_rule.name] = True
207+
if entries:
208+
if record_type == "txt":
209+
for entry in entries:
210+
if hasattr(entry, "text") and entry.text == record_value:
211+
status[dns_rule.name] = True
212+
break
213+
elif (
214+
hasattr(entries, record_type)
215+
and getattr(entries, record_type) == record_value
216+
):
217+
status[dns_rule.name] = True
218+
219+
if all(status.values()) is False:
220+
dns_rule.raise_error(status)
222221

223222
return status
224223

0 commit comments

Comments
 (0)