예제 #1
0
    def test_positive_update_org_loc_by_name(self):
        """Update org and location of selected discovery rule using org/loc
        names

        :id: 7a5d61ac-6a2d-48f6-a00d-df437a7dc3c4

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

        :BZ: 1377990

        :CaseLevel: Component

        :CaseImportance: Medium
        """
        new_org = make_org()
        new_loc = make_location()
        new_hostgroup = make_hostgroup({
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id']
        })
        rule = self._make_discoveryrule()
        DiscoveryRule.update({
            'id': rule['id'],
            'organizations': new_org['name'],
            'locations': new_loc['name'],
            'hostgroup-id': new_hostgroup['id'],
        })
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertIn(new_org['name'], rule['organizations'])
        self.assertIn(new_loc['name'], rule['locations'])
예제 #2
0
    def test_positive_create_rule_with_non_admin_user(self):
        """Create rule with non-admin user by associating discovery_manager role

        :id: 056535aa-3338-4c1e-8a4b-ebfc8bd6e456

        :expectedresults: Rule should be created successfully.

        :CaseLevel: Integration
        """
        rule_name = gen_string('alpha')
        rule = DiscoveryRule.with_user(
            self.user['login'],
            self.user['password']
        ).create({
            u'name': rule_name,
            u'search': 'cpu_count = 5',
            u'organization-ids': self.org['id'],
            u'location-ids': self.loc['id'],
            u'hostgroup-id': self.hostgroup['id'],
        })
        rule = DiscoveryRule.with_user(
            self.user['login'],
            self.user['password']
        ).info({u'id': rule['id']})
        self.assertEqual(rule['name'], rule_name)
예제 #3
0
    def test_positive_update_org_loc(self):
        """Update org and location of selected discovery rule

        :id: 26da79aa-30e5-4052-98ae-141de071a68a

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

        :BZ: 1377990

        :CaseLevel: Integration
        """
        new_org = make_org()
        new_loc = make_location()
        new_hostgroup = make_hostgroup({
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
        })
        rule = self._make_discoveryrule()
        DiscoveryRule.update({
            'id': rule['id'],
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
            'hostgroup-id': new_hostgroup['id'],
        })
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertIn(new_org['name'], rule['organizations'])
        self.assertIn(new_loc['name'], rule['locations'])
예제 #4
0
    def test_positive_create_rule_with_non_admin_user(self):
        """Create rule with non-admin user by associating discovery_manager role

        :id: 056535aa-3338-4c1e-8a4b-ebfc8bd6e456

        :expectedresults: Rule should be created successfully.

        :CaseLevel: Integration
        """
        rule_name = gen_string('alpha')
        rule = DiscoveryRule.with_user(self.user['login'],
                                       self.user['password']).create({
                                           u'name':
                                           rule_name,
                                           u'search':
                                           'cpu_count = 5',
                                           u'organization-ids':
                                           self.org['id'],
                                           u'location-ids':
                                           self.loc['id'],
                                           u'hostgroup-id':
                                           self.hostgroup['id'],
                                       })
        rule = DiscoveryRule.with_user(self.user['login'],
                                       self.user['password']).info(
                                           {u'id': rule['id']})
        self.assertEqual(rule['name'], rule_name)
예제 #5
0
    def test_negative_delete_rule_with_non_admin_user(self):
        """Delete rule with non-admin user by associating discovery_reader role

        :id: f7f9569b-916e-46f3-bd89-a05e33483741

        :expectedresults: User should validation error and rule should not be
            deleted successfully.

        :CaseLevel: Integration
        """
        rule = make_discoveryrule({
            u'enabled': 'false',
            u'search': "last_report = Today",
            u'organization-ids': self.org['id'],
            u'location-ids': self.loc['id'],
            u'hostgroup-id': self.hostgroup['id'],
        })
        rule = DiscoveryRule.with_user(
            self.user_reader['login'],
            self.user_reader['password']
        ).info({u'id': rule['id']})
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.with_user(
                self.user_reader['login'],
                self.user_reader['password']
            ).delete({u'id': rule['id']})
