コード例 #1
0
    def test_negative_validate_matcher_value_with_default_type(self):
        """Error raised for matcher value not of default type.

        @id: 307b0ea1-a035-4ce1-bcc5-f582147359e7

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with valid value.
        3.  Create a matcher with value that doesn't matches the default type.
        4.  Submit the change.

        @assert: Error raised for matcher value not of default type.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update({
            'id': sc_param_id,
            'parameter-type': 'boolean',
            'override': 1,
            'default-value': u'true',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value({
                'smart-class-parameter-id': sc_param_id,
                'match': 'domain=test.com',
                'value': gen_string('alpha')
            })
コード例 #2
0
    def test_negative_validate_matcher_non_existing_attribute(self):
        """Error while creating matcher for Non Existing Attribute.

        :id: 5223e582-81b4-442d-b4ba-b16ede460ef6

        :steps:

            1.  Override the parameter.
            2.  Create a matcher with non existing attribute in org.
            3.  Attempt to submit the change.

        :expectedresults: Error raised for non existing attribute.

        :CaseImportance: Medium
        """
        sc_param_id = self.sc_params_ids_list.pop()
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value({
                'smart-class-parameter-id':
                sc_param_id,
                'match':
                'hostgroup=nonexistingHG',
                'value':
                gen_string('alpha'),
            })
コード例 #3
0
    def test_negative_validate_matcher_value_with_list(self):
        """Error raised for matcher value not in list.

        @id: 6e02c3f2-40aa-49ec-976d-7a12f5fa1e04

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that doesn't match
        the list of step 3.
        3.  Validate this value with list validator type and rule.
        4.  Submit the change.

        @assert: Error raised for matcher value not in list.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "domain=test.com", "value": "myexample"}
        )
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update(
                {
                    "id": sc_param_id,
                    "default-value": "50",
                    "override": 1,
                    "validator-type": "list",
                    "validator-rule": "25, example, 50",
                }
            )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertNotEqual(sc_param["default-value"], "50")
コード例 #4
0
    def test_positive_validate_matcher_value_with_list(self):
        """Error not raised for matcher value in list.

        @id: 16927050-0bf2-4cbd-bb34-43c669f81304

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that matches the list of step 3.
        3.  Validate this value with list validator type and rule.
        4.  Submit the change.

        @assert: Error not raised for matcher value in list.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "domain=test.com", "value": "30"}
        )
        SmartClassParameter.update(
            {
                "id": sc_param_id,
                "default-value": "example",
                "override": 1,
                "validator-type": "list",
                "validator-rule": "test, example, 30",
            }
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["default-value"], "example")
コード例 #5
0
    def test_positive_validate_matcher_value_with_regex(self):
        """Error not raised for matcher value matching with regex.

        @id: 2c8273aa-e621-4d4e-b03e-f8d50a596bc2

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that matches the regex of step 3.
        3.  Validate this value with regex validator type and rule.
        4.  Submit the change.

        @assert: Error not raised for matcher value matching with regex.
        """
        value = gen_string("numeric")
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "domain=test.com", "value": gen_string("numeric")}
        )
        SmartClassParameter.update(
            {
                "id": sc_param_id,
                "default-value": value,
                "override": 1,
                "validator-type": "regexp",
                "validator-rule": "[0-9]",
            }
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["default-value"], value)
コード例 #6
0
    def test_positive_validate_matcher_value_with_list(self):
        """Error not raised for matcher value in list.

        @id: 16927050-0bf2-4cbd-bb34-43c669f81304

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that matches the list of step 3.
        3.  Validate this value with list validator type and rule.
        4.  Submit the change.

        @assert: Error not raised for matcher value in list.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': '30'
        })
        SmartClassParameter.update({
            'id': sc_param_id,
            'default-value': 'example',
            'override': 1,
            'validator-type': 'list',
            'validator-rule': 'test, example, 30',
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['default-value'], 'example')
コード例 #7
0
    def test_negative_validate_matcher_and_default_value(self):
        """Error for invalid default and matcher value both at a time.

        @id: 07dfcdad-e619-4672-9fe8-75a8352e44a4

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with Invalid value.
        3.  Create a matcher with value that doesn't matches the default type.
        4.  Attempt to submit the change.

        @assert: Error raised for invalid default and matcher value both.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': gen_string('alpha'),
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update({
                'id': sc_param_id,
                'parameter-type': 'boolean',
                'override': 1,
                'default-value': gen_string('alpha'),
            })
コード例 #8
0
    def test_positive_create_matcher(self):
        """Create matcher for attribute in parameter.

        @id: 37fe299b-1e81-4faf-b1c3-2edfc3d53dc1

        @steps:

        1.  Override the parameter.
        2.  Set some default Value.
        3.  Create a matcher with all valid values.
        4.  Submit the change.

        @assert: The matcher has been created successfully.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string('alpha')
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'is_virtual=true',
            'value': value
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['override-values']['values']['1']['match'],
                         'is_virtual=true')
        self.assertEqual(sc_param['override-values']['values']['1']['value'],
                         value)
