Beispiel #1
0
    def test_negative_validate_matcher_value_with_default_type(self):
        """Matcher is not created for value not of default type.

        @id: 84463d56-839f-4d5b-8646-cb6772fe5875

        @steps:

        1.  Create variable with valid default value.
        2.  Create matcher with value that doesn't match the default type.

        @assert: Matcher is not created for unmatched type.
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            'true',
            'variable-type':
            'boolean'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id':
                smart_variable['id'],
                'match':
                'is_virtual=true',
                'value':
                50,
            })
Beispiel #2
0
    def test_positive_create_matcher(self):
        """Create a Smart Variable with matcher.

        @id: 9ab8ae74-ee58-4738-8d8b-0e465eee8696

        @steps:

        1. Create a smart variable with valid name and default value.
        2. Create a matcher for Host with valid value.

        @assert:

        1. The smart Variable with matcher is created successfully.
        2. The variable is associated with host with match.
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet['name']})
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'is_virtual=true',
            'value':
            value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], value)
Beispiel #3
0
    def test_negative_validate_matcher_value_with_list(self):
        """Test matcher is not created for unmatched validator type list.

        @id: b6523714-8d6f-4b23-8ecf-6972a584bfee

        @steps:

        1.  Create smart variable with proper validator
        2.  Attempt to associate a matcher with value that doesn't match values
        from validator list

        @assert: Matcher is not created for unmatched validator rule.
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            '50',
            'validator-type':
            'list',
            'validator-rule':
            '25, example, 50',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id':
                smart_variable['id'],
                'match':
                'domain=test.com',
                'value':
                'myexample'
            })
Beispiel #4
0
    def test_negative_create_empty_matcher_value(self):
        """Create matcher with empty value for non string type.

        :id: 677a0881-c42a-4063-ac7b-7e7d9b5bc307

        :steps: Create a matcher for variable with type other than string and
            empty value

        :expectedresults: Matcher is not created with empty value

        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet_class['name'],
            'default-value':
            '20',
            'variable-type':
            'integer',
            'override-value-order':
            'is_virtual',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id':
                smart_variable['id'],
                'match':
                'is_virtual=true',
                'value':
                '',
            })