예제 #6
0
    def test_positive_update_org_loc_by_id(self, discoveryrule_factory):
        """Update org and location of selected discovery rule using org/loc ids

        :id: 26da79aa-30e5-4052-98ae-141de071a68a

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

        :BZ: 1377990

        :CaseLevel: Component
        """
        new_org = AttrDict(make_org())
        new_loc = AttrDict(make_location())
        new_hostgroup = AttrDict(
            make_hostgroup({
                'organization-ids': new_org.id,
                'location-ids': new_loc.id
            }))
        rule = discoveryrule_factory()
        DiscoveryRule.update({
            'id': rule.id,
            'organization-ids': new_org.id,
            'location-ids': new_loc.id,
            'hostgroup-id': new_hostgroup.id,
        })
        rule = AttrDict(DiscoveryRule.info({'id': rule.id}))
        assert new_org.name in rule.organizations
        assert new_loc.name in rule.locations
예제 #7
0
    def test_positive_update_org_loc_by_name(self, discoveryrule_factory):
        """Update org and location of selected discovery rule using org/loc
        names

        :id: 7a5d61ac-6a2d-48f6-a00d-df437a7dc3c4

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

        :BZ: 1377990

        :CaseLevel: Component

        :CaseImportance: Medium
        """
        new_org = AttrDict(make_org())
        new_loc = AttrDict(make_location())
        new_hostgroup = AttrDict(
            make_hostgroup({
                'organization-ids': new_org.id,
                'location-ids': new_loc.id
            }))
        rule = discoveryrule_factory()
        DiscoveryRule.update({
            'id': rule.id,
            'organizations': new_org.name,
            'locations': new_loc.name,
            'hostgroup-id': new_hostgroup.id,
        })
        rule = AttrDict(DiscoveryRule.info({'id': rule.id}))
        assert new_org.name in rule.organizations
        assert new_loc.name in rule.locations
예제 #8
0
    def test_positive_create_rule_with_non_admin_user(self, class_org,
                                                      class_location,
                                                      class_user_password,
                                                      class_user_manager,
                                                      class_hostgroup):
        """Create rule with non-admin user by associating discovery_manager role

        :id: 056535aa-3338-4c1e-8a4b-ebfc8bd6e456

        :expectedresults: Rule should be created successfully.

        :CaseLevel: Integration
        """
        rule_name = gen_string('alpha')
        rule = AttrDict(
            DiscoveryRule.with_user(class_user_manager.login,
                                    class_user_password).create({
                                        'name':
                                        rule_name,
                                        'search':
                                        'cpu_count = 5',
                                        'organizations':
                                        class_org.name,
                                        'locations':
                                        class_location.name,
                                        'hostgroup-id':
                                        class_hostgroup.id,
                                    }))
        rule = AttrDict(
            DiscoveryRule.with_user(class_user_manager.login,
                                    class_user_password).info({'id': rule.id}))
        assert rule.name == rule_name
예제 #9
0
    def test_negative_delete_rule_with_non_admin_user(self, class_org,
                                                      class_location,
                                                      class_user_password,
                                                      class_user_reader,
                                                      class_hostgroup):
        """Delete rule with non-admin user by associating discovery_reader role

        :id: f7f9569b-916e-46f3-bd89-a05e33483741

        :expectedresults: User should validation error and rule should not be
            deleted successfully.

        :CaseLevel: Integration
        """
        rule = AttrDict(
            make_discoveryrule({
                'enabled': 'false',
                'search': "last_report = Today",
                'organizations': class_org.name,
                'locations': class_location.name,
                'hostgroup-id': class_hostgroup.id,
            }))
        rule = AttrDict(
            DiscoveryRule.with_user(class_user_reader.login,
                                    class_user_password).info({'id': rule.id}))
        with pytest.raises(CLIReturnCodeError):
            DiscoveryRule.with_user(class_user_reader.login,
                                    class_user_password).delete(
                                        {'id': rule.id})