コード例 #9
0
    def test_negative_validate_matcher_value_with_default_type(self):
        """Error raised for matcher value not of default type.

        @id: 307b0ea1-a035-4ce1-bcc5-f582147359e7

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with valid value.
        3.  Create a matcher with value that doesn't matches the default type.
        4.  Submit the change.

        @assert: Error raised for matcher value not of default type.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update({
            'id': sc_param_id,
            'parameter-type': 'boolean',
            'override': 1,
            'default-value': u'true',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value({
                'smart-class-parameter-id': sc_param_id,
                'match': 'domain=test.com',
                'value': gen_string('alpha')
            })
コード例 #10
0
    def test_positive_create_matcher_puppet_default_value(self):
        """Create matcher for attribute in parameter,
        Where Value is puppet default value.

        @id: c08fcf25-e5c7-411e-beed-3741a24496fd

        @steps:

        1.  Override the parameter.
        2.  Set some default Value.
        3.  Create matcher with valid attribute type, name and
        puppet default value.
        4.  Submit the change.

        @assert: The matcher has been created successfully.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string("alpha")
        SmartClassParameter.update({"id": sc_param_id, "override": 1, "default-value": gen_string("alpha")})
        SmartClassParameter.add_override_value(
            {
                "smart-class-parameter-id": sc_param_id,
                "match": "domain=test.com",
                "value": value,
                "use-puppet-default": 1,
            }
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["override-values"]["values"]["1"]["match"], "domain=test.com")
        self.assertEqual(sc_param["override-values"]["values"]["1"]["value"], value)
コード例 #11
0
    def test_positive_validate_matcher_value_with_default_type(self):
        """No error for matcher value of default type.

        @id: a247adac-4631-4b90-ae4a-a768cd05be34

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with valid value.
        3.  Create a matcher with value that matches the default type.
        4.  Submit the change.

        @assert: Error not raised for matcher value of default type.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update({
            'id': sc_param_id,
            'parameter-type': 'boolean',
            'override': 1,
            'default-value': u'true',
        })
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': u'false'
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['override-values']['values']['1']['match'],
                         'domain=test.com')
        self.assertEqual(sc_param['override-values']['values']['1']['value'],
                         False)
コード例 #12
0
    def test_negative_validate_matcher_value_with_list(self):
        """Error raised for matcher value not in list.

        @id: 6e02c3f2-40aa-49ec-976d-7a12f5fa1e04

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that doesn't match
        the list of step 3.
        3.  Validate this value with list validator type and rule.
        4.  Submit the change.

        @assert: Error raised for matcher value not in list.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': 'myexample'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update({
                'id': sc_param_id,
                'default-value': '50',
                'override': 1,
                'validator-type': 'list',
                'validator-rule': '25, example, 50',
            })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertNotEqual(sc_param['default-value'], '50')