Beispiel #5
0
    def test_positive_validate_matcher_value_with_list(self):
        """Test matcher is created for matched validator type list.

        :id: 751e70ba-f1a4-4b73-878f-b2ab260a8a78

        :steps:

            1.  Create smart variable with proper validator
            2.  Create a matcher with value that matches the values from
                validator list

        :expectedresults: Matcher is created for matched validator rule.

        :CaseImportance: High
        """
        smart_variable = make_smart_variable(
            {
                'puppet-class': self.puppet_class['name'],
                'default-value': 'example',
                'validator-type': 'list',
                'validator-rule': 'test, example, 30',
            }
        )
        SmartVariable.add_override_value(
            {'smart-variable-id': smart_variable['id'], 'match': 'domain=test.com', 'value': '30'}
        )
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(smart_variable['validator']['type'], 'list')
        self.assertEqual(smart_variable['validator']['rule'], 'test, example, 30')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'], 'domain=test.com'
        )
        self.assertEqual(smart_variable['override-values']['values']['1']['value'], '30')
    def test_positive_create_matcher(self):
        """Create a Smart Variable with matcher.

        @id: 9ab8ae74-ee58-4738-8d8b-0e465eee8696

        @steps:

        1. Create a smart variable with valid name and default value.
        2. Create a matcher for Host with valid value.

        @assert:

        1. The smart Variable with matcher is created successfully.
        2. The variable is associated with host with match.
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'is_virtual=true',
            'value': value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true'
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], value)
Beispiel #7
0
    def test_positive_create_empty_matcher_value(self):
        """Create matcher with empty value for string type.

        @id: 00fe9a2b-a4c0-4f3e-9bc3-db22f8625005

        @steps: Create a matcher for variable with type string and empty value

        @assert: Matcher is created with empty value
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            gen_string('alpha'),
        })
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'is_virtual=true',
            'value':
            '',
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], '')
Beispiel #8
0
    def test_negative_validate_matcher_value_with_regex(self):
        """Test matcher is not created for unmatched validator type regex.

        @id: 6542a847-7627-4bc2-828f-33b06d30d4e4

        @steps:

        1.  Create a matcher with value that doesn't match the regex of step 2.
        2.  Validate this value with regex validator type and rule.

        @assert: Matcher is not created for unmatched validator rule.
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            gen_string('numeric'),
            'validator-type':
            'regexp',
            'validator-rule':
            '[0-9]',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id':
                smart_variable['id'],
                'match':
                'domain=test.com',
                'value':
                gen_string('alpha')
            })
    def test_positive_validate_matcher_value_with_default_type(self):
        """Matcher is created for default type value.

        @id: fc29aeb4-ead9-48ff-92de-3db659e8b0d1

        @steps:

        1.  Create variable default type with valid value.
        2.  Create a matcher with value that matches the default type.

        @assert: Matcher is created for matched type.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': 'true',
            'variable-type': 'boolean'
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'is_virtual=true',
            'value': 'false',
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true'
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], False)
Beispiel #10
0
    def test_negative_validate_matcher_value_with_list(self):
        """Test matcher is not created for unmatched validator type list.

        @id: b6523714-8d6f-4b23-8ecf-6972a584bfee

        @steps:

        1.  Create smart variable with proper validator
        2.  Attempt to associate a matcher with value that doesn't match values
        from validator list

        @assert: Matcher is not created for unmatched validator rule.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': '50',
            'validator-type': 'list',
            'validator-rule': '25, example, 50',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id': smart_variable['id'],
                'match': 'domain=test.com',
                'value': 'myexample'
            })
Beispiel #11
0
    def test_positive_validate_matcher_value_with_list(self):
        """Test matcher is created for matched validator type list.

        @id: 751e70ba-f1a4-4b73-878f-b2ab260a8a78

        @steps:

        1.  Create smart variable with proper validator
        2.  Create a matcher with value that matches the values from validator
        list

        @assert: Matcher is created for matched validator rule.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': 'example',
            'validator-type': 'list',
            'validator-rule': 'test, example, 30',
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'domain=test.com',
            'value': '30'
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(smart_variable['validator']['type'], 'list')
        self.assertEqual(
            smart_variable['validator']['rule'], 'test, example, 30')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'domain=test.com'
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], '30')
Beispiel #12
0
    def test_positive_validate_matcher_value_with_default_type(self):
        """Matcher is created for default type value.

        :id: fc29aeb4-ead9-48ff-92de-3db659e8b0d1

        :steps:

            1.  Create variable default type with valid value.
            2.  Create a matcher with value that matches the default type.

        :expectedresults: Matcher is created for matched type.

        :CaseImportance: High
        """
        smart_variable = make_smart_variable(
            {
                'puppet-class': self.puppet_class['name'],
                'default-value': 'true',
                'variable-type': 'boolean',
                'override-value-order': 'is_virtual',
            }
        )
        SmartVariable.add_override_value(
            {
                'smart-variable-id': smart_variable['id'],
                'match': 'is_virtual=true',
                'value': 'false',
            }
        )
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'], 'is_virtual=true'
        )
        self.assertEqual(smart_variable['override-values']['values']['1']['value'], False)
Beispiel #13
0
    def test_positive_validate_matcher_value_with_regex(self):
        """Test matcher is created for matched validator type regex.

        @id: 67e20b4b-cf39-4dbc-b553-80c5d54b7ad2

        @steps:

        1.  Create a matcher with value that matches the regex of step 2.
        2.  Validate this value with regex validator type and rule.

        @assert: Matcher is created for matched validator rule.
        """
        value = gen_string('numeric').lstrip('0')
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('numeric'),
            'validator-type': 'regexp',
            'validator-rule': '[0-9]',
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'domain=test.com',
            'value': value
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(smart_variable['validator']['type'], 'regexp')
        self.assertEqual(smart_variable['validator']['rule'], '[0-9]')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'domain=test.com'
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], value)
Beispiel #14
0
    def test_positive_validate_matcher_value_with_regex(self):
        """Test matcher is created for matched validator type regex.

        :id: 67e20b4b-cf39-4dbc-b553-80c5d54b7ad2

        :steps:

            1.  Create a matcher with value that matches the regex of step 2.
            2.  Validate this value with regex validator type and rule.

        :expectedresults: Matcher is created for matched validator rule.

        :CaseImportance: High
        """
        value = gen_string('numeric').lstrip('0')
        smart_variable = make_smart_variable(
            {
                'puppet-class': self.puppet_class['name'],
                'default-value': gen_string('numeric'),
                'validator-type': 'regexp',
                'validator-rule': '[0-9]',
            }
        )
        SmartVariable.add_override_value(
            {'smart-variable-id': smart_variable['id'], 'match': 'domain=test.com', 'value': value}
        )
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(smart_variable['validator']['type'], 'regexp')
        self.assertEqual(smart_variable['validator']['rule'], '[0-9]')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'], 'domain=test.com'
        )
        self.assertEqual(smart_variable['override-values']['values']['1']['value'], value)
