def test_positive_create_with_env(self):
        """Create a hostgroup with environment specified

        @id: 528afd01-356a-4082-9e88-a5b2a715a792

        @assert: A hostgroup is created with expected environment assigned

        @CaseLevel: Integration
        """
        env = entities.Environment(
            location=[self.loc],
            organization=[self.org],
        ).create()
        hostgroup = entities.HostGroup(
            environment=env,
            location=[self.loc],
            organization=[self.org],
        ).create()
        self.assertEqual(hostgroup.environment.read().name, env.name)
Exemple #2
0
    def test_positive_create_with_domain(self):
        """Create a hostgroup with domain specified

        :id: 4f4aee5d-1f43-45e6-ac60-0573083dbcee

        :expectedresults: A hostgroup is created with expected domain assigned

        :CaseLevel: Integration
        """
        domain = entities.Domain(
            location=[self.loc],
            organization=[self.org],
        ).create()
        hostgroup = entities.HostGroup(
            domain=domain,
            location=[self.loc],
            organization=[self.org],
        ).create()
        self.assertEqual(hostgroup.domain.read().name, domain.name)
Exemple #3
0
    def test_positive_update_content_source(self):
        """Update a hostgroup with a new puppet proxy

        :id: 02ef1340-a21e-41b7-8aa7-d6fdea196c16

        :expectedresults: A hostgroup is updated with expected puppet proxy

        :CaseLevel: Integration
        """
        hostgroup = entities.HostGroup(location=[self.loc],
                                       organization=[self.org]).create()
        new_content_source = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup.content_source = new_content_source
        hostgroup = hostgroup.update(['content_source'])
        self.assertEqual(hostgroup.content_source.read().name,
                         new_content_source.name)
Exemple #4
0
    def test_positive_update_locs(self):
        """Update a hostgroup with new multiple locations

        :id: b045f7e8-d7c0-428b-a29c-8d54e53742e2

        :expectedresults: A hostgroup is updated with expected locations

        :CaseLevel: Integration
        """
        hostgroup = entities.HostGroup(location=[self.loc],
                                       organization=[self.org]).create()
        new_locs = [
            entities.Location(organization=[self.org]).create()
            for _ in range(randint(3, 5))
        ]
        hostgroup.location = new_locs
        hostgroup = hostgroup.update(['location'])
        self.assertEqual(set(loc.name for loc in new_locs),
                         set(loc.read().name for loc in hostgroup.location))
def test_positive_end_to_end(session, module_org, module_loc):
    """Perform end to end testing for puppet class component

    :id: f837eec0-101c-4aff-a270-652005bdee51

    :expectedresults: All expected CRUD actions finished successfully

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    hostgroup = entities.HostGroup(organization=[module_org],
                                   location=[module_loc]).create()
    puppet_class = entities.PuppetClass(name=name).create()
    with session:
        # Check that created puppet class can be found in UI
        assert session.puppetclass.search(name)[0]['Class name'] == name
        # Read puppet class values and check that they are expected
        pc_values = session.puppetclass.read(name)
        assert pc_values['puppet_class']['name'] == name
        assert not pc_values['puppet_class']['puppet_environment']
        assert not pc_values['puppet_class']['host_group']['assigned']
        # Update puppet class
        session.puppetclass.update(
            puppet_class.name,
            {'puppet_class.host_group.assigned': [hostgroup.name]})
        pc_values = session.puppetclass.read(name)
        assert pc_values['puppet_class']['host_group']['assigned'] == [
            hostgroup.name
        ]
        # Make an attempt to delete puppet class that associated with host group
        with pytest.raises(AssertionError) as context:
            session.puppetclass.delete(name)
        assert f"error: '{puppet_class.name} is used by {hostgroup.name}'" in str(
            context.value)
        # Unassign puppet class from host group
        session.puppetclass.update(
            puppet_class.name,
            {'puppet_class.host_group.unassigned': [hostgroup.name]})
        # Delete puppet class
        session.puppetclass.delete(name)
        assert not session.puppetclass.search(name)
Exemple #6
0
    def test_positive_create_with_hostgroup(self):
        """Create a host with hostgroup specified

        @feature: Hosts

        @assert: A host is created with expected hostgroup assigned
        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        hostgroup = entities.HostGroup(
            location=[loc],
            organization=[org],
        ).create()
        host = entities.Host(
            hostgroup=hostgroup,
            location=loc,
            organization=org,
        ).create()
        self.assertEqual(host.hostgroup.read().name, hostgroup.name)
    def test_positive_update_orgs(self):
        """Update a hostgroup with new multiple organizations

        @feature: HostGroup

        @assert: A hostgroup is updated with expected organizations
        """
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
        ).create()
        new_orgs = [
            entities.Organization().create() for _ in range(randint(3, 5))
        ]
        hostgroup.organization = new_orgs
        hostgroup = hostgroup.update(['organization'])
        self.assertEqual(
            set(org.name for org in new_orgs),
            set(org.read().name for org in hostgroup.organization))
