Example #1
0
    def test_positive_update_hidden_value(self):
        """Update the hidden default value of variable.

        @id: 944d3fb9-ce90-47d8-bc54-fdf505bd5317

        @steps:

        1. Create a variable with some valid default value.
        2. Set '--hidden-value' to true.
        3. Again update the default value.

        @assert:

        1. The variable default value is updated.
        2. The variable '--hidden-value' is set true.
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            gen_string('alpha'),
            'hidden-value':
            1,
        })
        self.assertEqual(smart_variable['hidden-value?'], True)
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'default-value': value,
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['default-value'], value)
Example #2
0
    def test_positive_unhide_default_value(self):
        """Test unhiding of the default value of variable.

        @id: e1928ebf-32dd-4fb6-a40b-4c84507c1e2f

        @steps:

        1. Create a variable with some default value.
        2. Set '--hidden-value' to true.
        3. After hiding, set '--hidden-value' to false.

        @assert: The hidden value is set to false.
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            gen_string('alpha'),
            'hidden-value':
            1,
        })
        self.assertEqual(smart_variable['hidden-value?'], True)
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'hidden-value': 0
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['hidden-value?'], False)
Example #3
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'], '')
Example #4
0
    def test_negative_enable_merge_overrides_default_flags(self):
        """Attempt to enable Merge Overrides, Merge Default flags for non
        supported types.

        @id: 306400df-e823-48d6-b541-ef3b20181c78

        @steps:

        1.  Create smart variable with type that is not array/hash.
        2.  Attempt to update smart variable and set corresponding flags to
        True state.

        @assert: The Merge Overrides, Merge Default flags are not allowed
        to set to True.
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            gen_string('numeric'),
            'variable-type':
            'integer'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.update({
                'variable': smart_variable['variable'],
                'merge-overrides': 1,
                'merge-default': 1,
            })
Example #5
0
    def test_positive_enable_avoid_duplicates_flag(self):
        """Enable Avoid duplicates flag for supported array type.

        @id: 0c7063e0-8e85-44b7-abae-4def7f68833a

        @steps:

        1. Create smart variable with array/hash type.
        2. Set '--merge-overrides' to true.

        @assert: The '--avoid-duplicates' flag is allowed to set true.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': '[test]',
            'variable-type': 'array'
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'merge-overrides': 1,
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'avoid-duplicates': 1,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['avoid-duplicates'], True)
Example #6
0
    def test_positive_enable_merge_overrides_default_flags(self):
        """Enable Merge Overrides, Merge Default flags for supported types.

        @id: c000f408-c293-4915-9432-6b597a2e6ad0

        @steps:

        1.  Create smart variable with array/hash type.
        2.  Update smart variable and set corresponding flags to True state.

        @assert: The Merge Overrides, Merge Default flags are allowed to set
        True.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': '[56]',
            'variable-type': 'array'
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'merge-overrides': 1,
            'merge-default': 1,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['merge-overrides'], True)
        self.assertEqual(
            smart_variable['override-values']['merge-default-value'], True)
Example #7
0
    def test_negative_enable_merge_overrides_default_flags(self):
        """Attempt to enable Merge Overrides, Merge Default flags for non
        supported types.

        @id: 306400df-e823-48d6-b541-ef3b20181c78

        @steps:

        1.  Create smart variable with type that is not array/hash.
        2.  Attempt to update smart variable and set corresponding flags to
        True state.

        @assert: The Merge Overrides, Merge Default flags are not allowed
        to set to True.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('numeric'),
            'variable-type': 'integer'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.update({
                'variable': smart_variable['variable'],
                'merge-overrides': 1,
                'merge-default': 1,
            })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['merge-overrides'], False)
        self.assertEqual(
            smart_variable['override-values']['merge-default-value'], False)