Beispiel #15
0
    def test_negative_validate_matcher_non_existing_attribute(self):
        """Attempt to create Smart Variable with a matcher that has value for
        non existing attribute.

        :id: bde1edf6-12b8-457e-ac8f-a909666abfb5

        :expectedresults: Matcher is not created and error is raised

        :CaseImportance: High
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet_class['name'],
            'default-value':
            'true',
            'variable-type':
            'boolean',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id':
                smart_variable['id'],
                'match':
                'hostgroup={0}'.format(gen_string('alpha')),
                'value':
                'false',
            })
Beispiel #16
0
    def test_positive_create_empty_matcher_value(self):
        """Create matcher with empty value for string type.

        @id: 00fe9a2b-a4c0-4f3e-9bc3-db22f8625005

        @steps: Create a matcher for variable with type string and empty value

        @assert: Matcher is created with empty value
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('alpha'),
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'is_virtual=true',
            'value': '',
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true'
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], '')
Beispiel #17
0
    def test_negative_create_matcher_with_invalid_attribute(self):
        """Attempt to create Smart Variable with a matcher that has value for
        invalid attribute that is not in order priority list.

        :id: 35c0edab-31f5-4795-ba75-010ec355744c

        :expectedresults: Matcher is not created and error is raised

        :BZ: 1379277

        :CaseImportance: High
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet_class['name'],
            'default-value':
            'true',
            'variable-type':
            'boolean',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id':
                smart_variable['id'],
                'match':
                'something_is_here=true',
                'value':
                'false',
            })
Beispiel #18
0
    def test_positive_create_matcher_merge_override(self):
        """Merge the values of all the associated matchers.

        @id: 2f8e80ff-612f-461e-9498-90ebab2352c5

        @steps:

        1.  Create variable with some default value.
        2.  Create first matcher for attribute fqdn with valid details.
        3.  Create second matcher for other attribute with valid details.
        Note - The fqdn/host should have this attribute.
        4.  Create more matchers for some more attributes if any.
        Note - The fqdn/host should have this attributes.
        5.  Set --merge-overrides to true.
        6.  Go to YAML output of associated host.

        @assert:

        1.  The YAML output has the values merged from all the associated
        matchers.
        2.  The YAML output doesn't have the default value of variable.
        3.  Duplicate values in YAML output if any are displayed.

        @caseautomation: notautomated

        @CaseLevel: Integration
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            '[56]',
            'variable-type':
            'array'
        })
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'os=rhel6',
            'value':
            '[67, 66]',
        })
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'os=rhel7',
            'value':
            '[23, 44, 66]',
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'merge-overrides': 1,
            'merge-default': 1,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
Beispiel #19
0
    def test_positive_impact_delete_attribute(self):
        """Impact on variable after deleting associated attribute.

        :id: ac6f3a65-ed39-4e97-bdee-349f08bd878e

        :steps:

            1.  Create a variable with matcher for some attribute.
            2.  Delete the attribute.
            3.  Recreate the attribute with same name as earlier.

        :expectedresults:

            1.  The matcher for deleted attribute removed from variable.
            2.  On recreating attribute, the matcher should not reappear in
                variable.

        :CaseLevel: Integration
        """
        hostgroup_name = gen_string('alpha')
        matcher_value = gen_string('alpha')
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet_class['name']})
        hostgroup = make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'hostgroup={0}'.format(hostgroup_name),
            'value':
            matcher_value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'hostgroup={0}'.format(hostgroup_name))
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'],
            matcher_value,
        )
        HostGroup.delete({'id': hostgroup['id']})
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
        make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
Beispiel #20
0
    def test_positive_impact_delete_attribute(self):
        """Impact on variable after deleting associated attribute.

        @id: ac6f3a65-ed39-4e97-bdee-349f08bd878e

        @steps:

        1.  Create a variable with matcher for some attribute.
        2.  Delete the attribute.
        3.  Recreate the attribute with same name as earlier.

        @assert:

        1.  The matcher for deleted attribute removed from variable.
        2.  On recreating attribute, the matcher should not reappear in
        variable.

        @CaseLevel: Integration
        """
        hostgroup_name = gen_string('alpha')
        matcher_value = gen_string('alpha')
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet_class['name']})
        hostgroup = make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'hostgroup={0}'.format(hostgroup_name),
            'value': matcher_value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'hostgroup={0}'.format(hostgroup_name)
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'],
            matcher_value,
        )
        HostGroup.delete({'id': hostgroup['id']})
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
        make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
