def test_negative_update_content_source(self):
        """Attempt to update hostgroup's content source with invalid value

        :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26

        :BZ: 1260697, 1313056

        :expectedresults: Host group was not updated. Content source remains
            the same as it was before update

        :CaseImportance: Medium
        """
        content_source = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        with self.assertRaises(CLIBaseError):
            HostGroup.update({
                'id': hostgroup['id'],
                'content-source-id': gen_integer(10000, 99999),
            })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(
            hostgroup['content-source']['name'], content_source['name'])
    def test_positive_update_content_source(self):
        """Update hostgroup's content source

        :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

        :customerscenario: true

        :BZ: 1260697, 1313056

        :expectedresults: Hostgroup was successfully updated with new content
            source

        :CaseImportance: High
        """
        content_source = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        new_content_source = make_proxy()
        self.addCleanup(capsule_cleanup, new_content_source['id'])
        self.addCleanup(HostGroup.delete, {'id': hostgroup['id']})
        HostGroup.update({
            'id': hostgroup['id'],
            'content-source-id': new_content_source['id'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(hostgroup['content-source']['name'],
                         new_content_source['name'])
    def test_negative_update_content_source(self):
        """Attempt to update hostgroup's content source with invalid value

        :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26

        :BZ: 1260697, 1313056

        :expectedresults: Host group was not updated. Content source remains
            the same as it was before update

        :CaseImportance: Medium
        """
        content_source = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        with self.assertRaises(CLIReturnCodeError):
            HostGroup.update({
                'id': hostgroup['id'],
                'content-source-id': gen_integer(10000, 99999),
            })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(hostgroup['content-source']['name'],
                         content_source['name'])
    def test_positive_update_content_source(self):
        """Update hostgroup's content source

        :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

        :customerscenario: true

        :BZ: 1260697, 1313056

        :expectedresults: Hostgroup was successfully updated with new content
            source

        :CaseImportance: High
        """
        content_source = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        new_content_source = make_proxy()
        self.addCleanup(capsule_cleanup, new_content_source['id'])
        self.addCleanup(HostGroup.delete, {'id': hostgroup['id']})
        HostGroup.update({
            'id': hostgroup['id'],
            'content-source-id': new_content_source['id'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(
            hostgroup['content-source']['name'], new_content_source['name'])
Exemple #5
0
def test_positive_update_hostgroup(
    request,
    module_puppet_org,
    env,
    puppet_content_source,
    puppet_classes,
    session_puppet_enabled_sat,
    puppet_proxy_port_range,
):
    """Update hostgroup's content source, name and puppet classes

    :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

    :customerscenario: true

    :BZ: 1260697, 1313056

    :expectedresults: Hostgroup was successfully updated with new content
        source, name and puppet classes

    :CaseLevel: Integration
    """
    with session_puppet_enabled_sat:
        hostgroup = make_hostgroup({
            'content-source-id':
            puppet_content_source['id'],
            'organization-ids':
            module_puppet_org.id,
            'environment-id':
            env.id,
            'query-organization-id':
            module_puppet_org.id,
        })
        new_content_source = make_proxy()

        @request.addfinalizer
        def _cleanup():
            with session_puppet_enabled_sat:
                HostGroup.delete({'id': hostgroup['id']})
                capsule_cleanup(new_content_source['id'])

        assert len(hostgroup['puppetclasses']) == 0
        new_name = valid_hostgroups_list()[0]
        puppet_class_names = [puppet['name'] for puppet in puppet_classes]
        HostGroup.update({
            'new-name': new_name,
            'id': hostgroup['id'],
            'content-source-id': new_content_source['id'],
            'puppet-classes': puppet_class_names,
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        assert hostgroup['name'] == new_name
        assert hostgroup['content-source']['name'] == new_content_source[
            'name']
        for puppet_class_name in puppet_class_names:
            assert puppet_class_name in hostgroup['puppetclasses']
Exemple #6
0
def test_negative_update_name(hostgroup):
    """Create HostGroup then fail to update its name

    :id: 42d208a4-f518-4ff2-9b7a-311adb460abd

    :expectedresults: HostGroup name is not updated
    """
    new_name = invalid_values_list()[0]
    with pytest.raises(CLIReturnCodeError):
        HostGroup.update({'id': hostgroup['id'], 'new-name': new_name})
    result = HostGroup.info({'id': hostgroup['id']})
    assert hostgroup['name'] == result['name']
Exemple #7
0
    def test_positive_update_name(self):
        """@Test: Successfully update an HostGroup.

        @Feature: HostGroup

        @Assert: HostGroup is updated.
        """
        hostgroup = make_hostgroup()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                HostGroup.update({"id": hostgroup["id"], "new-name": new_name})
                hostgroup = HostGroup.info({"id": hostgroup["id"]})
                self.assertEqual(hostgroup["name"], new_name)
Exemple #8
0
    def test_negative_update(self):
        """@test: Create HostGroup then fail to update its name

        @feature: HostGroup

        @assert: HostGroup name is not updated
        """
        hostgroup = make_hostgroup()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.update({"id": hostgroup["id"], "new-name": new_name})
                result = HostGroup.info({"id": hostgroup["id"]})
                self.assertEqual(hostgroup["name"], result["name"])
    def test_positive_update_name(self):
        """Successfully update an HostGroup.

        @Feature: HostGroup

        @Assert: HostGroup is updated.
        """
        hostgroup = make_hostgroup()
        for new_name in valid_hostgroups_list():
            with self.subTest(new_name):
                HostGroup.update({
                    'id': hostgroup['id'],
                    'new-name': new_name,
                })
                hostgroup = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], new_name)
    def test_positive_update_name(self):
        """Successfully update an HostGroup.

        @id: a36e3cbe-83d9-44ce-b8f7-5fab2a2cadf9

        @Assert: HostGroup is updated.
        """
        hostgroup = make_hostgroup()
        for new_name in valid_hostgroups_list():
            with self.subTest(new_name):
                HostGroup.update({
                    'id': hostgroup['id'],
                    'new-name': new_name,
                })
                hostgroup = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], new_name)
Exemple #11
0
    def test_positive_update_name(self):
        """Successfully update an HostGroup.

        @id: a36e3cbe-83d9-44ce-b8f7-5fab2a2cadf9

        @Assert: HostGroup is updated.
        """
        hostgroup = make_hostgroup()
        for new_name in valid_hostgroups_list():
            with self.subTest(new_name):
                HostGroup.update({
                    'id': hostgroup['id'],
                    'new-name': new_name,
                })
                hostgroup = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], new_name)
Exemple #12
0
def test_negative_update_content_source(hostgroup, content_source):
    """Attempt to update hostgroup's content source with invalid value

    :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26

    :BZ: 1260697, 1313056

    :expectedresults: Host group was not updated. Content source remains
        the same as it was before update

    :CaseLevel: Integration
    """
    with pytest.raises(CLIReturnCodeError):
        HostGroup.update({'id': hostgroup['id'], 'content-source-id': gen_integer(10000, 99999)})
    hostgroup = HostGroup.info({'id': hostgroup['id']})
    assert hostgroup['content-source']['name'] == content_source['name']
Exemple #13
0
    def test_positive_update_name(self):
        """Successfully update an HostGroup.

        @Feature: HostGroup

        @Assert: HostGroup is updated.
        """
        hostgroup = make_hostgroup()
        for new_name in valid_hostgroups_list():
            with self.subTest(new_name):
                HostGroup.update({
                    'id': hostgroup['id'],
                    'new-name': new_name,
                })
                hostgroup = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], new_name)
    def test_negative_update_name(self):
        """Create HostGroup then fail to update its name

        @id: 42d208a4-f518-4ff2-9b7a-311adb460abd

        @assert: HostGroup name is not updated
        """
        hostgroup = make_hostgroup()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.update({
                        'id': hostgroup['id'],
                        'new-name': new_name,
                    })
                result = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], result['name'])
    def test_negative_update_name(self):
        """Create HostGroup then fail to update its name

        @feature: HostGroup

        @assert: HostGroup name is not updated
        """
        hostgroup = make_hostgroup()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.update({
                        'id': hostgroup['id'],
                        'new-name': new_name,
                    })
                result = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], result['name'])