Example #8
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)
Example #9
0
    def test_positive_enable_avoid_duplicates_flag(self):
        """Enable Avoid duplicates flag for supported array type.

        :id: 0c7063e0-8e85-44b7-abae-4def7f68833a

        :steps:

            1. Create smart variable with array/hash type.
            2. Set '--merge-overrides' to true.

        :expectedresults: The '--avoid-duplicates' flag is allowed to set true.

        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet_class['name'],
            'default-value':
            '[test]',
            'variable-type':
            'array'
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'merge-overrides': 1,
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'avoid-duplicates': 1,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(smart_variable['override-values']['avoid-duplicates'],
                         True)
Example #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['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'
            })
Example #11
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,
            })
Example #12
0
    def test_negative_validate_default_value_with_regex(self):
        """Test variable is not created for unmatched validator type regex.

        @id: f728ea2c-f7f4-4d9b-8c92-9681e0b21769

        @steps:

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

        @assert: Variable is not created for unmatched validator rule.
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            value
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.update({
                'id': smart_variable['id'],
                'default-value': gen_string('alpha'),
                'validator-type': 'regexp',
                'validator-rule': '[0-9]',
            })
        sc_param = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(sc_param['default-value'], value)
Example #13
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')
            })
Example #14
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'], '')
Example #15
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_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)
Example #16
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)
Example #17
0
    def test_negative_enable_avoid_duplicates_flag(self):
        """Attempt to enable Avoid duplicates flag for non supported types.

        @id: ea1e8e31-4374-4172-82fd-538d29d70c03

        @steps:

        1.  Create smart variable with type that is not array/hash.
        2.  Attempt to update smart variable and set corresponding flags to
        True state.

        @assert:

        1.  The '--merge-overrides' is only allowed to set to true for type
        hash.
        2.  The '--avoid-duplicates' is not allowed to set to true for type
        other than array.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('numeric'),
            'variable-type': 'integer'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.update({
                'variable': smart_variable['variable'],
                'merge-overrides': 1,
                'avoid-duplicates': 1,
            })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['merge-overrides'], False)
        self.assertEqual(
            smart_variable['override-values']['avoid-duplicates'], False)
Example #18
0
    def test_positive_unhide_default_value(self):
        """Test unhiding of the default value of variable.

        @id: e1928ebf-32dd-4fb6-a40b-4c84507c1e2f

        @steps:

        1. Create a variable with some default value.
        2. Set '--hidden-value' to true.
        3. After hiding, set '--hidden-value' to false.

        @assert: The hidden value is set to false.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('alpha'),
            'hidden-value': 1,
        })
        self.assertEqual(smart_variable['hidden-value?'], True)
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'hidden-value': 0
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['hidden-value?'], False)
Example #19
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)
Example #20
0
    def test_positive_validate_default_value_with_regex(self):
        """Test variable is created for matched validator type regex.

        @id: f720c888-0ed0-4d32-bf72-8f5db5c1b5ed

        @steps:

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

        @assert: Variable 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('alpha')
        })
        SmartVariable.update({
            'id': smart_variable['id'],
            'default-value': value,
            'validator-type': 'regexp',
            'validator-rule': '[0-9]',
        })
        updated_sv = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(updated_sv['default-value'], value)
        self.assertEqual(updated_sv['validator']['type'], 'regexp')
        self.assertEqual(updated_sv['validator']['rule'], '[0-9]')
Example #21
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'
            })
Example #22
0
    def test_negative_validate_default_value_with_regex(self):
        """Test variable is not created for unmatched validator type regex.

        @id: f728ea2c-f7f4-4d9b-8c92-9681e0b21769

        @steps:

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

        @assert: Variable is not created for unmatched validator rule.
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': value
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.update({
                'id': smart_variable['id'],
                'default-value': gen_string('alpha'),
                'validator-type': 'regexp',
                'validator-rule': '[0-9]',
            })
        sc_param = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(sc_param['default-value'], value)
