@@ -131,3 +131,52 @@ func TestLoadScenarios(t *testing.T) {
131131 }
132132 documentOperatorScenarios (t , "load" , loadScenarios )
133133}
134+
135+ var loadOperatorSecurityDisabledScenarios = []expressionScenario {
136+ {
137+ description : "load() operation fails when security is enabled" ,
138+ subdescription : "Use `--security-disable-file-ops` to disable file operations for security." ,
139+ expression : `load("../../examples/thing.yml")` ,
140+ expectedError : "file operations have been disabled" ,
141+ },
142+ {
143+ description : "load_str() operation fails when security is enabled" ,
144+ subdescription : "Use `--security-disable-file-ops` to disable file operations for security." ,
145+ expression : `load_str("../../examples/thing.yml")` ,
146+ expectedError : "file operations have been disabled" ,
147+ },
148+ {
149+ description : "load_xml() operation fails when security is enabled" ,
150+ subdescription : "Use `--security-disable-file-ops` to disable file operations for security." ,
151+ expression : `load_xml("../../examples/small.xml")` ,
152+ expectedError : "file operations have been disabled" ,
153+ },
154+ {
155+ description : "load_props() operation fails when security is enabled" ,
156+ subdescription : "Use `--security-disable-file-ops` to disable file operations for security." ,
157+ expression : `load_props("../../examples/small.properties")` ,
158+ expectedError : "file operations have been disabled" ,
159+ },
160+ {
161+ description : "load_base64() operation fails when security is enabled" ,
162+ subdescription : "Use `--security-disable-file-ops` to disable file operations for security." ,
163+ expression : `load_base64("../../examples/base64.txt")` ,
164+ expectedError : "file operations have been disabled" ,
165+ },
166+ }
167+
168+ func TestLoadOperatorSecurityDisabledScenarios (t * testing.T ) {
169+ // Save original security preferences
170+ originalDisableFileOps := ConfiguredSecurityPreferences .DisableFileOps
171+ defer func () {
172+ ConfiguredSecurityPreferences .DisableFileOps = originalDisableFileOps
173+ }()
174+
175+ // Test that load operations fail when DisableFileOps is true
176+ ConfiguredSecurityPreferences .DisableFileOps = true
177+
178+ for _ , tt := range loadOperatorSecurityDisabledScenarios {
179+ testScenario (t , & tt )
180+ }
181+ appendOperatorDocumentScenario (t , "load" , loadOperatorSecurityDisabledScenarios )
182+ }
0 commit comments