Beispiel #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)
Beispiel #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)
    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)
Beispiel #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,
            })
Beispiel #5
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']})
    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]')
Beispiel #7
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)
    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)
    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)
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
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,
            })
Beispiel #13
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)
Beispiel #14
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)
Beispiel #15
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)
Beispiel #16
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)
Beispiel #17
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]')
Beispiel #18
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'])
Beispiel #19
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 #20
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 #21
0
    def test_positive_hide_update_and_unhide_default_value(self):
        """Test hiding of the default value of variable.

        :id: 00dd5627-5d7c-4fb2-9bbc-bf812205459e

        :steps:

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

        :BZ: 1371794

        :expectedresults: The 'hidden value' set to true for that variable.
            Default value is hidden

        """
        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)
        self.assertEqual(smart_variable['default-value'], '*****')

        # Update hidden value to empty
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'default-value': '',
        })
        updated_sv = SmartVariable.info({
            'variable': smart_variable['variable'],
            'show-hidden': 'true',
        })
        self.assertEqual(updated_sv['default-value'], '')

        # Unhide value
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'hidden-value': 0
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['hidden-value?'], False)
Beispiel #22
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['name']})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                SmartVariable.update({
                    'id': smart_variable['id'],
                    'new-name': new_name,
                    'puppet-class': self.puppet['name']
                })
                updated_sv = SmartVariable.info({'id': smart_variable['id']})
                self.assertEqual(updated_sv['name'], new_name)
Beispiel #23
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)
Beispiel #24
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['name']})
        self.assertEqual(smart_variable['puppet-class'], self.puppet['name'])
        new_puppet = Puppet.info({u'name': 'ntp::config'})
        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'])