예제 #10
0
    def test_negative_update_hostname(self):
        """Update discovery rule host name using number as a value

        @id: c382dbc7-9509-4060-9038-1617f7fef038

        @Assert: Rule host name is not updated
        """
        rule = self._make_discoveryrule()
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.update({'id': rule['id'], 'hostname': '$#@!*'})
예제 #11
0
    def test_negative_update_limit(self):
        """Update discovery rule host limit using invalid values

        @id: e3257d8a-91b9-406f-bd74-0fd1fb05bb77

        @Assert: Rule host limit is not updated
        """
        rule = self._make_discoveryrule()
        host_limit = gen_string('alpha')
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.update({'id': rule['id'], 'hosts-limit': host_limit})
예제 #12
0
    def test_negative_update_priority(self):
        """Update discovery rule priority using invalid values

        @id: 0778dd00-aa19-4062-bdf3-752e1b546ec2

        @Assert: Rule priority is not updated
        """
        rule = self._make_discoveryrule()
        priority = gen_string('alpha')
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.update({'id': rule['id'], 'priority': priority})
예제 #13
0
    def test_positive_delete(self):
        """Delete existing Discovery Rule

        @id: c9b88a94-13c4-496f-a5c1-c088187250dc

        @Assert: Rule should be successfully deleted
        """
        rule = self._make_discoveryrule()
        DiscoveryRule.delete({u'id': rule['id']})
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.info({u'id': rule['id']})
예제 #14
0
    def test_negative_update_hostname(self):
        """Update discovery rule host name using number as a value

        :id: c382dbc7-9509-4060-9038-1617f7fef038

        :expectedresults: Rule host name is not updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule()
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.update({'id': rule['id'], 'hostname': '$#@!*'})
예제 #15
0
    def test_negative_update_hostname(self):
        """Update discovery rule host name using number as a value

        :id: c382dbc7-9509-4060-9038-1617f7fef038

        :expectedresults: Rule host name is not updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule()
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.update({'id': rule['id'], 'hostname': '$#@!*'})
예제 #16
0
    def test_positive_update_priority(self):
        """Update discovery rule priority value

        @id: 0543cc73-c692-4bbf-818b-37353ec98986

        @Assert: Rule priority is updated
        """
        rule = self._make_discoveryrule({u'priority': 100})
        new_priority = '1'
        DiscoveryRule.update({'id': rule['id'], 'priority': new_priority})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['priority'], new_priority)
예제 #17
0
    def test_negative_update_name(self):
        """Update discovery rule name using invalid names only

        @id: 8293cc6a-d983-460a-b76e-221ad02b54b7

        @Assert: Rule name is not updated
        """
        rule = self._make_discoveryrule()
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIReturnCodeError):
                    DiscoveryRule.update({'id': rule['id'], 'name': name})
예제 #18
0
    def test_positive_update_limit(self):
        """Update discovery rule limit value

        @id: efa6f5bc-4d56-4449-90f5-330affbcfb09

        @Assert: Rule host limit field is updated
        """
        rule = self._make_discoveryrule({u'hosts-limit': '5'})
        new_limit = '10'
        DiscoveryRule.update({'id': rule['id'], 'hosts-limit': new_limit})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['hosts-limit'], new_limit)
예제 #19
0
    def test_positive_update_query(self):
        """Update discovery rule search query

        @id: 86943095-acc5-40ff-8e3c-88c76b36333d

        @Assert: Rule search field is updated
        """
        rule = self._make_discoveryrule()
        new_query = 'model = KVM'
        DiscoveryRule.update({'id': rule['id'], 'search': new_query})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['search'], new_query)
예제 #20
0
    def test_positive_update_hostname(self):
        """Update discovery rule hostname value

        @id: 4c123488-92df-42f6-afe3-8a88cd90ffc2

        @Assert: Rule host name is updated
        """
        new_hostname = gen_string('alpha')
        rule = self._make_discoveryrule()
        DiscoveryRule.update({'id': rule['id'], 'hostname': new_hostname})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['hostname-template'], new_hostname)