Exemple #8
0
def test_positive_delete_rule_with_non_admin_user(manager_loc, manager_user, module_org, test_name):
    """Delete rule with non-admin user by associating discovery_manager role

    :id: 7fa56bab-82d7-46c9-a4fa-c44ef173c703

    :expectedresults: Rule should be deleted successfully.

    :CaseLevel: Integration
    """
    hg = entities.HostGroup(organization=[module_org]).create()
    dr = entities.DiscoveryRule(
        hostgroup=hg, organization=[module_org], location=[manager_loc]
    ).create()
    with Session(test_name, user=manager_user.login, password=manager_user.password) as session:
        dr_val = session.discoveryrule.read_all()
        assert dr.name in [rule['Name'] for rule in dr_val]
        session.discoveryrule.delete(dr.name)
        dr_val = session.discoveryrule.read_all()
        assert dr.name not in [rule['Name'] for rule in dr_val]
    def test_positive_create_with_cv(self):
        """Create a hostgroup with content view specified

        @feature: HostGroup

        @assert: A hostgroup is created with expected content view assigned
        """
        content_view = entities.ContentView(organization=self.org).create()
        content_view.publish()
        content_view = content_view.read()
        lce = entities.LifecycleEnvironment(organization=self.org).create()
        promote(content_view.version[0], lce.id)
        hostgroup = entities.HostGroup(
            content_view=content_view,
            lifecycle_environment=lce,
            location=[self.loc],
            organization=[self.org],
        ).create()
        self.assertEqual(hostgroup.content_view.read().name, content_view.name)
Exemple #10
0
    def test_positive_read_puppet_ca_proxy_name(self):
        """Read a hostgroup created with puppet ca proxy and inspect server's
        response

        :id: ab151e09-8e64-4377-95e8-584629750659

        :expectedresults: Field 'puppet_ca_proxy_name' is returned

        :BZ: 1371900

        :CaseImportance: Critical
        """
        proxy = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hg = entities.HostGroup(puppet_ca_proxy=proxy).create().read_json()
        self.assertIn('puppet_ca_proxy_name', hg)
        self.assertEqual(proxy.name, hg['puppet_ca_proxy_name'])
Exemple #11
0
    def test_positive_create_with_subnet(self):
        """Create a hostgroup with subnet specified

        :id: affcaa2e-e22f-4601-97b2-4ca516f6ad2b

        :expectedresults: A hostgroup is created with expected subnet assigned

        :CaseLevel: Integration
        """
        subnet = entities.Subnet(
            location=[self.loc],
            organization=[self.org],
        ).create()
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
            subnet=subnet,
        ).create()
        self.assertEqual(hostgroup.subnet.read().name, subnet.name)
Exemple #12
0
    def test_positive_read_puppet_proxy_name(self):
        """Read a hostgroup created with puppet proxy and inspect server's
        response

        :id: f93d0866-0073-4577-8777-6d645b63264f

        :expectedresults: Field 'puppet_proxy_name' is returned

        :BZ: 1371900

        :CaseImportance: Critical
        """
        proxy = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hg = entities.HostGroup(puppet_proxy=proxy).create().read_json()
        self.assertIn('puppet_proxy_name', hg)
        self.assertEqual(proxy.name, hg['puppet_proxy_name'])
    def test_positive_add_and_remove_hostgroup(self):
        """Add a hostgroup to an organization and then remove it

        :id: 7eb1aca7-fd7b-404f-ab18-21be5052a11f

        :BZ: 1395229

        :expectedresults: Hostgroup is added to organization and then removed

        :CaseLevel: Integration
        """
        org = entities.Organization().create()
        hostgroup = entities.HostGroup().create()
        org.hostgroup = [hostgroup]
        org = org.update(['hostgroup'])
        assert len(org.hostgroup) == 1
        org.hostgroup = []
        org = org.update(['hostgroup'])
        assert len(org.hostgroup) == 0