Beispiel #21
0
    def test_positive_add_and_remove_matcher(self):
        """Create a Smart Variable with matcher and remove that matcher
        afterwards.

        :id: 883e0f3b-6367-4fbb-a0b2-434fbeb10fcf

        :steps:

            1. Create a smart variable with valid name and default value.
            2. Create a matcher for that variable.
            3. Remove just assigned matcher.

        :expectedresults:

            1. The smart Variable is created successfully.
            2. The matcher is associated with variable.
            3. Matcher removed successfully

        :CaseImportance: Critical
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet_class['name'],
            'override-value-order':
            'is_virtual',
        })
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'is_virtual=true',
            'value':
            value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true')
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], value)
        SmartVariable.remove_override_value({
            'id':
            smart_variable['override-values']['values']['1']['id'],
            'smart-variable-id':
            smart_variable['id'],
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
Beispiel #22
0
    def test_positive_create_matcher_merge_override(self):
        """Merge the values of all the associated matchers.

        @id: 2f8e80ff-612f-461e-9498-90ebab2352c5

        @steps:

        1.  Create variable with some default value.
        2.  Create first matcher for attribute fqdn with valid details.
        3.  Create second matcher for other attribute with valid details.
        Note - The fqdn/host should have this attribute.
        4.  Create more matchers for some more attributes if any.
        Note - The fqdn/host should have this attributes.
        5.  Set --merge-overrides to true.
        6.  Go to YAML output of associated host.

        @assert:

        1.  The YAML output has the values merged from all the associated
        matchers.
        2.  The YAML output doesn't have the default value of variable.
        3.  Duplicate values in YAML output if any are displayed.

        @caseautomation: notautomated

        @CaseLevel: Integration
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': '[56]',
            'variable-type': 'array'
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'os=rhel6',
            'value': '[67, 66]',
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'os=rhel7',
            'value': '[23, 44, 66]',
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'merge-overrides': 1,
            'merge-default': 1,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
Beispiel #23
0
    def test_negative_create_with_invalid_match_value(self):
        """Attempt to create matcher with invalid match value.

        @id: 1026bc74-1bd0-40ab-81f1-d1371cc49d8f

        @steps: Create a matcher for variable with invalid match value

        @assert: Matcher is not created
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id': smart_variable['id'],
                'match': 'invalid_value',
                'value': gen_string('alpha'),
            })
Beispiel #24
0
    def test_negative_create_with_invalid_match_value(self):
        """Attempt to create matcher with invalid match value.

        :id: 1026bc74-1bd0-40ab-81f1-d1371cc49d8f

        :steps: Create a matcher for variable with invalid match value

        :expectedresults: Matcher is not created

        """
        smart_variable = make_smart_variable({'puppet-class': self.puppet_class['name']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value(
                {
                    'smart-variable-id': smart_variable['id'],
                    'match': 'invalid_value',
                    'value': gen_string('alpha'),
                }
            )
Beispiel #25
0
    def test_negative_create_empty_matcher_value(self):
        """Create matcher with empty value for non string type.

        @id: 677a0881-c42a-4063-ac7b-7e7d9b5bc307

        @steps: Create a matcher for variable with type other than string and
        empty value

        @assert: Matcher is not created with empty value
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': '20',
            'variable-type': 'integer'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id': smart_variable['id'],
                'match': 'is_virtual=true',
                'value': '',
            })
Beispiel #26
0
    def test_positive_remove_matcher(self):
        """Create a Smart Variable with matcher and remove that matcher
        afterwards.

        @id: 883e0f3b-6367-4fbb-a0b2-434fbeb10fcf

        @steps:

        1. Create a smart variable with valid name and default value.
        2. Create a matcher for that variable.
        3. Remove just assigned matcher.

        @assert:

        1. The smart Variable is created successfully.
        2. The matcher is associated with variable.
        3. Matcher removed successfully
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'is_virtual=true',
            'value': value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'is_virtual=true'
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'], value)
        SmartVariable.remove_override_value({
            'id': smart_variable['override-values']['values']['1']['id'],
            'smart-variable-id': smart_variable['id'],
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
Beispiel #27
0
    def test_negative_validate_matcher_value_with_default_type(self):
        """Matcher is not created for value not of default type.

        @id: 84463d56-839f-4d5b-8646-cb6772fe5875

        @steps:

        1.  Create variable with valid default value.
        2.  Create matcher with value that doesn't match the default type.

        @assert: Matcher is not created for unmatched type.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': 'true',
            'variable-type': 'boolean'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id': smart_variable['id'],
                'match': 'is_virtual=true',
                'value': 50,
            })
Beispiel #28
0
    def test_negative_validate_matcher_value_with_regex(self):
        """Test matcher is not created for unmatched validator type regex.

        @id: 6542a847-7627-4bc2-828f-33b06d30d4e4

        @steps:

        1.  Create a matcher with value that doesn't match the regex of step 2.
        2.  Validate this value with regex validator type and rule.

        @assert: Matcher is not created for unmatched validator rule.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('numeric'),
            'validator-type': 'regexp',
            'validator-rule': '[0-9]',
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.add_override_value({
                'smart-variable-id': smart_variable['id'],
                'match': 'domain=test.com',
                'value': gen_string('alpha')
            })