@@ -420,6 +420,90 @@ def test_no_env_from(full_route):
420420 assert expected_response == actual_response
421421
422422
423+ def test_env_from_config_map_ref_optional_property_not_present (full_route ):
424+ expected_response = load_json_as_dict (
425+ f"{ os .path .dirname (os .path .abspath (__file__ ))} /json/full-response.json"
426+ )
427+ expected_response ["children" ][0 ]["spec" ]["template" ]["spec" ]["containers" ][0 ][
428+ "envFrom"
429+ ][0 ]["configMapRef" ].pop ("optional" , None )
430+
431+ full_route ["parent" ]["spec" ]["envFrom" ][0 ]["configMapRef" ].pop ("optional" , None )
432+ actual_response = sync (full_route )
433+
434+ assert expected_response == actual_response
435+
436+
437+ def test_env_from_config_map_ref_optional_false (full_route ):
438+ expected_response = load_json_as_dict (
439+ f"{ os .path .dirname (os .path .abspath (__file__ ))} /json/full-response.json"
440+ )
441+ expected_response ["children" ][0 ]["spec" ]["template" ]["spec" ]["containers" ][0 ][
442+ "envFrom"
443+ ][0 ]["configMapRef" ]["optional" ] = False
444+
445+ full_route ["parent" ]["spec" ]["envFrom" ][0 ]["configMapRef" ]["optional" ] = False
446+ actual_response = sync (full_route )
447+
448+ assert expected_response == actual_response
449+
450+
451+ def test_env_from_config_map_ref_optional_true (full_route ):
452+ expected_response = load_json_as_dict (
453+ f"{ os .path .dirname (os .path .abspath (__file__ ))} /json/full-response.json"
454+ )
455+ expected_response ["children" ][0 ]["spec" ]["template" ]["spec" ]["containers" ][0 ][
456+ "envFrom"
457+ ][0 ]["configMapRef" ]["optional" ] = True
458+
459+ full_route ["parent" ]["spec" ]["envFrom" ][0 ]["configMapRef" ]["optional" ] = True
460+ actual_response = sync (full_route )
461+
462+ assert expected_response == actual_response
463+
464+
465+ def test_env_from_secret_ref_optional_property_not_present (full_route ):
466+ expected_response = load_json_as_dict (
467+ f"{ os .path .dirname (os .path .abspath (__file__ ))} /json/full-response.json"
468+ )
469+ expected_response ["children" ][0 ]["spec" ]["template" ]["spec" ]["containers" ][0 ][
470+ "envFrom"
471+ ][1 ]["secretRef" ].pop ("optional" , None )
472+
473+ full_route ["parent" ]["spec" ]["envFrom" ][1 ]["secretRef" ].pop ("optional" , None )
474+ actual_response = sync (full_route )
475+
476+ assert expected_response == actual_response
477+
478+
479+ def test_env_from_secret_ref_optional_false (full_route ):
480+ expected_response = load_json_as_dict (
481+ f"{ os .path .dirname (os .path .abspath (__file__ ))} /json/full-response.json"
482+ )
483+ expected_response ["children" ][0 ]["spec" ]["template" ]["spec" ]["containers" ][0 ][
484+ "envFrom"
485+ ][1 ]["secretRef" ]["optional" ] = False
486+
487+ full_route ["parent" ]["spec" ]["envFrom" ][1 ]["secretRef" ]["optional" ] = False
488+ actual_response = sync (full_route )
489+
490+ assert expected_response == actual_response
491+
492+
493+ def test_env_from_secret_ref_optional_true (full_route ):
494+ expected_response = load_json_as_dict (
495+ f"{ os .path .dirname (os .path .abspath (__file__ ))} /json/full-response.json"
496+ )
497+ expected_response ["children" ][0 ]["spec" ]["template" ]["spec" ]["containers" ][0 ][
498+ "envFrom"
499+ ][1 ]["secretRef" ]["optional" ] = True
500+
501+ full_route ["parent" ]["spec" ]["envFrom" ][1 ]["secretRef" ]["optional" ] = True
502+ actual_response = sync (full_route )
503+
504+ assert expected_response == actual_response
505+
506+
423507def test_deployment_missing_labels (full_route ):
424508 del full_route ["parent" ]["spec" ]["labels" ]
425509
0 commit comments