Exemple #14
0
def test_positive_update_by_type():
    """Update some entities of different types and check audit logs for
    these events using entity type as search criteria

    :id: 43e73a11-b241-4b91-bdf6-e966366014e8

    :expectedresults: Audit logs contain corresponding entries per each
        update event

    :CaseImportance: Medium

    :CaseComponent: AuditLog

    :Assignee: rplevka
    """
    for entity in [
            entities.Architecture(),
            entities.Domain(),
            entities.HostGroup(),
            entities.Location(),
            entities.Organization(),
            entities.Role(),
            entities.UserGroup(),
    ]:
        created_entity = entity.create()
        name = created_entity.name
        new_name = gen_string('alpha')
        created_entity.name = new_name
        created_entity = created_entity.update(['name'])
        audits = entities.Audit().search(
            query={
                'search': f'type={created_entity.__class__.__name__.lower()}'
            })
        entity_audits = [
            entry for entry in audits if entry.auditable_name == name
        ]
        assert entity_audits, f'audit not found by name "{name}"'
        audit = entity_audits[0]
        assert audit.auditable_id == created_entity.id
        assert audit.audited_changes['name'] == [name, new_name]
        assert audit.action == 'update'
        assert audit.version == 2
Exemple #15
0
    def test_positive_delete_by_type(self):
        """Delete some entities of different types and check audit logs for
        these events using entity type as search criteria

        :id: de9b056f-10da-485a-87ce-b02a9efff15c

        :expectedresults: Audit logs contain corresponding entries per each
            delete event

        :CaseImportance: Medium

        :CaseComponent: AuditLog
        """
        for entity in [
                entities.Architecture(),
                entities.Domain(),
                entities.Host(),
                entities.HostGroup(),
                entities.Location(),
                entities.Organization(),
                entities.Role(),
                entities.UserGroup(),
        ]:
            created_entity = entity.create()
            created_entity.delete()
            audits = entities.Audit().search(
                query={
                    'search':
                    'type={0}'.format(
                        created_entity.__class__.__name__.lower())
                })
            entity_audits = [
                entry for entry in audits
                if entry.auditable_name == created_entity.name
            ]
            if not entity_audits:
                self.fail('audit not found by name "{}"'.format(
                    created_entity.name))
            audit = entity_audits[0]
            self.assertEqual(audit.auditable_id, created_entity.id)
            self.assertEqual(audit.action, 'destroy')
            self.assertEqual(audit.version, 2)
Exemple #16
0
    def test_negative_update_name(self):
        """Attempt to update a hostgroup with invalid names

        :id: 6d8c4738-a0c4-472b-9a71-27c8a3832335

        :expectedresults: A hostgroup is not updated

        :CaseImportance: Critical
        """
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
        ).create()
        original_name = hostgroup.name
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                hostgroup.name = new_name
                with self.assertRaises(HTTPError):
                    hostgroup.update(['name'])
                self.assertEqual(hostgroup.read().name, original_name)
Exemple #17
0
    def test_positive_create_with_group_parameters(self):
        """Create a hostgroup with 'group parameters' specified

        :id: 0959e2a2-d635-482b-9b2e-d33990d6f0dc

        :expectedresults: A hostgroup is created with assigned group parameters

        :CaseLevel: Integration

        :BZ: 1710853
        """
        group_params = {'name': gen_string('alpha'), 'value': gen_string('alpha')}
        hostgroup = entities.HostGroup(
            organization=[self.org],
            group_parameters_attributes=[group_params]
        ).create()
        self.assertEqual(group_params['name'],
                         hostgroup.group_parameters_attributes[0]['name'])
        self.assertEqual(group_params['value'],
                         hostgroup.group_parameters_attributes[0]['value'])