Example #23
0
    def test_negative_enable_avoid_duplicates_flag(self):
        """Attempt to enable Avoid duplicates flag for non supported types.

        @id: ea1e8e31-4374-4172-82fd-538d29d70c03

        @steps:

        1.  Create smart variable with type that is not array/hash.
        2.  Attempt to update smart variable and set corresponding flags to
        True state.

        @assert:

        1.  The '--merge-overrides' is only allowed to set to true for type
        hash.
        2.  The '--avoid-duplicates' is not allowed to set to true for type
        other than array.
        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet['name'],
            'default-value':
            gen_string('numeric'),
            'variable-type':
            'integer'
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.update({
                'variable': smart_variable['variable'],
                'merge-overrides': 1,
                'avoid-duplicates': 1,
            })
Example #24
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':
                '',
            })
Example #25
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)
Example #26
0
    def test_positive_validate_default_value_with_regex(self):
        """Test variable is created for matched validator type regex.

        :id: f720c888-0ed0-4d32-bf72-8f5db5c1b5ed

        :steps:

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

        :expectedresults: Variable 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('alpha')
        })
        SmartVariable.update({
            'id': smart_variable['id'],
            'default-value': value,
            'validator-type': 'regexp',
            'validator-rule': '[0-9]',
        })
        updated_sv = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(updated_sv['default-value'], value)
        self.assertEqual(updated_sv['validator']['type'], 'regexp')
        self.assertEqual(updated_sv['validator']['rule'], '[0-9]')
