File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class ProxyConfigZone(BaseModel):
2626 `admin` enabled creating and deleting the zone.
2727 `subzones` sets the same permissions on all subzones.
2828 `all_records` will be set to `True` if no `records` are defined.
29- `read_only` will be set to `True` if `global_read_only` is `True` .
29+ `read_only` controls write permissions for this specific zone .
3030 """
3131
3232 name : str
@@ -84,15 +84,10 @@ def validate_zones_or_global_read_only(self):
8484
8585 def __init__ (self , ** data ):
8686 super ().__init__ (** data )
87- if self .global_read_only :
88- logger .debug (
89- "Setting all subzones to read_only, because global_read_only is true"
90- )
91- for zone in self .zones :
92- zone .read_only = True
93-
94- # populate zones lookup
95- self ._zones_lookup [zone .name ] = zone
87+
88+ # populate zones lookup
89+ for zone in self .zones :
90+ self ._zones_lookup [zone .name ] = zone
9691
9792 def __hash__ (self ):
9893 return hash (
Original file line number Diff line number Diff line change @@ -644,3 +644,29 @@ def test_proxy_config_with_global_read_only_environment():
644644 )
645645 assert config .environments [0 ].global_read_only is True
646646 assert config .environments [0 ].zones == []
647+
648+
649+ def test_global_read_only_with_explicit_zones_keeps_zone_permissions ():
650+ """Test that global_read_only=True doesn't force explicit zones to be read_only"""
651+ # Create a zone that should remain writable
652+ writable_zone = ProxyConfigZone (name = "example.com" , read_only = False )
653+ readonly_zone = ProxyConfigZone (name = "readonly.com" , read_only = True )
654+
655+ env = ProxyConfigEnvironment (
656+ name = "Test Global Read Only with Zones" ,
657+ token_sha512 = dummy_proxy_environment_token_sha512 ,
658+ zones = [writable_zone , readonly_zone ],
659+ global_read_only = True
660+ )
661+
662+ # global_read_only should be True
663+ assert env .global_read_only is True
664+
665+ # But explicit zones should keep their original read_only settings
666+ assert env .zones [0 ].read_only is False # writable_zone should remain writable
667+ assert env .zones [1 ].read_only is True # readonly_zone should remain read_only
668+
669+ # Should have access to zones via lookup
670+ assert len (env ._zones_lookup ) == 2
671+ assert "example.com" in env ._zones_lookup
672+ assert "readonly.com" in env ._zones_lookup
You can’t perform that action at this time.
0 commit comments