Skip to content

Commit 711e974

Browse files
authored
Merge pull request #162 from quantum5/dnssec-rectify
feat(rectify): implement DNSSEC rectify API proxying
2 parents d985ac5 + 5e450d0 commit 711e974

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

powerdns_api_proxy/proxy.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,30 @@ async def zone_notification(server_id: str, zone_id: str, X_API_Key: str = Heade
416416
return JSONResponse(content=pdns_response.data, status_code=status_code)
417417

418418

419+
@router_pdns.put("/servers/{server_id}/zones/{zone_id}/rectify")
420+
async def zone_rectification(
421+
response: Response, server_id: str, zone_id: str, X_API_Key: str = Header()
422+
):
423+
"""
424+
Rectify the zone data.
425+
426+
<https://doc.powerdns.com/authoritative/http-api/zone.html#put--servers-server_id-zones-zone_id-rectify>
427+
"""
428+
environment = get_environment_for_token(config, X_API_Key)
429+
if not check_pdns_zone_allowed(environment, zone_id):
430+
logger.info(f"Zone {zone_id} not allowed for environment {environment.name}")
431+
raise ZoneNotAllowedException()
432+
resp = await pdns.put(f"/api/v1/servers/{server_id}/zones/{zone_id}/rectify")
433+
pdns_response = await handle_pdns_response(resp)
434+
status_code = pdns_response.raise_for_error()
435+
436+
# PUT operations often return 204 No Content
437+
if status_code == HTTPStatus.NO_CONTENT:
438+
return Response(status_code=HTTPStatus.NO_CONTENT)
439+
440+
return JSONResponse(content=pdns_response.data, status_code=status_code)
441+
442+
419443
@router_pdns.get("/servers/{server_id}/search-data")
420444
async def search_data(
421445
server_id: str,

tests/unit/proxy_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def test_api_post_missing_token(path, fixture_patch_dummy_config, fixture_patch_
118118
put_routes = [
119119
"/api/v1/servers/localhost/zones/test-zone.example.com.",
120120
"/api/v1/servers/localhost/zones/test-zone.example.com./notify",
121+
"/api/v1/servers/localhost/zones/test-zone.example.com./rectify",
121122
]
122123

123124

0 commit comments

Comments
 (0)