Exemple #18
0
    def test_positive_create_with_realm(self, module_org, module_location,
                                        default_sat):
        """Create a hostgroup with realm specified

        :id: 4f07ff8d-746f-4ab5-ae0b-03d629f6296c

        :expectedresults: A hostgroup is created with expected realm assigned

        :CaseLevel: Integration
        """
        realm = entities.Realm(
            location=[module_location],
            organization=[module_org],
            realm_proxy=entities.SmartProxy().search(
                query={'search': f'url = {default_sat.url}:9090'})[0],
        ).create()
        hostgroup = entities.HostGroup(location=[module_location],
                                       organization=[module_org],
                                       realm=realm).create()
        assert hostgroup.realm.read().name == realm.name
    def test_positive_create_with_realm(self):
        """Create a hostgroup with realm specified

        :id: 4f07ff8d-746f-4ab5-ae0b-03d629f6296c

        :expectedresults: A hostgroup is created with expected realm assigned

        :CaseLevel: Integration
        """
        realm = entities.Realm(
            location=[self.loc],
            organization=[self.org],
            realm_proxy=entities.SmartProxy().search(
                query={'search': f'url = https://{settings.server.hostname}:9090'}
            )[0],
        ).create()
        hostgroup = entities.HostGroup(
            location=[self.loc], organization=[self.org], realm=realm
        ).create()
        self.assertEqual(hostgroup.realm.read().name, realm.name)
Exemple #20
0
    def test_positive_update_puppet_ca_proxy(self):
        """Update a hostgroup with a new puppet CA proxy

        :id: fd13ab0e-1a5b-48a0-a852-3fff8306271f

        :expectedresults: A hostgroup is updated with expected puppet CA proxy

        :CaseLevel: Integration
        """
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
        ).create()
        new_proxy = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup.puppet_ca_proxy = new_proxy
        hostgroup = hostgroup.update(['puppet_ca_proxy'])
        self.assertEqual(hostgroup.puppet_ca_proxy.read().name, new_proxy.name)
Exemple #21
0
    def test_positive_create_with_puppet_ca_proxy(self):
        """Create a hostgroup with puppet CA proxy specified

        :id: 5c715ee8-2fd6-42c6-aece-037733f67454

        :expectedresults: A hostgroup is created with expected puppet CA proxy
            assigned

        :CaseLevel: Integration
        """
        proxy = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
            puppet_ca_proxy=proxy,
        ).create()
        self.assertEqual(hostgroup.puppet_ca_proxy.read().name, proxy.name)
Exemple #22
0
def test_positive_create_rule_with_non_admin_user(manager_loc, manager_user, module_org, test_name):
    """Create rule with non-admin user by associating discovery_manager role

    :id: 6a03983b-363d-4646-b277-34af5f5abc55

    :expectedresults: Rule should be created successfully.

    :CaseLevel: Integration
    """
    name = gen_string('alpha')
    search = gen_string('alpha')
    hg = entities.HostGroup(organization=[module_org]).create()
    with Session(test_name, user=manager_user.login, password=manager_user.password) as session:
        session.location.select(loc_name=manager_loc.name)
        session.discoveryrule.create(
            {'primary.name': name, 'primary.search': search, 'primary.host_group': hg.name}
        )
        dr_val = session.discoveryrule.read(name, widget_names='primary')
        assert dr_val['primary']['name'] == name
        assert dr_val['primary']['host_group'] == hg.name
Exemple #23
0
    def test_positive_create_with_puppet_proxy(self):
        """Create a hostgroup with puppet proxy specified

        :id: 4f39f246-d12f-468c-a33b-66486c3806fe

        :expectedresults: A hostgroup is created with expected puppet proxy
            assigned

        :CaseLevel: Integration
        """
        proxy = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
            puppet_proxy=proxy,
        ).create()
        self.assertEqual(hostgroup.puppet_proxy.read().name, proxy.name)
Exemple #24
0
    def test_positive_create_with_locs(self, module_org):
        """Create a hostgroup with multiple locations specified

        :id: 0c2ee2ff-9e7a-4931-8cea-f4eecbd8c4c0

        :expectedresults: A hostgroup is created with expected multiple
            locations assigned

        :CaseLevel: Integration
        """
        locs = [
            entities.Location(organization=[module_org]).create()
            for _ in range(randint(3, 5))
        ]
        hostgroup = entities.HostGroup(location=locs,
                                       organization=[module_org]).create()
        assert {loc.name
                for loc in locs
                } == {loc.read().name
                      for loc in hostgroup.location}
