File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from functools import lru_cache
22from typing import TypedDict
33
4- from pydantic import BaseModel , field_validator , model_validator
4+ from pydantic import BaseModel , field_validator
55
66from powerdns_api_proxy .logging import logger
77from powerdns_api_proxy .utils import (
@@ -77,14 +77,6 @@ def validate_token(cls, token_sha512):
7777 raise ValueError ("A SHA512 hash must be 128 digits long" )
7878 return token_sha512
7979
80- @model_validator (mode = "after" )
81- def validate_zones_or_global_read_only (self ):
82- if not self .zones and not self .global_read_only :
83- raise ValueError (
84- "Either 'zones' must be non-empty or 'global_read_only' must be True"
85- )
86- return self
87-
8880 def __init__ (self , ** data ):
8981 super ().__init__ (** data )
9082
Original file line number Diff line number Diff line change @@ -629,26 +629,15 @@ def test_global_read_only_without_zones():
629629 assert env .zones == []
630630
631631
632- def test_environment_with_neither_zones_nor_global_read_only_fails ():
633- """Test that providing neither zones nor global_read_only fails validation"""
634- with pytest .raises (ValueError ) as err :
635- ProxyConfigEnvironment (
636- name = "test" , token_sha512 = dummy_proxy_environment_token_sha512
637- )
638- assert "Either 'zones' must be non-empty or 'global_read_only' must be True" in str (
639- err .value
640- )
641-
642-
643- def test_environment_with_empty_zones_and_no_global_read_only_fails ():
644- """Test that explicitly providing empty zones without global_read_only fails"""
645- with pytest .raises (ValueError ) as err :
646- ProxyConfigEnvironment (
647- name = "test" , token_sha512 = dummy_proxy_environment_token_sha512 , zones = []
648- )
649- assert "Either 'zones' must be non-empty or 'global_read_only' must be True" in str (
650- err .value
632+ def test_environment_with_empty_zones_denies_zone_access ():
633+ """Test that environment with empty zones and no global permissions denies zone access"""
634+ env = ProxyConfigEnvironment (
635+ name = "test" ,
636+ token_sha512 = dummy_proxy_environment_token_sha512 ,
637+ zones = [],
651638 )
639+ assert not check_pdns_zone_allowed (env , "test.example.com." )
640+ assert not check_pdns_zone_allowed (env , "any.zone.com." )
652641
653642
654643def test_proxy_config_with_global_read_only_environment ():
You can’t perform that action at this time.
0 commit comments