Exemple #16
0
    def test_positive_update_hostgroup(self):
        """Update hostgroup's content source, name and puppet classes

        :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

        :customerscenario: true

        :BZ: 1260697, 1313056

        :expectedresults: Hostgroup was successfully updated with new content
            source, name and puppet classes

        :CaseLevel: Integration
        """
        hostgroup = make_hostgroup({
            'content-source-id':
            self.content_source['id'],
            'organization-ids':
            self.org['id'],
            'environment-id':
            self.env['id'],
            'content-view-id':
            self.cv['id'],
            'query-organization-id':
            self.org['id'],
        })
        new_content_source = make_proxy()
        self.addCleanup(capsule_cleanup, new_content_source['id'])
        self.addCleanup(HostGroup.delete, {'id': hostgroup['id']})
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        new_name = valid_hostgroups_list()[0]
        puppet_classes = [puppet['name'] for puppet in self.puppet_classes]
        HostGroup.update({
            'new-name': new_name,
            'id': hostgroup['id'],
            'content-source-id': new_content_source['id'],
            'puppet-classes': puppet_classes,
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(hostgroup['name'], new_name)
        self.assertEqual(hostgroup['content-source']['name'],
                         new_content_source['name'])
        self.assertEqual(set(puppet_classes), set(hostgroup['puppetclasses']))
    def test_negative_update_name(self):
        """Create HostGroup then fail to update its name

        :id: 42d208a4-f518-4ff2-9b7a-311adb460abd

        :expectedresults: HostGroup name is not updated

        :CaseImportance: Critical
        """
        hostgroup = make_hostgroup()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.update({
                        'id': hostgroup['id'],
                        'new-name': new_name,
                    })
                result = HostGroup.info({'id': hostgroup['id']})
                self.assertEqual(hostgroup['name'], result['name'])
    def test_positive_update_puppet_class_by_name(self):
        """Update hostgroup with puppet class by name

        :id: 4c37354f-ef2d-4d54-98ac-906bc611d292

        :expectedresults: Puppet class is associated with hostgroup

        :CaseImportance: Critical
        """
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'content-view-id': self.cv['id'],
            'query-organization-id': self.org['id'],
        })
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        HostGroup.update({
            'id': hostgroup['id'],
            'puppet-classes': self.puppet_classes[0]['name'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertIn(self.puppet_classes[0]['name'],
                      hostgroup['puppetclasses'])
    def test_positive_update_puppet_class_by_id(self):
        """Update hostgroup with puppet class by name by id

        :id: 4b044719-431d-4d72-8974-330cc62fd020

        :expectedresults: Puppet class is associated with hostgroup

        :CaseImportance: Critical
        """
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'content-view-id': self.cv['id'],
            'query-organization-id': self.org['id'],
        })
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        HostGroup.update({
            'id': hostgroup['id'],
            'puppet-class-ids': self.puppet_classes[0]['id'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertIn(self.puppet_classes[0]['name'],
                      hostgroup['puppetclasses'])
Exemple #20
0
    def test_positive_update_multiple_puppet_classes(self):
        """Update hostgroup with multiple puppet classes by name

        :id: 2e977aed-c0d4-478e-9c84-f07deac912cd

        :expectedresults: All puppet classes are associated with hostgroup

        :BZ: 1264163

        :CaseImportance: Critical
        """
        puppet_classes = [puppet['name'] for puppet in self.puppet_classes]
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'content-view-id': self.cv['id'],
            'query-organization-id': self.org['id'],
        })
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        HostGroup.update({
            'id': hostgroup['id'], 'puppet-classes': puppet_classes})
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(set(puppet_classes), set(hostgroup['puppetclasses']))
    def test_positive_update_multiple_puppet_classes(self):
        """Update hostgroup with multiple puppet classes by name

        :id: 2e977aed-c0d4-478e-9c84-f07deac912cd

        :expectedresults: All puppet classes are associated with hostgroup

        :BZ: 1264163

        :CaseImportance: Critical
        """
        puppet_classes = [puppet['name'] for puppet in self.puppet_classes]
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'content-view-id': self.cv['id'],
            'query-organization-id': self.org['id'],
        })
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        HostGroup.update({
            'id': hostgroup['id'], 'puppet-classes': puppet_classes})
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(set(puppet_classes), set(hostgroup['puppetclasses']))
    def test_positive_update_puppet_class_by_name(self):
        """Update hostgroup with puppet class by name

        :id: 4c37354f-ef2d-4d54-98ac-906bc611d292

        :expectedresults: Puppet class is associated with hostgroup

        :CaseImportance: Critical
        """
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'content-view-id': self.cv['id'],
            'query-organization-id': self.org['id'],
        })
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        HostGroup.update({
            'id': hostgroup['id'],
            'puppet-classes': self.puppet_classes[0]['name'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertIn(
            self.puppet_classes[0]['name'], hostgroup['puppetclasses'])
    def test_positive_update_puppet_class_by_id(self):
        """Update hostgroup with puppet class by name by id

        :id: 4b044719-431d-4d72-8974-330cc62fd020

        :expectedresults: Puppet class is associated with hostgroup

        :CaseImportance: Critical
        """
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'content-view-id': self.cv['id'],
            'query-organization-id': self.org['id'],
        })
        self.assertEqual(len(hostgroup['puppetclasses']), 0)
        HostGroup.update({
            'id': hostgroup['id'],
            'puppet-class-ids': self.puppet_classes[0]['id'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertIn(
            self.puppet_classes[0]['name'], hostgroup['puppetclasses'])
Exemple #24
0
def test_positive_update_hostgroup(request, module_org, content_source):
    """Update hostgroup's content source and name

    :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

    :customerscenario: true

    :BZ: 1260697, 1313056

    :expectedresults: Hostgroup was successfully updated with new content
        source and name

    :CaseLevel: Integration
    """
    hostgroup = make_hostgroup({
        'content-source-id': content_source['id'],
        'organization-ids': module_org.id,
        'query-organization-id': module_org.id,
    })
    new_content_source = make_proxy()

    @request.addfinalizer
    def _cleanup():
        HostGroup.delete({'id': hostgroup['id']})
        capsule_cleanup(new_content_source['id'])

    assert len(hostgroup['puppetclasses']) == 0
    new_name = valid_hostgroups_list()[0]
    HostGroup.update({
        'new-name': new_name,
        'id': hostgroup['id'],
        'content-source-id': new_content_source['id'],
    })
    hostgroup = HostGroup.info({'id': hostgroup['id']})
    assert hostgroup['name'] == new_name
    assert hostgroup['content-source']['name'] == new_content_source['name']