예제 #21
0
    def test_positive_update_disable_enable(self):
        """Update discovery rule enabled state. (Disabled->Enabled)

        @id: 64e8b21b-2ab0-49c3-a12d-02dbdb36647a

        @Assert: Rule is successfully enabled
        """
        rule = self._make_discoveryrule({u'enabled': 'false'})
        self.assertEqual(rule['enabled'], 'false')
        DiscoveryRule.update({'id': rule['id'], 'enabled': 'true'})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['enabled'], 'true')
예제 #22
0
    def test_positive_update_name(self):
        """Update discovery rule name

        @id: 1045e2c4-e1f7-42c9-95f7-488fc79bf70b

        @Assert: Rule name is updated
        """
        rule = self._make_discoveryrule()
        new_name = gen_string('numeric')
        DiscoveryRule.update({'id': rule['id'], 'name': new_name})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['name'], new_name)
예제 #23
0
    def test_positive_delete(self):
        """Delete existing Discovery Rule

        :id: c9b88a94-13c4-496f-a5c1-c088187250dc

        :expectedresults: Rule should be successfully deleted

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule()
        DiscoveryRule.delete({u'id': rule['id']})
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.info({u'id': rule['id']})
예제 #24
0
    def test_positive_delete(self):
        """Delete existing Discovery Rule

        :id: c9b88a94-13c4-496f-a5c1-c088187250dc

        :expectedresults: Rule should be successfully deleted

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule()
        DiscoveryRule.delete({u'id': rule['id']})
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.info({u'id': rule['id']})
예제 #25
0
    def test_positive_delete(self, discoveryrule_factory):
        """Delete existing Discovery Rule

        :id: c9b88a94-13c4-496f-a5c1-c088187250dc

        :expectedresults: Rule should be successfully deleted

        :CaseImportance: Critical
        """
        rule = discoveryrule_factory()
        DiscoveryRule.delete({'id': rule.id})
        with pytest.raises(CLIReturnCodeError):
            DiscoveryRule.info({'id': rule.id})
예제 #26
0
    def test_positive_update_name(self):
        """Update discovery rule name

        :id: 1045e2c4-e1f7-42c9-95f7-488fc79bf70b

        :expectedresults: Rule name is updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule()
        new_name = gen_string('numeric')
        DiscoveryRule.update({'id': rule['id'], 'name': new_name})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['name'], new_name)
예제 #27
0
    def test_positive_update_disable_enable(self):
        """Update discovery rule enabled state. (Disabled->Enabled)

        :id: 64e8b21b-2ab0-49c3-a12d-02dbdb36647a

        :expectedresults: Rule is successfully enabled

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule({u'enabled': 'false'})
        self.assertEqual(rule['enabled'], 'false')
        DiscoveryRule.update({'id': rule['id'], 'enabled': 'true'})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['enabled'], 'true')
예제 #28
0
    def test_positive_update_priority(self):
        """Update discovery rule priority value

        :id: 0543cc73-c692-4bbf-818b-37353ec98986

        :expectedresults: Rule priority is updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule({u'priority': 100})
        new_priority = '1'
        DiscoveryRule.update({'id': rule['id'], 'priority': new_priority})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['priority'], new_priority)
예제 #29
0
    def test_positive_update_priority(self):
        """Update discovery rule priority value

        :id: 0543cc73-c692-4bbf-818b-37353ec98986

        :expectedresults: Rule priority is updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule({u'priority': 100})
        new_priority = '1'
        DiscoveryRule.update({'id': rule['id'], 'priority': new_priority})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['priority'], new_priority)