Exemple #25
0
    def test_positive_update_puppet_proxy(self):
        """Update a hostgroup with a new puppet proxy

        :id: 86eca603-2cdd-4563-b6f6-aaa5cea1a723

        :expectedresults: A hostgroup is updated with expected puppet proxy

        :CaseLevel: Integration
        """
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
        ).create()
        new_proxy = entities.SmartProxy().search(query={
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup.puppet_proxy = new_proxy
        hostgroup = hostgroup.update(['puppet_proxy'])
        self.assertEqual(hostgroup.puppet_proxy.read().name, new_proxy.name)
    def test_positive_create_with_locs(self):
        """Create a hostgroup with multiple locations specified

        @id: 0c2ee2ff-9e7a-4931-8cea-f4eecbd8c4c0

        @assert: A hostgroup is created with expected multiple locations
        assigned

        @CaseLevel: Integration
        """
        locs = [
            entities.Location(organization=[self.org]).create()
            for _ in range(randint(3, 5))
        ]
        hostgroup = entities.HostGroup(
            location=locs,
            organization=[self.org],
        ).create()
        self.assertEqual(set(loc.name for loc in locs),
                         set(loc.read().name for loc in hostgroup.location))
Exemple #27
0
    def test_positive_create_with_hostgroup(self):
        """Add a hostgroup during organization creation.

        :id: ce1b5334-5601-42ae-aa04-3e766daa3984

        :expectedresults: hostgroup is added to organization

        :CaseLevel: Integration
        """
        with Session(self.browser):
            for hostgroup_name in generate_strings_list():
                with self.subTest(hostgroup_name):
                    # Create host group using nailgun
                    hostgroup = entities.HostGroup(
                        name=hostgroup_name).create()
                    self.assertEqual(hostgroup.name, hostgroup_name)
                    self.assertIsNotNone(
                        self.org.create_with_entity(gen_string('alpha'),
                                                    'hostgroups',
                                                    hostgroup_name))
    def test_positive_update_lce(self):
        """Update a hostgroup with a new lifecycle environment

        @id: df89d8e3-bd36-4ad9-bde8-1872ae3dd918

        @assert: A hostgroup is updated with expected lifecycle environment

        @CaseLevel: Integration
        """
        lce = entities.LifecycleEnvironment(organization=self.org).create()
        hostgroup = entities.HostGroup(
            lifecycle_environment=lce,
            location=[self.loc],
            organization=[self.org],
        ).create()
        new_lce = entities.LifecycleEnvironment(organization=self.org).create()
        hostgroup.lifecycle_environment = new_lce
        hostgroup = hostgroup.update(['lifecycle_environment'])
        self.assertEqual(hostgroup.lifecycle_environment.read().name,
                         new_lce.name)
Exemple #29
0
    def test_positive_create_with_org_loc(self):
        """Create discovery rule by associating org and location

        :id: 121e0a30-8a24-47d7-974d-998886ed1ea7

        :expectedresults: Rule was created and with given org & location.

        :CaseImportance: Critical
        """
        org = entities.Organization().create()
        loc = entities.Location().create()
        hostgroup = entities.HostGroup(organization=[org]).create()
        discovery_rule = entities.DiscoveryRule(
            hostgroup=hostgroup,
            search_='cpu_count = 1',
            organization=[org],
            location=[loc],
        ).create()
        self.assertEqual(org.name, discovery_rule.organization[0].read().name)
        self.assertEqual(loc.name, discovery_rule.location[0].read().name)
    def test_positive_create_with_realm(self):
        """Create a hostgroup with realm specified

        @id: 4f07ff8d-746f-4ab5-ae0b-03d629f6296c

        @assert: A hostgroup is created with expected realm assigned

        @CaseLevel: Integration
        """
        realm = entities.Realm(
            location=[self.loc],
            organization=[self.org],
            realm_proxy=entities.SmartProxy().search()[0],
        ).create()
        hostgroup = entities.HostGroup(
            location=[self.loc],
            organization=[self.org],
            realm=realm,
        ).create()
        self.assertEqual(hostgroup.realm.read().name, realm.name)