コード例 #13
0
    def test_positive_validate_matcher_value_with_regex(self):
        """Error not raised for matcher value matching with regex.

        @id: 2c8273aa-e621-4d4e-b03e-f8d50a596bc2

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that matches the regex of step 3.
        3.  Validate this value with regex validator type and rule.
        4.  Submit the change.

        @assert: Error not raised for matcher value matching with regex.
        """
        value = gen_string('numeric')
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': gen_string('numeric')
        })
        SmartClassParameter.update({
            'id': sc_param_id,
            'default-value': value,
            'override': 1,
            'validator-type': 'regexp',
            'validator-rule': '[0-9]',
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['default-value'], value)
コード例 #14
0
    def test_negative_validate_matcher_value_with_regex(self):
        """Error raised for matcher value not matching with regex.

        @id: b8b2f1c2-a20c-42d6-a687-79e6eee0268e

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that doesn't match
        the regex of step 3.
        3.  Validate this value with regex validator type and rule.
        4.  Submit the change.

        @assert: Error raised for matcher value not matching with regex.
        """
        value = gen_string('numeric')
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': gen_string('alpha')
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update({
                'id': sc_param_id,
                'default-value': value,
                'override': 1,
                'validator-type': 'regexp',
                'validator-rule': '[0-9]',
            })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertNotEqual(sc_param['default-value'], value)
コード例 #15
0
    def test_negative_validate_matcher_value_with_list(self):
        """Error raised for matcher value not in list.

        @id: 6e02c3f2-40aa-49ec-976d-7a12f5fa1e04

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that doesn't match
        the list of step 3.
        3.  Validate this value with list validator type and rule.
        4.  Submit the change.

        @assert: Error raised for matcher value not in list.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': 'myexample'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update({
                'id': sc_param_id,
                'default-value': '50',
                'override': 1,
                'validator-type': 'list',
                'validator-rule': '25, example, 50',
            })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertNotEqual(sc_param['default-value'], '50')
コード例 #16
0
    def test_positive_validate_matcher_value_required_check(self):
        """Error not raised for matcher Value - Required check.

        @id: e62c3c5a-d900-44d4-9793-2c17202974e5

        @steps:

        1.  Override the parameter.
        2.  Create a matcher for Parameter for some attribute.
        3.  Provide some Value for matcher.
        4.  Set '--required' check.
        5.  Submit the change.

        @assert: Error not raised for matcher value.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=example.com',
            'value': gen_string('alpha')
        })
        SmartClassParameter.update({
            'id': sc_param_id,
            'override': 1,
            'required': 1
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['required'], True)
コード例 #17
0
    def test_negative_validate_matcher_and_default_value(self):
        """Error for invalid default and matcher value both at a time.

        @id: 07dfcdad-e619-4672-9fe8-75a8352e44a4

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with Invalid value.
        3.  Create a matcher with value that doesn't matches the default type.
        4.  Attempt to submit the change.

        @assert: Error raised for invalid default and matcher value both.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': gen_string('alpha'),
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update({
                'id': sc_param_id,
                'parameter-type': 'boolean',
                'override': 1,
                'default-value': gen_string('alpha'),
            })
コード例 #18
0
    def test_negative_validate_matcher_value_with_regex(self):
        """Error raised for matcher value not matching with regex.

        @id: b8b2f1c2-a20c-42d6-a687-79e6eee0268e

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that doesn't match
        the regex of step 3.
        3.  Validate this value with regex validator type and rule.
        4.  Submit the change.

        @assert: Error raised for matcher value not matching with regex.
        """
        value = gen_string("numeric")
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "domain=test.com", "value": gen_string("alpha")}
        )
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update(
                {
                    "id": sc_param_id,
                    "default-value": value,
                    "override": 1,
                    "validator-type": "regexp",
                    "validator-rule": "[0-9]",
                }
            )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertNotEqual(sc_param["default-value"], value)
コード例 #19
0
    def test_negative_validate_matcher_value_with_regex(self):
        """Error raised for matcher value not matching with regex.

        @id: b8b2f1c2-a20c-42d6-a687-79e6eee0268e

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that doesn't match
        the regex of step 3.
        3.  Validate this value with regex validator type and rule.
        4.  Submit the change.

        @assert: Error raised for matcher value not matching with regex.
        """
        value = gen_string('numeric')
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': gen_string('alpha')
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.update({
                'id': sc_param_id,
                'default-value': value,
                'override': 1,
                'validator-type': 'regexp',
                'validator-rule': '[0-9]',
            })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertNotEqual(sc_param['default-value'], value)
コード例 #20
0
    def test_positive_validate_matcher_value_with_regex(self):
        """Error not raised for matcher value matching with regex.

        @id: 2c8273aa-e621-4d4e-b03e-f8d50a596bc2

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that matches the regex of step 3.
        3.  Validate this value with regex validator type and rule.
        4.  Submit the change.

        @assert: Error not raised for matcher value matching with regex.
        """
        value = gen_string('numeric')
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': gen_string('numeric')
        })
        SmartClassParameter.update({
            'id': sc_param_id,
            'default-value': value,
            'override': 1,
            'validator-type': 'regexp',
            'validator-rule': '[0-9]',
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['default-value'], value)
コード例 #21
0
    def test_positive_remove_matcher(self):
        """Removal of matcher from parameter.

        @id: f51ea9ca-f57c-482e-841f-3ea5cc8f8958

        @steps:

        1. Override the parameter and create a matcher for some attribute.
        2. Remove the matcher created in step 1.

        @assert: The matcher removed from parameter.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string('alpha')
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'is_virtual=true',
            'value': value
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(len(sc_param['override-values']['values']), 1)
        SmartClassParameter.remove_override_value({
            'smart-class-parameter-id':
            sc_param_id,
            'id':
            sc_param['override-values']['values']['1']['id'],
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(len(sc_param['override-values']['values']), 0)
コード例 #22
0
    def test_positive_validate_matcher_value_required_check(self):
        """Error not raised for matcher Value - Required check.

        @id: e62c3c5a-d900-44d4-9793-2c17202974e5

        @steps:

        1.  Override the parameter.
        2.  Create a matcher for Parameter for some attribute.
        3.  Provide some Value for matcher.
        4.  Set '--required' check.
        5.  Submit the change.

        @assert: Error not raised for matcher value.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=example.com',
            'value': gen_string('alpha')
        })
        SmartClassParameter.update({
            'id': sc_param_id,
            'override': 1,
            'required': 1
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['required'], True)
コード例 #23
0
    def test_positive_create_matcher(self):
        """Create matcher for attribute in parameter.

        @id: 37fe299b-1e81-4faf-b1c3-2edfc3d53dc1

        @steps:

        1.  Override the parameter.
        2.  Set some default Value.
        3.  Create a matcher with all valid values.
        4.  Submit the change.

        @assert: The matcher has been created successfully.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string('alpha')
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'is_virtual=true',
            'value': value
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(
            sc_param['override-values']['values']['1']['match'],
            'is_virtual=true'
        )
        self.assertEqual(
            sc_param['override-values']['values']['1']['value'], value)
コード例 #24
0
    def test_positive_create_matcher_puppet_default_value(self):
        """Create matcher for attribute in parameter,
        Where Value is puppet default value.

        @id: c08fcf25-e5c7-411e-beed-3741a24496fd

        @steps:

        1.  Override the parameter.
        2.  Set some default Value.
        3.  Create matcher with valid attribute type, name and
        puppet default value.
        4.  Submit the change.

        @assert: The matcher has been created successfully.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update({
            'id': sc_param_id,
            'override': 1,
            'default-value': gen_string('alpha'),
        })
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'use-puppet-default': 1
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(
            sc_param['override-values']['values']['1']['match'],
            'domain=test.com'
        )
コード例 #25
0
    def test_positive_remove_matcher(self):
        """Removal of matcher from parameter.

        @id: f51ea9ca-f57c-482e-841f-3ea5cc8f8958

        @steps:

        1. Override the parameter and create a matcher for some attribute.
        2. Remove the matcher created in step 1.

        @assert: The matcher removed from parameter.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string('alpha')
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'is_virtual=true',
            'value': value
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(len(sc_param['override-values']['values']), 1)
        SmartClassParameter.remove_override_value({
            'smart-class-parameter-id': sc_param_id,
            'id': sc_param['override-values']['values']['1']['id'],
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(len(sc_param['override-values']['values']), 0)
コード例 #26
0
    def test_positive_validate_matcher_value_with_list(self):
        """Error not raised for matcher value in list.

        @id: 16927050-0bf2-4cbd-bb34-43c669f81304

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with value that matches the list of step 3.
        3.  Validate this value with list validator type and rule.
        4.  Submit the change.

        @assert: Error not raised for matcher value in list.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': '30'
        })
        SmartClassParameter.update({
            'id': sc_param_id,
            'default-value': 'example',
            'override': 1,
            'validator-type': 'list',
            'validator-rule': 'test, example, 30',
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['default-value'], 'example')
コード例 #27
0
    def test_positive_create_and_remove_matcher(self):
        """Create and remove matcher for attribute in parameter.

        :id: 37fe299b-1e81-4faf-b1c3-2edfc3d53dc1

        :steps:

            1.  Override the parameter.
            2.  Set some default Value.
            3.  Create a matcher with all valid values.
            4.  Create matcher with valid attribute type, name and puppet
                default value.
            5.  Submit the change.
            6.  Remove the matcher created in step 1

        :expectedresults: The matcher has been created successfully.

        :CaseImportance: Medium
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string('alpha')
        SmartClassParameter.update({
            'id': sc_param_id,
            'override': 1,
            'override-value-order': 'is_virtual',
        })
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'is_virtual=true',
            'value': value,
        })
        sc_param = SmartClassParameter.info({
            'puppet-class':
            self.puppet_class['name'],
            'id':
            sc_param_id,
        })
        self.assertEqual(sc_param['override-values']['values']['1']['match'],
                         'is_virtual=true')
        self.assertEqual(sc_param['override-values']['values']['1']['value'],
                         value)

        SmartClassParameter.remove_override_value({
            'smart-class-parameter-id':
            sc_param_id,
            'id':
            sc_param['override-values']['values']['1']['id'],
        })
        sc_param = SmartClassParameter.info({
            'puppet-class':
            self.puppet_class['name'],
            'id':
            sc_param_id,
        })
        self.assertEqual(len(sc_param['override-values']['values']), 0)
コード例 #28
0
    def test_negative_create_matcher(self):
        """Error while creating matcher with empty value

        @id: d4d9f730-152c-428d-b48c-294a23b183ea

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with empty value.
        4.  Attempt to submit the change.

        @assert: Error is raised for attempt to add matcher with empty value
        """
        sc_param_id = self.sc_params_ids_list.pop()
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value(
                {"smart-class-parameter-id": sc_param_id, "match": "is_virtual=true", "value": ""}
            )
コード例 #29
0
    def test_negative_validate_matcher_non_existing_attribute(self):
        """Error while creating matcher for Non Existing Attribute.

        @id: 5223e582-81b4-442d-b4ba-b16ede460ef6

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with non existing attribute in org.
        4.  Attempt to submit the change.

        @assert: Error raised for non existing attribute.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value({
                'smart-class-parameter-id': sc_param_id,
                'match': 'hostgroup=nonexistingHG',
                'value': gen_string('alpha')
            })
コード例 #30
0
    def test_negative_validate_matcher_non_existing_attribute(self):
        """Error while creating matcher for Non Existing Attribute.

        @id: 5223e582-81b4-442d-b4ba-b16ede460ef6

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with non existing attribute in org.
        4.  Attempt to submit the change.

        @assert: Error raised for non existing attribute.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value({
                'smart-class-parameter-id': sc_param_id,
                'match': 'non_existing_attribute',
                'value': gen_string('alpha')
            })
コード例 #31
0
    def test_negative_create_matcher(self):
        """Error while creating matcher with empty value

        @id: d4d9f730-152c-428d-b48c-294a23b183ea

        @steps:

        1.  Override the parameter.
        2.  Create a matcher with empty value.
        4.  Attempt to submit the change.

        @assert: Error is raised for attempt to add matcher with empty value
        """
        sc_param_id = self.sc_params_ids_list.pop()
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value({
                'smart-class-parameter-id': sc_param_id,
                'match': 'is_virtual=true',
                'value': '',
            })
コード例 #32
0
    def test_positive_create_matcher(self):
        """Create matcher for attribute in parameter.

        @id: 37fe299b-1e81-4faf-b1c3-2edfc3d53dc1

        @steps:

        1.  Override the parameter.
        2.  Set some default Value.
        3.  Create a matcher with all valid values.
        4.  Submit the change.

        @assert: The matcher has been created successfully.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string("alpha")
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "is_virtual=true", "value": value}
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["override-values"]["values"]["1"]["match"], "is_virtual=true")
        self.assertEqual(sc_param["override-values"]["values"]["1"]["value"], value)
コード例 #33
0
    def test_positive_validate_matcher_value_required_check(self):
        """Error not raised for matcher Value - Required check.

        @id: e62c3c5a-d900-44d4-9793-2c17202974e5

        @steps:

        1.  Override the parameter.
        2.  Create a matcher for Parameter for some attribute.
        3.  Provide some Value for matcher.
        4.  Set '--required' check.
        5.  Submit the change.

        @assert: Error not raised for matcher value.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "domain=example.com", "value": gen_string("alpha")}
        )
        SmartClassParameter.update({"id": sc_param_id, "override": 1, "required": 1})
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["required"], True)
コード例 #34
0
    def test_negative_validate_matcher_value_with_default_type(self):
        """Error raised for matcher value not of default type.

        @id: 307b0ea1-a035-4ce1-bcc5-f582147359e7

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with valid value.
        3.  Create a matcher with value that doesn't matches the default type.
        4.  Submit the change.

        @assert: Error raised for matcher value not of default type.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update(
            {"id": sc_param_id, "parameter-type": "boolean", "override": 1, "default-value": u"true"}
        )
        with self.assertRaises(CLIReturnCodeError):
            SmartClassParameter.add_override_value(
                {"smart-class-parameter-id": sc_param_id, "match": "domain=test.com", "value": gen_string("alpha")}
            )
コード例 #35
0
    def test_positive_create_matcher_puppet_default_value(self):
        """Create matcher for attribute in parameter,
        Where Value is puppet default value.

        @id: c08fcf25-e5c7-411e-beed-3741a24496fd

        @steps:

        1.  Override the parameter.
        2.  Set some default Value.
        3.  Create matcher with valid attribute type, name and
        puppet default value.
        4.  Submit the change.

        @assert: The matcher has been created successfully.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string('alpha')
        SmartClassParameter.update({
            'id': sc_param_id,
            'override': 1,
            'default-value': gen_string('alpha'),
        })
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': value,
            'use-puppet-default': 1
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': 'ntp',
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['override-values']['values']['1']['match'],
                         'domain=test.com')
        self.assertEqual(sc_param['override-values']['values']['1']['value'],
                         value)