예제 #30
0
    def test_positive_update_limit(self):
        """Update discovery rule limit value

        :id: efa6f5bc-4d56-4449-90f5-330affbcfb09

        :expectedresults: Rule host limit field is updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule({u'hosts-limit': '5'})
        new_limit = '10'
        DiscoveryRule.update({'id': rule['id'], 'hosts-limit': new_limit})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['hosts-limit'], new_limit)
예제 #31
0
    def test_positive_update_hostname(self):
        """Update discovery rule hostname value

        :id: 4c123488-92df-42f6-afe3-8a88cd90ffc2

        :expectedresults: Rule host name is updated

        :CaseImportance: Critical
        """
        new_hostname = gen_string('alpha')
        rule = self._make_discoveryrule()
        DiscoveryRule.update({'id': rule['id'], 'hostname': new_hostname})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['hostname-template'], new_hostname)
예제 #32
0
    def test_positive_update_query(self):
        """Update discovery rule search query

        :id: 86943095-acc5-40ff-8e3c-88c76b36333d

        :expectedresults: Rule search field is updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule()
        new_query = 'model = KVM'
        DiscoveryRule.update({'id': rule['id'], 'search': new_query})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['search'], new_query)
예제 #33
0
    def test_positive_update_disable_enable(self):
        """Update discovery rule enabled state. (Disabled->Enabled)

        :id: 64e8b21b-2ab0-49c3-a12d-02dbdb36647a

        :expectedresults: Rule is successfully enabled

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule({u'enabled': 'false'})
        self.assertEqual(rule['enabled'], 'false')
        DiscoveryRule.update({'id': rule['id'], 'enabled': 'true'})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['enabled'], 'true')
예제 #34
0
    def test_positive_update_limit(self):
        """Update discovery rule limit value

        :id: efa6f5bc-4d56-4449-90f5-330affbcfb09

        :expectedresults: Rule host limit field is updated

        :CaseImportance: Critical
        """
        rule = self._make_discoveryrule({u'hosts-limit': '5'})
        new_limit = '10'
        DiscoveryRule.update({'id': rule['id'], 'hosts-limit': new_limit})
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['hosts-limit'], new_limit)
예제 #35
0
    def test_negative_update_hostname(self, discoveryrule_factory):
        """Update discovery rule host name using number as a value

        :id: c382dbc7-9509-4060-9038-1617f7fef038

        :expectedresults: Rule host name is not updated

        :CaseImportance: Medium

        :CaseLevel: Component
        """
        rule = discoveryrule_factory()
        with pytest.raises(CLIReturnCodeError):
            DiscoveryRule.update({'id': rule.id, 'hostname': '$#@!*'})
예제 #36
0
    def test_positive_update_limit(self, discoveryrule_factory):
        """Update discovery rule limit value

        :id: efa6f5bc-4d56-4449-90f5-330affbcfb09

        :expectedresults: Rule host limit field is updated

        :CaseLevel: Component
        """
        rule = discoveryrule_factory(options={'hosts-limit': '5'})
        new_limit = '10'
        DiscoveryRule.update({'id': rule.id, 'hosts-limit': new_limit})
        rule = AttrDict(DiscoveryRule.info({'id': rule.id}))
        assert rule['hosts-limit'] == new_limit
예제 #37
0
    def test_positive_update_disable_enable(self, discoveryrule_factory):
        """Update discovery rule enabled state. (Disabled->Enabled)

        :id: 64e8b21b-2ab0-49c3-a12d-02dbdb36647a

        :expectedresults: Rule is successfully enabled

        :CaseImportance: Critical
        """
        rule = discoveryrule_factory(options={'enabled': 'false'})
        assert rule.enabled == 'false'
        DiscoveryRule.update({'id': rule.id, 'enabled': 'true'})
        rule = AttrDict(DiscoveryRule.info({'id': rule.id}))
        assert rule.enabled == 'true'
예제 #38
0
    def test_positive_update_hostname(self, discoveryrule_factory):
        """Update discovery rule hostname value

        :id: 4c123488-92df-42f6-afe3-8a88cd90ffc2

        :expectedresults: Rule host name is updated

        :CaseLevel: Component
        """
        new_hostname = gen_string('alpha')
        rule = discoveryrule_factory()
        DiscoveryRule.update({'id': rule.id, 'hostname': new_hostname})
        rule = AttrDict(DiscoveryRule.info({'id': rule.id}))
        assert rule['hostname-template'] == new_hostname
예제 #39
0
    def test_positive_update_query(self, discoveryrule_factory):
        """Update discovery rule search query

        :id: 86943095-acc5-40ff-8e3c-88c76b36333d

        :expectedresults: Rule search field is updated

        :CaseLevel: Component
        """
        rule = discoveryrule_factory()
        new_query = 'model = KVM'
        DiscoveryRule.update({'id': rule.id, 'search': new_query})
        rule = AttrDict(DiscoveryRule.info({'id': rule.id}))
        assert rule.search == new_query
예제 #40
0
    def test_positive_update_hostgroup(self):
        """Update discovery rule host group

        @id: 07992a3f-2aa9-4e45-b2e8-ef3d2f255292

        @Assert: Rule host group is updated
        """
        new_hostgroup = make_hostgroup({u'organization-ids': self.org['id']})
        rule = self._make_discoveryrule()
        DiscoveryRule.update({
            'id': rule['id'],
            'hostgroup': new_hostgroup['name']
        })
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertEqual(rule['host-group'], new_hostgroup['name'])
예제 #41
0
    def test_positive_view_existing_rule_with_non_admin_user(self):
        """Existing rule should be viewed to non-admin user by associating
        discovery_reader role.

        :id: 7b1d90b9-fc2d-4ccb-93d3-605c2da876f7

        :Steps:

            1. create a rule with admin user
            2. create a non-admin user and assign 'Discovery Reader' role
            3. Login with non-admin user

        :expectedresults: Rule should be visible to non-admin user.

        :CaseLevel: Integration
        """
        rule_name = gen_string('alpha')
        rule = make_discoveryrule({
            u'name': rule_name,
            u'enabled': 'false',
            u'search': "last_report = Today",
            u'organization-ids': self.org['id'],
            u'location-ids': self.loc['id'],
            u'hostgroup-id': self.hostgroup['id'],
        })
        rule = DiscoveryRule.with_user(
            self.user_reader['login'],
            self.user_reader['password']
        ).info({u'id': rule['id']})
        self.assertEqual(rule['name'], rule_name)
예제 #42
0
    def test_positive_update_org_loc(self):
        """Update org and location of selected discovery rule

        @id: 26da79aa-30e5-4052-98ae-141de071a68a

        @Assert: Rule was updated and with given org & location.

        @CaseLevel: Integration
        """
        new_org = make_org()
        new_loc = make_location()
        rule = self._make_discoveryrule()
        DiscoveryRule.update({
            'id': rule['id'],
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
        })
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertIn(rule['organizations'], new_org['name'])
        self.assertIn(rule['locations'], new_loc['name'])
예제 #43
0
    def test_positive_delete_rule_with_non_admin_user(self):
        """Delete rule with non-admin user by associating discovery_manager role

        :id: 87ab969b-7d92-478d-a5c0-1c0d50e9bdd6

        :expectedresults: Rule should be deleted successfully.

        :CaseLevel: Integration
        """
        rule_name = gen_string('alpha')
        rule = DiscoveryRule.with_user(
            self.user['login'],
            self.user['password']
        ).create({
            u'name': rule_name,
            u'search': 'cpu_count = 5',
            u'organization-ids': self.org['id'],
            u'location-ids': self.loc['id'],
            u'hostgroup-id': self.hostgroup['id'],
        })
        rule = DiscoveryRule.with_user(
            self.user['login'],
            self.user['password']
        ).info({u'id': rule['id']})
        DiscoveryRule.with_user(
            self.user['login'],
            self.user['password'],
        ).delete({u'id': rule['id']})
        with self.assertRaises(CLIReturnCodeError):
            DiscoveryRule.info({u'id': rule['id']})