def test_parameters_inconsistent_encrypted_param_names(self):
    tmpl = template_format.parse('\n        heat_template_version: 2013-05-23\n        parameters:\n            param1:\n                type: string\n                description: value1.\n            param2:\n                type: string\n                description: value2.\n                hidden: true\n        resources:\n            a_resource:\n                type: GenericResourceType\n        ')
    warning_logger = self.useFixture(fixtures.FakeLogger(level=logging.WARNING, format='%(levelname)8s [%(name)s] %(message)s'))
    cfg.CONF.set_override('encrypt_parameters_and_properties', False)
    env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'})
    self.stack = stack.Stack(self.ctx, 'test', template.Template(tmpl, env=env1))
    self.stack.store()
    loaded_stack = stack.Stack.load(self.ctx, stack_id=self.stack.id)
    loaded_stack.state_set(self.stack.CREATE, self.stack.COMPLETE, 'for_update')
    env2 = environment.Environment({'param1': 'foo', 'param2': 'new_bar'})
    env2.encrypted_param_names = ['param1']
    new_stack = stack.Stack(self.ctx, 'test_update', template.Template(tmpl, env=env2))
    self.assertIsNone(loaded_stack.update(new_stack))
    self.assertIn('Encountered already-decrypted data', warning_logger.output)
def test_parameters_inconsistent_encrypted_param_names(self):
    tmpl = template_format.parse('\n        heat_template_version: 2013-05-23\n        parameters:\n            param1:\n                type: string\n                description: value1.\n            param2:\n                type: string\n                description: value2.\n                hidden: true\n        resources:\n            a_resource:\n                type: GenericResourceType\n        ')
    warning_logger = self.useFixture(fixtures.FakeLogger(level=logging.WARNING, format='%(levelname)8s [%(name)s] %(message)s'))
    cfg.CONF.set_override('encrypt_parameters_and_properties', False)
    env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'})
    self.stack = stack.Stack(self.ctx, 'test', template.Template(tmpl, env=env1))
    self.stack.store()
    loaded_stack = stack.Stack.load(self.ctx, stack_id=self.stack.id)
    loaded_stack.state_set(self.stack.CREATE, self.stack.COMPLETE, 'for_update')
    env2 = environment.Environment({'param1': 'foo', 'param2': 'new_bar'})
    env2.encrypted_param_names = ['param1']
    new_stack = stack.Stack(self.ctx, 'test_update', template.Template(tmpl, env=env2))
    self.assertIsNone(loaded_stack.update(new_stack))
    self.assertIn('Encountered already-decrypted data', warning_logger.output)