コード例 #36
0
    def test_positive_validate_matcher_value_with_default_type(self):
        """No error for matcher value of default type.

        @id: a247adac-4631-4b90-ae4a-a768cd05be34

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with valid value.
        3.  Create a matcher with value that matches the default type.
        4.  Submit the change.

        @assert: Error not raised for matcher value of default type.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update(
            {"id": sc_param_id, "parameter-type": "boolean", "override": 1, "default-value": u"true"}
        )
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "domain=test.com", "value": u"false"}
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["override-values"]["values"]["1"]["match"], "domain=test.com")
        self.assertEqual(sc_param["override-values"]["values"]["1"]["value"], False)
コード例 #37
0
    def test_positive_validate_matcher_value_with_default_type(self):
        """No error for matcher value of default type.

        @id: a247adac-4631-4b90-ae4a-a768cd05be34

        @steps:

        1.  Override the parameter.
        2.  Update parameter default type with valid value.
        3.  Create a matcher with value that matches the default type.
        4.  Submit the change.

        @assert: Error not raised for matcher value of default type.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update({
            'id': sc_param_id,
            'parameter-type': 'boolean',
            'override': 1,
            'default-value': u'true',
        })
        SmartClassParameter.add_override_value({
            'smart-class-parameter-id': sc_param_id,
            'match': 'domain=test.com',
            'value': u'false'
        })
        sc_param = SmartClassParameter.info({
            'puppet-class': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(
            sc_param['override-values']['values']['1']['match'],
            'domain=test.com'
        )
        self.assertEqual(
            sc_param['override-values']['values']['1']['value'], False)
コード例 #38
0
    def test_positive_remove_matcher(self):
        """Removal of matcher from parameter.

        @id: f51ea9ca-f57c-482e-841f-3ea5cc8f8958

        @steps:

        1. Override the parameter and create a matcher for some attribute.
        2. Remove the matcher created in step 1.

        @assert: The matcher removed from parameter.
        """
        sc_param_id = self.sc_params_ids_list.pop()
        value = gen_string("alpha")
        SmartClassParameter.add_override_value(
            {"smart-class-parameter-id": sc_param_id, "match": "is_virtual=true", "value": value}
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(len(sc_param["override-values"]["values"]), 1)
        SmartClassParameter.remove_override_value(
            {"smart-class-parameter-id": sc_param_id, "id": sc_param["override-values"]["values"]["1"]["id"]}
        )
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(len(sc_param["override-values"]["values"]), 0)