@@ -194,3 +194,74 @@ def test_validate_without_release():
194194 config = HelmValuesConfig ()
195195 with pytest .raises (ValueError , match = "Release name is required" ):
196196 config .validate ()
197+
198+
199+ def test_release_name_validation ():
200+ """
201+ Test that release names are properly validated.
202+
203+ Release names must match the following pattern: ^[a-z0-9-]{1,53}$.
204+ """
205+ # Valid cases
206+ valid_names = [
207+ "my-release" ,
208+ "release123" ,
209+ "a-b-c-123" ,
210+ "a" * 53 , # max length
211+ ]
212+ for name in valid_names :
213+ config = {"version" : "1.0" , "release" : name , "deployments" : {}, "config" : []}
214+ HelmValuesConfig ._validate_schema (config ) # Should not raise
215+
216+ # Invalid cases
217+ invalid_names = [
218+ "UPPERCASE" , # uppercase not allowed
219+ "my_release" , # underscore not allowed
220+ "my.release" , # dot not allowed
221+ "-starts-with-hyphen" , # cannot start with hyphen
222+ "ends-with-hyphen-" , # cannot end with hyphen
223+ "a" * 54 , # too long
224+ "" , # empty string
225+ ]
226+ for name in invalid_names :
227+ config = {"version" : "1.0" , "release" : name , "deployments" : {}, "config" : []}
228+ with pytest .raises (jsonschema .exceptions .ValidationError ):
229+ HelmValuesConfig ._validate_schema (config )
230+
231+
232+ def test_deployment_name_validation ():
233+ """
234+ Test that deployment names are properly validated.
235+
236+ Deployment names must match the following pattern: ^[a-z0-9-]{1,53}$.
237+ """
238+ # Valid cases
239+ valid_config = {
240+ "version" : "1.0" ,
241+ "release" : "test-release" ,
242+ "deployments" : {
243+ "my-deployment" : {"backend" : "no-backend" , "auth" : {"type" : "no-auth" }},
244+ "deployment123" : {"backend" : "no-backend" , "auth" : {"type" : "no-auth" }},
245+ "a-b-c-123" : {"backend" : "no-backend" , "auth" : {"type" : "no-auth" }},
246+ },
247+ "config" : [],
248+ }
249+ HelmValuesConfig ._validate_schema (valid_config ) # Should not raise
250+
251+ # Invalid cases - test one by one to ensure proper validation
252+ base_config = {"version" : "1.0" , "release" : "test-release" , "deployments" : {}, "config" : []}
253+
254+ invalid_names = [
255+ "UPPERCASE" , # uppercase not allowed
256+ "my_deployment" , # underscore not allowed
257+ "my.deployment" , # dot not allowed
258+ "-starts-with-hyphen" , # cannot start with hyphen
259+ "ends-with-hyphen-" , # cannot end with hyphen
260+ "" , # empty string
261+ ]
262+
263+ for name in invalid_names :
264+ config = dict (base_config )
265+ config ["deployments" ] = {name : {"backend" : "no-backend" , "auth" : {"type" : "no-auth" }}}
266+ with pytest .raises (jsonschema .exceptions .ValidationError ):
267+ HelmValuesConfig ._validate_schema (config )
0 commit comments