Added test for trigger parameter validation with default config
@@ -42,14 +42,18 @@ FIXTURES_PACK = 'generic'
@mock.patch.object(PoolPublisher, 'publish', mock.MagicMock())
class TestRuleController(FunctionalTest):
+ VALIDATE_TRIGGER_PAYLOAD = None
+
fixtures_loader = FixturesLoader()
@classmethod
def setUpClass(cls):
super(TestRuleController, cls).setUpClass()
- # reset default configuration value
- cfg.CONF.system.validate_trigger_parameters = False
+ # Previously, cfg.CONF.system.validate_trigger_payload was set to False explicitly
+ # here. Instead, we store original value so that the default is used, and if unit
+ # test modifies this, we can set it to what it was (preserve test atomicity)
+ cls.VALIDATE_TRIGGER_PAYLOAD = cfg.CONF.system.validate_trigger_parameters
models = TestRuleController.fixtures_loader.save_fixtures_to_db(
fixtures_pack=FIXTURES_PACK, fixtures_dict=TEST_FIXTURES)
@@ -110,6 +114,9 @@ class TestRuleController(FunctionalTest):
@classmethod
def tearDownClass(cls):
+ # Replace original configured value for trigger parameter validation
+ cfg.CONF.system.validate_trigger_payload = cls.VALIDATE_TRIGGER_PAYLOAD
+
TestRuleController.fixtures_loader.delete_fixtures_from_db(
fixtures_pack=FIXTURES_PACK, fixtures_dict=TEST_FIXTURES)
super(TestRuleController, cls).setUpClass()
@@ -227,6 +234,13 @@ class TestRuleController(FunctionalTest):
post_resp.json['faultstring'])
self.assertTrue('12345 is not of type u\'string\'' in post_resp.json['faultstring'])
+ def test_post_invalid_custom_trigger_param_trigger_param_validation_disabled_default_cfg(self):
+ """Test validation does NOT take place with the default configuration.
+ """
+
+ post_resp = self.__do_post(TestRuleController.RULE_9)
+ self.assertEqual(post_resp.status_int, http_client.CREATED)
+
def test_post_invalid_custom_trigger_parameter_trigger_param_validation_disabled(self):
# Invalid custom trigger parameter (invalid type) and non-system trigger parameter
# validation is disabled - trigger creation should succeed
