3737PACK_6_PATH = os .path .join (fixturesloader .get_fixtures_packs_base_path (), 'dummy_pack_6' )
3838PACK_19_PATH = os .path .join (fixturesloader .get_fixtures_packs_base_path (), 'dummy_pack_19' )
3939PACK_11_PATH = os .path .join (fixturesloader .get_fixtures_packs_base_path (), 'dummy_pack_11' )
40+ PACK_22_PATH = os .path .join (fixturesloader .get_fixtures_packs_base_path (), 'dummy_pack_22' )
4041
4142
4243class ConfigsRegistrarTestCase (CleanDbTestCase ):
@@ -151,6 +152,9 @@ def test_register_all_configs_with_config_schema_validation_validation_failure_2
151152 base_dirs = packs_base_paths )
152153
153154 def test_register_all_configs_with_config_schema_validation_validation_failure_3 (self ):
155+ # This test checks for values containing "decrypt_kv" jinja filter in the config
156+ # object where keys have "secret: True" set in the schema.
157+
154158 # Verify DB is empty
155159 pack_dbs = Pack .get_all ()
156160 config_dbs = Config .get_all ()
@@ -170,7 +174,38 @@ def test_register_all_configs_with_config_schema_validation_validation_failure_3
170174
171175 expected_msg = ('Values specified as "secret: True" in config schema are automatically '
172176 'decrypted by default. Use of "decrypt_kv" jinja filter is not allowed '
173- 'for such values.' )
177+ 'for such values. Please check the specified values in the config or '
178+ 'the default values in the schema.' )
179+
180+ self .assertRaisesRegexp (ValueError , expected_msg ,
181+ registrar .register_from_packs ,
182+ base_dirs = packs_base_paths )
183+
184+ def test_register_all_configs_with_config_schema_validation_validation_failure_4 (self ):
185+ # This test checks for default values containing "decrypt_kv" jinja filter for
186+ # keys which have "secret: True" set.
187+
188+ # Verify DB is empty
189+ pack_dbs = Pack .get_all ()
190+ config_dbs = Config .get_all ()
191+
192+ self .assertEqual (len (pack_dbs ), 0 )
193+ self .assertEqual (len (config_dbs ), 0 )
194+
195+ registrar = ConfigsRegistrar (use_pack_cache = False , fail_on_failure = True ,
196+ validate_configs = True )
197+ registrar ._pack_loader .get_packs = mock .Mock ()
198+ registrar ._pack_loader .get_packs .return_value = {'dummy_pack_22' : PACK_22_PATH }
199+
200+ # Register ConfigSchema for pack
201+ registrar ._register_pack_db = mock .Mock ()
202+ registrar ._register_pack (pack_name = 'dummy_pack_22' , pack_dir = PACK_22_PATH )
203+ packs_base_paths = content_utils .get_packs_base_paths ()
204+
205+ expected_msg = ('Values specified as "secret: True" in config schema are automatically '
206+ 'decrypted by default. Use of "decrypt_kv" jinja filter is not allowed '
207+ 'for such values. Please check the specified values in the config or '
208+ 'the default values in the schema.' )
174209
175210 self .assertRaisesRegexp (ValueError , expected_msg ,
176211 registrar .register_from_packs ,
0 commit comments