Example #27
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')
Example #28
0
    def test_positive_update_variable_puppet_class(self):
        """Update Smart Variable's puppet class.

        @id: 0f2d617b-c9ec-46e9-ac84-7a0d59a84811

        @steps:

        1. Create a smart variable with valid name.
        2. Update the puppet class associated to the smart variable created in
        step1.

        @assert: The variable is updated with new puppet class.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        self.assertEqual(
            smart_variable['puppet-class'], self.puppet_class['name'])
        new_puppet = Puppet.info(
            {u'name': choice(self.puppet_subclasses)['name']})
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'puppet-class': new_puppet['name']
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['puppet-class'], new_puppet['name'])
Example #29
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.

        @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)
Example #30
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')
Example #31
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',
            })
Example #32
0
    def test_positive_enable_merge_overrides_default_flags(self):
        """Enable Merge Overrides, Merge Default flags for supported types.

        :id: c000f408-c293-4915-9432-6b597a2e6ad0

        :steps:

            1.  Create smart variable with array/hash type.
            2.  Update smart variable and set corresponding flags to True
                state.

        :expectedresults: The Merge Overrides, Merge Default flags are allowed
            to set True.

        """
        smart_variable = make_smart_variable({
            'puppet-class':
            self.puppet_class['name'],
            'default-value':
            '[56]',
            'variable-type':
            'array'
        })
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'merge-overrides': 1,
            'merge-default': 1,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(smart_variable['override-values']['merge-overrides'],
                         True)
        self.assertEqual(
            smart_variable['override-values']['merge-default-value'], True)
Example #33
0
    def test_positive_update_hidden_value(self):
        """Update the hidden default value of variable.

        @id: 944d3fb9-ce90-47d8-bc54-fdf505bd5317

        @steps:

        1. Create a variable with some valid default value.
        2. Set '--hidden-value' to true.
        3. Again update the default value.

        @assert:

        1. The variable default value is updated.
        2. The variable '--hidden-value' is set true.
        """
        value = gen_string('alpha')
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name'],
            'default-value': gen_string('alpha'),
            'hidden-value': 1,
        })
        self.assertEqual(smart_variable['hidden-value?'], True)
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'default-value': value,
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['default-value'], value)
Example #34
0
    def test_negative_duplicate_name_variable(self):
        """Create Smart Variable with an existing name.

        :id: cc219111-1d2a-47ae-9b22-0b399f2d586d

        :steps:

            1. Create a smart Variable with Valid name and default value.
            2. Attempt to create a variable with same name from same/other
               class.

        :expectedresults: The variable with same name are not allowed to create
            from any class.

        :CaseImportance: Critical
        """
        name = gen_string('alpha')
        make_smart_variable({
            'variable': name,
            'puppet-class': self.puppet_class['name']
        })
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.create({
                'variable': name,
                'puppet-class': self.puppet_class['name']
            })
Example #35
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',
            })
Example #36
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)
Example #37
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)
Example #38
0
    def test_negative_create(self):
        """Create Smart Variable with invalid name.

        :id: 3f71f39f-4178-42e7-be40-2a3538361466

        :steps: Create a smart Variable with Invalid name.

        :expectedresults: The smart Variable is not created.

        """
        name = invalid_values_list()[0]
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.create({'variable': name, 'puppet-class': self.puppet_class['name']})
Example #39
0
    def test_positive_delete_smart_variable_by_id(self):
        """Delete a Smart Variable by id.

        @id: b0c4f7f0-d568-411f-94c2-fa525f36a8fd

        @steps:

        1. Delete a smart Variable by id.

        @assert: The smart Variable is deleted successfully.
        """
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet['name']})
        SmartVariable.delete({'id': smart_variable['id']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.info({'id': smart_variable['id']})
Example #40
0
    def test_positive_delete_smart_variable_by_name(self):
        """Delete a Smart Variable by name.

        @id: 52900000-d7e1-4f0c-b67e-a2a1d25fc76e

        @steps:

        1. Delete a smart Variable by name.

        @assert: The smart Variable is deleted successfully.
        """
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet['name']})
        SmartVariable.delete({'variable': smart_variable['variable']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.info({'variable': smart_variable['variable']})
Example #41
0
    def test_positive_delete_smart_variable_by_id(self):
        """Delete a Smart Variable by id.

        @id: b0c4f7f0-d568-411f-94c2-fa525f36a8fd

        @steps:

        1. Delete a smart Variable by id.

        @assert: The smart Variable is deleted successfully.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        SmartVariable.delete({'id': smart_variable['id']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.info({'id': smart_variable['id']})
Example #42
0
    def test_positive_delete_smart_variable_by_name(self):
        """Delete a Smart Variable by name.

        @id: 52900000-d7e1-4f0c-b67e-a2a1d25fc76e

        @steps:

        1. Delete a smart Variable by name.

        @assert: The smart Variable is deleted successfully.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        SmartVariable.delete({'variable': smart_variable['variable']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.info({'variable': smart_variable['variable']})
Example #43
0
    def test_positive_CRUD(self):
        """Create, Update, and Delete Smart Variable.

        :id: 8be9ed26-9a27-42a8-8edd-b255637f205e

        :steps: Create a smart Variable with Valid name.

        :expectedresults: The smart Variable is created successfully.

        :CaseImportance: Critical
        """
        name = valid_data_list()[0]
        smart_variable = make_smart_variable(
            {'variable': name, 'puppet-class': self.puppet_class['name']}
        )
        self.assertEqual(smart_variable['variable'], name)

        # Update name and puppet class
        new_name = valid_data_list()[0]
        new_puppet = Puppet.info({'name': choice(self.puppet_subclasses)['name']})
        SmartVariable.update(
            {
                'id': smart_variable['id'],
                'new-variable': new_name,
                'puppet-class': new_puppet['name'],
            }
        )
        updated_sv = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(updated_sv['puppet-class'], new_puppet['name'])
        self.assertEqual(updated_sv['variable'], new_name)

        # Delete
        SmartVariable.delete({'variable': updated_sv['variable']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.info({'variable': updated_sv['variable']})
Example #44
0
    def test_negative_create(self):
        """Create Smart Variable with invalid name.

        @id: 3f71f39f-4178-42e7-be40-2a3538361466

        @steps:

        1. Create a smart Variable with Invalid name.

        @assert: The smart Variable is not created.
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    SmartVariable.create({
                        'variable': name,
                        'puppet-class': self.puppet_class['name']
                    })
Example #45
0
    def test_negative_create(self):
        """Create Smart Variable with invalid name.

        @id: 3f71f39f-4178-42e7-be40-2a3538361466

        @steps:

        1. Create a smart Variable with Invalid name.

        @assert: The smart Variable is not created.
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    SmartVariable.create({
                        'variable': name,
                        'puppet-class': self.puppet['name']
                    })
Example #46
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'),
            })
Example #47
0
    def test_negative_duplicate_name_variable(self):
        """Create Smart Variable with an existing name.

        @id: cc219111-1d2a-47ae-9b22-0b399f2d586d

        @steps:

        1. Create a smart Variable with Valid name and default value.
        2. Attempt to create a variable with same name from same/other class.

        @assert: The variable with same name are not allowed to create from
        any class.
        """
        name = gen_string('alpha')
        make_smart_variable(
            {'variable': name, 'puppet-class': self.puppet_class['name']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.create({
                'variable': name, 'puppet-class': self.puppet_class['name']})
Example #48
0
    def test_negative_validate_default_value_with_list(self):
        """Test variable is not created for unmatched validator type list.

        :id: dc2b6471-99d7-448b-b90a-9675baacbebe

        :steps: Attempt to create variable with default value that doesn't
            match values from validator list

        :expectedresults: Variable is not created for unmatched validator rule.

        :CaseImportance: High
        """
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.create({
                'puppet-class': self.puppet_class['name'],
                'default-value': gen_string('alphanumeric'),
                'validator-type': 'list',
                'validator-rule': '5, test',
            })
Example #49
0
    def test_negative_validate_default_value_with_list(self):
        """Test variable is not created for unmatched validator type list.

        @id: dc2b6471-99d7-448b-b90a-9675baacbebe

        @steps:

        1.  Attempt to create variable with default value that doesn't match
        values from validator list

        @assert: Variable is not created for unmatched validator rule.
        """
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.create({
                'puppet-class': self.puppet_class['name'],
                'default-value': gen_string('alphanumeric'),
                'validator-type': 'list',
                'validator-rule': '5, test',
            })
Example #50
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'),
                }
            )
Example #51
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']})
Example #52
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': '',
            })
Example #53
0
    def test_positive_list_variables_by_puppetclass_id(self):
        """List all smart variables associated to puppet class by puppet class
        id.

        @id: 57d290e8-2ae2-4c09-ab1e-7c7914bc4ba8

        @assert: Smart Variables listed for specific puppet class by puppet
        class id.
        """
        make_smart_variable({'puppet-class-id': self.puppet['id']})
        sc_params_list = SmartVariable.list(
            {'puppet-class-id': self.puppet['id']})
        self.assertGreater(len(sc_params_list), 0)
Example #54
0
    def test_positive_list_variables_by_puppetclass_name(self):
        """List all smart variables associated to puppet class by puppet class
        name.

        @id: 43b795c2-a64d-4a84-bb35-1e8fd0e1a0c9

        @assert: Smart Variables listed for specific puppet class by puppet
        class name.
        """
        make_smart_variable({'puppet-class': self.puppet_class['name']})
        sc_params_list = SmartVariable.list({
            'puppet-class': self.puppet_class['name']
        })
        self.assertGreater(len(sc_params_list), 0)
Example #55
0
    def test_positive_list_variables_by_puppetclass_id(self):
        """List all smart variables associated to puppet class by puppet class
        id.

        @id: 57d290e8-2ae2-4c09-ab1e-7c7914bc4ba8

        @assert: Smart Variables listed for specific puppet class by puppet
        class id.
        """
        make_smart_variable({'puppet-class-id': self.puppet_class['id']})
        sc_params_list = SmartVariable.list({
            'puppet-class-id': self.puppet_class['id']
        })
        self.assertGreater(len(sc_params_list), 0)
Example #56
0
    def test_positive_update_name(self):
        """Update Smart Variable's name

        @id: e73c1366-6745-4576-ae22-d87cbf03faf9

        @steps:

        1. Create a smart variable with valid name.
        2. Update smart variable name created in step1.

        @assert: The variable is updated with new name.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                SmartVariable.update({
                    'id': smart_variable['id'],
                    'new-variable': new_name,
                    'puppet-class': self.puppet_class['name']
                })
                updated_sv = SmartVariable.info({'id': smart_variable['id']})
                self.assertEqual(updated_sv['variable'], new_name)
Example #57
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,
            })
Example #58
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')
            })
Example #59
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']})
Example #60
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)