def test_positive_add_host_by_name(self):
        """Check if content host can be added to host collection by name

        :id: fe468f76-4693-4509-b534-126fce187194

        :customerscenario: true

        :expectedresults: Host collection is created and content-host is added

        :CaseLevel: Integration
        """
        new_host_col = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_system = self._make_fake_host_helper()
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'hosts': new_system['name'],
            u'name': new_host_col['name'],
            u'organization': self.organization['name'],
        })
        result = HostCollection.info({
            u'name': new_host_col['name'],
            u'organization': self.organization['name'],
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
    def test_positive_list_by_host_id(self):
        """Check if host collection list can be filtered by associated host id

        :id: de272461-9804-4524-83c8-23e47abfc8e3

        :expectedresults: Only host-collection with specific host is listed

        :CaseLevel: Integration

        :BZ: 1379372
        """
        # Create two host collections within the same org but only one with
        # associated host that will be used for filtering
        host_col = make_host_collection({
            'organization-id': self.organization['id'],
        })
        make_host_collection({'organization-id': self.organization['id']})
        host = self._make_fake_host_helper()
        HostCollection.add_host({
            'host-ids': host['id'],
            'id': host_col['id'],
        })
        host_col = HostCollection.info({
            'id': host_col['id'],
        })
        self.assertEqual(host_col['total-hosts'], '1')
        # List all host collections within organization
        result = HostCollection.list({
            'organization-id': self.organization['id']})
        self.assertGreaterEqual(len(result), 2)
        # Filter list by associated host id
        result = HostCollection.list({'host-id': host['id']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
    def test_positive_list_by_name(self):
        """Check if host collection list can be filtered by name

        :id: 2d611a48-1e51-49b5-8f20-81b09f96c542

        :expectedresults: Only host-collection with specific name is listed

        :CaseLevel: Integration
        """
        host_col_name = gen_string('alpha')
        # Create two host collections within the same org
        host_col = make_host_collection({
            'name': host_col_name,
            'organization-id': self.organization['id'],
        })
        make_host_collection({'organization-id': self.organization['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by name
        result = HostCollection.list({
            'name': host_col_name,
            'organization-id': self.organization['id'],
        })
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
    def test_positive_copy_by_name(self):
        """Check if host collection can be cloned by name

        :id: ca9be8de-ea9a-4890-8890-a1809a85a4ff

        :customerscenario: true

        :expectedresults: Host collection is cloned successfully

        :BZ: 1328925

        :CaseLevel: Integration
        """
        host_collection = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_name = gen_string('numeric')
        new_host_collection = HostCollection.copy({
            u'name': host_collection['name'],
            u'new-name': new_name,
            u'organization-label': self.organization['label'],
        })
        result = HostCollection.info({
            u'id': new_host_collection[0]['id'],
        })
        self.assertEqual(result['name'], new_name)
    def test_positive_copy_by_id(self):
        """Check if host collection can be cloned by id

        :id: fd7cea50-bc56-4938-a81d-4f7a60711814

        :customerscenario: true

        :expectedresults: Host collection is cloned successfully

        :BZ: 1328925

        :CaseLevel: Integration
        """
        host_collection = make_host_collection({
            'name': gen_string('alpha', 15),
            'organization-id': self.organization['id'],
        })
        new_name = gen_string('numeric')
        new_host_collection = HostCollection.copy({
            u'id': host_collection['id'],
            u'new-name': new_name,
        })
        result = HostCollection.info({
            u'id': new_host_collection[0]['id'],
        })
        self.assertEqual(result['name'], new_name)
    def test_positive_add_host_by_id(self):
        """Check if content host can be added to host collection

        @Feature: Host Collection

        @Assert: Host collection is created and content-host is added

        """
        new_host_col = self._new_host_collection({
            'name': gen_string('alpha', 15)})
        new_system = make_content_host({
            u'content-view-id': self.default_cv['id'],
            u'lifecycle-environment-id': self.library['id'],
            u'name': gen_string('alpha', 15),
            u'organization-id': self.org['id'],
        })
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'hosts': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
Beispiel #7
0
    def test_remove_content_host(self):
        """@Test: Check if content host can be removed from host collection

        @Feature: Host Collection

        @Assert: Host collection is created and content-host is removed

        """

        host_col_name = generate_string('alpha', 15)
        content_host_name = generate_string('alpha', 15)

        try:
            new_host_col = self._new_host_collection({'name': host_col_name})
            new_system = make_content_host({
                u'name': content_host_name,
                u'organization-id': self.org['id'],
                u'content-view-id': self.default_cv['id'],
                u'lifecycle-environment-id': self.library['id']})
        except CLIFactoryError as err:
            self.fail(err)

        result = HostCollection.add_content_host({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
            u'content-host-ids': new_system['id']
        })
        self.assertEqual(result.return_code, 0,
                         "Content Host not added to host collection")
        self.assertEqual(len(result.stderr), 0,
                         "No error was expected")

        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })

        no_of_content_host = result.stdout['total-content-hosts']

        result = HostCollection.remove_content_host({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
            u'content-host-ids': new_system['id']
        })
        self.assertEqual(result.return_code, 0,
                         "Content Host not removed host collection")
        self.assertEqual(len(result.stderr), 0,
                         "No error was expected")

        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })
        self.assertEqual(
            result.return_code, 0, 'Failed to get info for host collection')
        self.assertEqual(
            len(result.stderr), 0, 'There should not be an error here')
        self.assertGreater(no_of_content_host,
                           result.stdout['total-content-hosts'],
                           "There should not be an exception here")
    def test_positive_list_chosts(self):
        """Check if content hosts added to host collection is listed

        @Feature: Host Collection

        @Assert: Content-host added to host-collection is listed

        """
        host_col_name = gen_string("alpha", 15)
        new_host_col = self._new_host_collection({"name": host_col_name})
        new_system = make_content_host(
            {
                u"content-view-id": self.default_cv["id"],
                u"lifecycle-environment-id": self.library["id"],
                u"name": gen_string("alpha", 15),
                u"organization-id": self.org["id"],
            }
        )
        no_of_content_host = new_host_col["total-content-hosts"]
        HostCollection.add_content_host(
            {u"content-host-ids": new_system["id"], u"id": new_host_col["id"], u"organization-id": self.org["id"]}
        )
        result = HostCollection.info({u"id": new_host_col["id"], u"organization-id": self.org["id"]})
        self.assertGreater(result["total-content-hosts"], no_of_content_host)
        result = HostCollection.content_hosts({u"name": host_col_name, u"organization-id": self.org["id"]})
        self.assertEqual(new_system["id"], result[0]["id"])
    def test_positive_list_hosts(self):
        """Check if content hosts added to host collection is listed

        @Feature: Host Collection

        @Assert: Content-host added to host-collection is listed

        """
        host_col_name = gen_string('alpha', 15)
        new_host_col = self._new_host_collection({'name': host_col_name})
        new_system = make_content_host({
            u'content-view-id': self.default_cv['id'],
            u'lifecycle-environment-id': self.library['id'],
            u'name': gen_string('alpha', 15),
            u'organization-id': self.org['id'],
        })
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'hosts': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
        result = HostCollection.content_hosts({
            u'name': host_col_name,
            u'organization-id': self.org['id']
        })
        self.assertEqual(new_system['id'], result[0]['id'])
Beispiel #10
0
    def test_positive_update_3(self, test_data):
        """@Test: Check if host collection limits be updated

        @Feature: Host Collection

        @Assert: Host collection limits is updated

        @BZ: 1245334

        """

        new_host_col = self._new_host_collection()

        # Update sync interval
        result = HostCollection.update({
            'id': new_host_col['id'],
            'organization-id': self.org['id'],
            'max-content-hosts': test_data
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it
        result = HostCollection.info({
            'id': new_host_col['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        # Assert that limit was updated
        self.assertEqual(result.stdout['limit'], test_data)
        self.assertNotEqual(
            new_host_col['limit'],
            result.stdout['limit']
        )
Beispiel #11
0
    def test_positive_update_1(self, test_data):
        """@Test: Check if host collection name can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and name is updated

        """

        new_host_col = self._new_host_collection()
        # Assert that name does not matches data passed
        self.assertNotEqual(new_host_col['name'], test_data['name'])

        # Update host collection
        result = HostCollection.update({
            'id': new_host_col['id'],
            'organization-id': self.org['id'],
            'name': test_data['name']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it
        result = HostCollection.info({
            'id': new_host_col['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        # Assert that name matches new value
        self.assertIsNotNone(result.stdout.get('name', None))
        self.assertEqual(result.stdout['name'], test_data['name'])
        # Assert that name does not match original value
        self.assertNotEqual(new_host_col['name'], result.stdout['name'])
Beispiel #12
0
    def test_positive_delete_1(self, test_data):
        """@Test: Check if host collection can be created and deleted

        @Feature: Host Collection

        @Assert: Host collection is created and then deleted

        """

        new_host_col = self._new_host_collection({'name': test_data['name']})
        # Assert that name matches data passed
        self.assertEqual(new_host_col['name'], test_data['name'])

        # Delete it
        result = HostCollection.delete(
            {'id': new_host_col['id'],
             'organization-id': self.org['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it
        result = HostCollection.info(
            {
                'id': new_host_col['id'],
            }
        )
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
    def test_positive_list_hosts(self):
        """Check if content hosts added to host collection is listed

        @id: 3075cb97-8448-4358-8ffc-0d5cd0078ca3

        @Assert: Content-host added to host-collection is listed

        @CaseLevel: Integration
        """
        host_col_name = gen_string('alpha', 15)
        new_host_col = self._new_host_collection({'name': host_col_name})
        new_system = self._make_content_host_helper()
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
        result = HostCollection.hosts({
            u'name': host_col_name,
            u'organization-id': self.org['id']
        })
        self.assertEqual(new_system['name'].lower(), result[0]['name'])
    def test_positive_host_collection_host_pagination(self):
        """Check if pagination configured on per-page param defined in hammer
        host-collection hosts command overrides global configuration defined
        on /etc/hammer/cli_config.yml, which default is 20 per page

        @BZ: 1343583

        @id: bbe1108b-bfb2-4a03-94ef-8fd1b5a0ec82

        @Assert: Number of host per page follows per_page configuration
        restriction

        @CaseLevel: Integration
        """
        host_collection = self._new_host_collection({
            'name': gen_string('alpha', 15)
        })
        host_ids = ','.join(
            self._make_content_host_helper()['id'] for i in range(2)
        )
        HostCollection.add_host({
            u'host-ids': host_ids,
            u'id': host_collection['id'],
            u'organization-id': self.org['id'],
        })

        for number in range(1, 3):
            listed_hosts = HostCollection.hosts({
                u'id': host_collection['id'],
                u'organization-id': self.org['id'],
                u'per-page': number
            })
            self.assertEqual(len(listed_hosts), number)
    def test_positive_delete_by_name(self):
        """Check if host collection can be created and deleted by name

        :id: a841a9f8-4285-40e5-9670-3f379dfd9a1e

        :customerscenario: true

        :expectedresults: Host collection is created and then deleted

        :BZ: 1328925

        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                new_host_col = make_host_collection({
                    'name': name,
                    'organization-id': self.organization['id'],
                })
                HostCollection.delete({
                    'name': new_host_col['name'],
                    'organization-id': self.organization['id'],
                })
                with self.assertRaises(CLIReturnCodeError):
                    HostCollection.info({'id': new_host_col['id']})
Beispiel #16
0
    def test_positive_update_2(self, test_data):
        """
        @Test: Check if host collection description can be updated
        @Feature: Host Collection
        @Assert: Host collection is created and description is updated
        @BZ: 1084240
        """

        new_host_col = self._new_host_collection()
        # Assert that description does not match data passed
        self.assertNotEqual(
            new_host_col['description'],
            test_data['description'],
            "Descriptions should not match"
        )

        # Update sync plan
        result = HostCollection.update(
            {
                'id': new_host_col['id'],
                'organization-id': self.org['id'],
                'description': test_data['description']
            }
        )
        self.assertEqual(
            result.return_code,
            0,
            "Host collection was not updated")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Fetch it
        result = HostCollection.info(
            {
                'id': new_host_col['id'],
            }
        )
        self.assertEqual(
            result.return_code,
            0,
            "Host collection was not updated")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")
        # Assert that description matches new value
        self.assertIsNotNone(
            result.stdout.get('description', None),
            "The description field was not returned"
        )
        self.assertEqual(
            result.stdout['description'],
            test_data['description'],
            "Descriptions should match"
        )
        # Assert that description does not matches original value
        self.assertNotEqual(
            new_host_col['description'],
            result.stdout['description'],
            "Descriptions should not match"
        )
Beispiel #17
0
    def test_positive_update_3(self, test_data):
        """@Test: Check if host collection limits be updated

        @Feature: Host Collection

        @Assert: Host collection limits is updated

        @BZ: 1084240

        """

        new_host_col = self._new_host_collection()

        # Update sync interval
        result = HostCollection.update(
            {
                'id': new_host_col['id'],
                'organization-id': self.org['id'],
                'max-content-hosts': test_data
            }
        )
        self.assertEqual(
            result.return_code,
            0,
            "Host collection was not updated")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Fetch it
        result = HostCollection.info(
            {
                'id': new_host_col['id'],
            }
        )
        self.assertEqual(
            result.return_code,
            0,
            "Host collection was not updated")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")
        # Assert that limit was updated
        self.assertEqual(
            result.stdout['max-content-hosts'],
            test_data,
            "Limits don't match"
        )
        self.assertNotEqual(
            new_host_col['max-content-hosts'],
            result.stdout['max-content-hosts'],
            "Limits don't match"
        )
    def test_positive_delete_by_id(self):
        """Check if host collection can be created and deleted

        @Feature: Host Collection

        @Assert: Host collection is created and then deleted

        """
        for name in valid_data_list():
            with self.subTest(name):
                new_host_col = self._new_host_collection({"name": name})
                HostCollection.delete({"id": new_host_col["id"], "organization-id": self.org["id"]})
                with self.assertRaises(CLIReturnCodeError):
                    HostCollection.info({"id": new_host_col["id"]})
    def test_positive_update_name(self):
        """Check if host collection name can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and name is updated

        """
        new_host_col = self._new_host_collection()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                HostCollection.update({"id": new_host_col["id"], "name": new_name, "organization-id": self.org["id"]})
                result = HostCollection.info({"id": new_host_col["id"]})
                self.assertEqual(result["name"], new_name)
Beispiel #20
0
    def test_positive_create_with_unlimited_hosts(self):
        """Create Host Collection with different values of
        unlimited-hosts parameter

        @Feature: Host Collection - Unlimited Hosts

        @Assert: Host Collection is created and unlimited-hosts
        parameter is set

        @BZ: 1214675

        """
        for unlimited in (u'True', u'Yes', 1, u'False', u'No', 0):
            with self.subTest(unlimited):
                host_collection = make_host_collection({
                    u'organization-id': self.org['id'],
                    u'unlimited-hosts': unlimited,
                })
                result = HostCollection.info({
                    u'id': host_collection['id'],
                    u'organization-id': self.org['id'],
                })
                if unlimited in (u'True', u'Yes', 1):
                    self.assertEqual(
                        result['unlimited-hosts'], u'true')
                else:
                    self.assertEqual(
                        result['unlimited-hosts'], u'false')
Beispiel #21
0
def test_positive_create_with_unlimited_hosts(module_org):
    """Create Host Collection with different values of unlimited-hosts
    parameter

    :id: d688fd4a-88eb-484e-9e90-854e0595edd0

    :expectedresults: Host Collection is created and unlimited-hosts
        parameter is set

    :CaseImportance: Critical
    """
    for unlimited in ('True', 'Yes', 1, 'False', 'No', 0):
        host_collection = make_host_collection(
            {
                'max-hosts': 1 if unlimited in ('False', 'No', 0) else None,
                'organization-id': module_org.id,
                'unlimited-hosts': unlimited,
            }
        )
        result = HostCollection.info(
            {'name': host_collection['name'], 'organization-id': module_org.id}
        )
        if unlimited in ('True', 'Yes', 1):
            assert result['limit'] == 'None'
        else:
            assert result['limit'] == '1'
    def test_positive_update_description(self):
        """Check if host collection description can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and description is updated

        """
        new_host_col = self._new_host_collection()
        for desc in valid_data_list():
            with self.subTest(desc):
                HostCollection.update(
                    {"description": desc, "id": new_host_col["id"], "organization-id": self.org["id"]}
                )
                result = HostCollection.info({"id": new_host_col["id"]})
                self.assertEqual(result["description"], desc)
Beispiel #23
0
    def test_create_hc_with_unlimited_content_hosts(self, unlimited):
        """@Test: Create Host Collection with different values of
        unlimited-content-hosts parameter

        @Feature: Host Collection - Unlimited Content Hosts

        @Assert: Host Collection is created and unlimited-content-hosts
        parameter is set

        @BZ: 1214675

        """
        try:
            host_collection = make_host_collection({
                u'organization-id': self.org['id'],
                u'unlimited-content-hosts': unlimited,
            })
        except CLIFactoryError as err:
            self.fail(err)
        result = HostCollection.info({
            u'id': host_collection['id'],
            u'organization-id': self.org['id'],
        })
        if unlimited in (u'True', u'Yes', 1):
            self.assertEqual(
                result.stdout['unlimited-content-hosts'], u'true')
        else:
            self.assertEqual(
                result.stdout['unlimited-content-hosts'], u'false')
    def test_positive_create_with_unlimited_hosts(self):
        """Create Host Collection with different values of
        unlimited-hosts parameter

        @id: d688fd4a-88eb-484e-9e90-854e0595edd0

        @Assert: Host Collection is created and unlimited-hosts
        parameter is set
        """
        for unlimited in ('True', 'Yes', 1, 'False', 'No', 0):
            with self.subTest(unlimited):
                host_collection = make_host_collection({
                    'max-hosts':
                        1 if unlimited in ('False', 'No', 0) else None,
                    'organization-id': self.org['id'],
                    'unlimited-hosts': unlimited,
                })
                result = HostCollection.info({
                    'id': host_collection['id'],
                    'organization-id': self.org['id'],
                })
                if unlimited in ('True', 'Yes', 1):
                    self.assertEqual(result['limit'], 'None')
                else:
                    self.assertEqual(result['limit'], '1')
Beispiel #25
0
    def test_positive_create_with_unlimited_hosts(self):
        """Create Host Collection with different values of
        unlimited-hosts parameter

        :id: d688fd4a-88eb-484e-9e90-854e0595edd0

        :expectedresults: Host Collection is created and unlimited-hosts
            parameter is set

        :CaseImportance: Critical
        """
        for unlimited in ('True', 'Yes', 1, 'False', 'No', 0):
            with self.subTest(unlimited):
                host_collection = make_host_collection({
                    'max-hosts':
                    1 if unlimited in ('False', 'No', 0) else None,
                    'organization-id':
                    self.org['id'],
                    'unlimited-hosts':
                    unlimited,
                })
                result = HostCollection.info({
                    'id': host_collection['id'],
                    'organization-id': self.org['id'],
                })
                if unlimited in ('True', 'Yes', 1):
                    self.assertEqual(result['limit'], 'None')
                else:
                    self.assertEqual(result['limit'], '1')
Beispiel #26
0
def test_positive_update_limit(module_org):
    """Check if host collection limits can be updated

    :id: 4c0e0c3b-82ac-4aa2-8378-6adc7946d4ec

    :expectedresults: Host collection limits is updated

    :BZ: 1245334

    :CaseImportance: Critical
    """
    new_host_col = make_host_collection({'organization-id': module_org.id})
    for limit in ('3', '6', '9', '12', '15', '17', '19'):
        HostCollection.update({'id': new_host_col['id'], 'max-hosts': limit, 'unlimited-hosts': 0})
        result = HostCollection.info({'id': new_host_col['id']})
        assert result['limit'] == limit
Beispiel #27
0
    def _new_host_collection(self, options=None):
        """Make a host collection and asserts its success"""

        if options is None:
            options = {}

        if not options.get('organization-id', None):
            options['organization-id'] = self.org['id']

        group = make_host_collection(options)

        # Fetch it
        result = HostCollection.info(
            {
                'id': group['id']
            }
        )

        self.assertEqual(
            result.return_code,
            0,
            "Host collection was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Return the host collection dictionary
        return group
Beispiel #28
0
    def test_content_hosts(self):
        """@Test: Check if content hosts added to host collection is listed

        @Feature: Host Collection

        @Assert: Content-host added to host-collection is listed

        """

        host_col_name = gen_string('alpha', 15)
        content_host_name = gen_string('alpha', 15)

        try:
            new_host_col = self._new_host_collection({'name': host_col_name})
            new_system = make_content_host({
                u'name': content_host_name,
                u'organization-id': self.org['id'],
                u'content-view-id': self.default_cv['id'],
                u'lifecycle-environment-id': self.library['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)
        no_of_content_host = new_host_col['total-content-hosts']
        result = HostCollection.add_content_host({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
            u'content-host-ids': new_system['id']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertGreater(
            result.stdout['total-content-hosts'], no_of_content_host)

        result = HostCollection.content_hosts({
            u'name': host_col_name,
            u'organization-id': self.org['id']
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_system['id'], result.stdout[0]['id'])
Beispiel #29
0
    def test_positive_delete_by_id(self):
        """Check if host collection can be created and deleted

        @Feature: Host Collection

        @Assert: Host collection is created and then deleted

        """
        for name in valid_data_list():
            with self.subTest(name):
                new_host_col = self._new_host_collection({'name': name})
                HostCollection.delete({
                    'id': new_host_col['id'],
                    'organization-id': self.org['id'],
                })
                with self.assertRaises(CLIReturnCodeError):
                    HostCollection.info({'id': new_host_col['id']})
    def test_positive_delete_1(self):
        """@Test: Check if host collection can be created and deleted

        @Feature: Host Collection

        @Assert: Host collection is created and then deleted

        """
        for name in valid_data_list():
            with self.subTest(name):
                new_host_col = self._new_host_collection({'name': name})
                HostCollection.delete({
                    'id': new_host_col['id'],
                    'organization-id': self.org['id'],
                })
                with self.assertRaises(CLIReturnCodeError):
                    HostCollection.info({'id': new_host_col['id']})
Beispiel #31
0
    def test_positive_register_host_ak_with_host_collection(self):
        """Attempt to register a host using activation key with host collection

        :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb

        :BZ: 1385814

        :expectedresults: Host successfully registered and listed in host
            collection

        :CaseLevel: System
        """
        # create a new activation key
        activation_key = make_activation_key(
            {
                'lifecycle-environment-id': self.env['id'],
                'organization-id': self.org['id'],
                'content-view-id': self.content_view['id'],
            }
        )
        hc = make_host_collection({'organization-id': self.org['id']})
        ActivationKey.add_host_collection(
            {
                'id': activation_key['id'],
                'organization-id': self.org['id'],
                'host-collection-id': hc['id'],
            }
        )
        # add the registered instance host to collection
        HostCollection.add_host(
            {'id': hc['id'], 'organization-id': self.org['id'], 'host-ids': self.host['id']}
        )
        with VirtualMachine() as client:
            client.create()
            client.install_katello_ca()
            # register the client host with the current activation key
            client.register_contenthost(self.org['name'], activation_key=activation_key['name'])
            assert client.subscribed
            # note: when registering the host, it should be automatically added
            # to the host collection
            client_host = Host.info({'name': client.hostname})
            hosts = HostCollection.hosts({'id': hc['id'], 'organization-id': self.org['id']})
            assert len(hosts) == 2
            expected_hosts_ids = {self.host['id'], client_host['id']}
            hosts_ids = {host['id'] for host in hosts}
            assert hosts_ids == expected_hosts_ids
Beispiel #32
0
    def test_reimport_host_collections_default_negative(self, test_data):
        """@test: Try to re-import all System Groups from the default data set
        (predefined source) as the Host Collections.

        @feature: Repetitive Import Host-Collections

        @assert: 3 Host Collections created, no action taken on 2nd Import

        """
        files = dict(self.default_dataset[1])
        for file_ in zip(
            ['users', 'system-groups'],
            [u'organization_id', u'org_id'],
            [u'orgs', u'hcs']
        ):
            files[file_[0]] = update_csv_values(
                files[file_[0]],
                file_[1],
                test_data[file_[2]],
                self.default_dataset[0]
            )
        # import the prerequisities
        import_org = Import.organization_with_tr_data(
            {'csv-file': files['users']}
        )
        import_hc = Import.host_collection(
            {'csv-file': files['system-groups']}
        )
        self.assertEqual(import_org[0].return_code, 0)
        self.assertEqual(import_hc.return_code, 0)
        hcollections_before = [
            HostCollection.list({'organization-id': tr['sat6']}).stdout
            for tr in import_org[1]
        ]
        self.assertNotEqual(hcollections_before, [])
        self.assertEqual(
            Import.host_collection(
                {'csv-file': files['system-groups']}
            ).return_code, 0
        )
        hcollections_after = [
            HostCollection.list({'organization-id': tr['sat6']}).stdout
            for tr in import_org[1]
        ]
        self.assertEqual(hcollections_before, hcollections_after)
    def test_positive_list_by_name(self):
        """Check if host collection list can be filtered by name

        @id: 2d611a48-1e51-49b5-8f20-81b09f96c542

        @Assert: Only host-collection with specific name is listed

        @CaseLevel: Integration
        """
        # Create two host collections within the same org
        host_col = self._new_host_collection()
        self._new_host_collection()
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by name
        result = HostCollection.list({'name': host_col['name']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
Beispiel #34
0
    def test_positive_update_name(self):
        """Check if host collection name can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and name is updated

        """
        new_host_col = self._new_host_collection()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                HostCollection.update({
                    'id': new_host_col['id'],
                    'name': new_name,
                    'organization-id': self.org['id'],
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['name'], new_name)
Beispiel #35
0
    def test_positive_list_by_name(self):
        """Check if host collection list can be filtered by name

        :id: 2d611a48-1e51-49b5-8f20-81b09f96c542

        :expectedresults: Only host-collection with specific name is listed

        :CaseLevel: Integration
        """
        # Create two host collections within the same org
        host_col = self._new_host_collection()
        self._new_host_collection()
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by name
        result = HostCollection.list({'name': host_col['name']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
Beispiel #36
0
    def test_positive_list_by_org_id(self):
        """Check if host collection list can be filtered by organization id

        :id: afbe077a-0de1-432c-a0c4-082129aab92e

        :expectedresults: Only host-collection within specific org is listed

        :CaseLevel: Integration
        """
        # Create two host collections within different organizations
        new_org = make_org()
        host_col = make_host_collection({'organization-id': new_org['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by org id
        result = HostCollection.list({'organization-id': new_org['id']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['id'], host_col['id'])
Beispiel #37
0
    def test_positive_update_description(self):
        """Check if host collection description can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and description is updated

        """
        new_host_col = self._new_host_collection()
        for desc in valid_data_list():
            with self.subTest(desc):
                HostCollection.update({
                    'description': desc,
                    'id': new_host_col['id'],
                    'organization-id': self.org['id'],
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['description'], desc)
Beispiel #38
0
    def test_positive_delete_by_id(self):
        """Check if host collection can be created and deleted

        @id: ef54a26e-a18f-4f29-8ef4-a7124785dbae

        @Assert: Host collection is created and then deleted

        @BZ: 1328925
        """
        for name in valid_data_list():
            with self.subTest(name):
                new_host_col = self._new_host_collection({'name': name})
                HostCollection.delete({
                    'id': new_host_col['id'],
                    'organization-id': self.org['id'],
                })
                with self.assertRaises(CLIReturnCodeError):
                    HostCollection.info({'id': new_host_col['id']})
    def test_positive_update_limit(self):
        """Check if host collection limits be updated

        @Feature: Host Collection

        @Assert: Host collection limits is updated

        @BZ: 1245334

        """
        new_host_col = self._new_host_collection()
        for limit in ("3", "6", "9", "12", "15", "17", "19"):
            with self.subTest(limit):
                HostCollection.update(
                    {"id": new_host_col["id"], "max-content-hosts": limit, "organization-id": self.org["id"]}
                )
                result = HostCollection.info({"id": new_host_col["id"]})
                self.assertEqual(result["limit"], limit)
Beispiel #40
0
    def test_positive_update_name(self):
        """Check if host collection name can be updated

        @id: 10d395e6-4ac6-4c35-a78c-c59a78c55799

        @Assert: Host collection is created and name is updated

        @BZ: 1328925
        """
        new_host_col = self._new_host_collection()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                HostCollection.update({
                    'id': new_host_col['id'],
                    'name': new_name,
                    'organization-id': self.org['id'],
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['name'], new_name)
    def test_positive_update_2(self, test_data):
        """@Test: Check if host collection description can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and description is updated

        @BZ: 1171669

        """

        new_host_col = self._new_host_collection()
        # Assert that description does not match data passed
        self.assertNotEqual(new_host_col['description'],
                            test_data['description'],
                            "Descriptions should not match")

        # Update sync plan
        result = HostCollection.update({
            'id': new_host_col['id'],
            'organization-id': self.org['id'],
            'description': test_data['description']
        })
        self.assertEqual(result.return_code, 0,
                         "Host collection was not updated")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Fetch it
        result = HostCollection.info({
            'id': new_host_col['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Host collection was not updated")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
        # Assert that description matches new value
        self.assertIsNotNone(result.stdout.get('description', None),
                             "The description field was not returned")
        self.assertEqual(result.stdout['description'],
                         test_data['description'], "Descriptions should match")
        # Assert that description does not matches original value
        self.assertNotEqual(new_host_col['description'],
                            result.stdout['description'],
                            "Descriptions should not match")
Beispiel #42
0
def test_positive_register_host_ak_with_host_collection(
        module_org, module_ak_with_cv, default_sat):
    """Attempt to register a host using activation key with host collection

    :id: 62459e8a-0cfa-44ff-b70c-7f55b4757d66

    :expectedresults: Host successfully registered and listed in host collection

    :BZ: 1385814

    :CaseLevel: System
    """
    host_info = _make_fake_host_helper(module_org)

    hc = make_host_collection({'organization-id': module_org.id})
    ActivationKey.add_host_collection({
        'id': module_ak_with_cv.id,
        'organization-id': module_org.id,
        'host-collection-id': hc['id'],
    })
    # add the registered instance host to collection
    HostCollection.add_host({
        'id': hc['id'],
        'organization-id': module_org.id,
        'host-ids': host_info['id']
    })

    with VMBroker(nick='rhel7', host_classes={'host': ContentHost}) as client:
        client.install_katello_ca(default_sat)
        # register the client host with the current activation key
        client.register_contenthost(module_org.name,
                                    activation_key=module_ak_with_cv.name)
        assert client.subscribed
        # note: when registering the host, it should be automatically added to the host-collection
        client_host = Host.info({'name': client.hostname})
        hosts = HostCollection.hosts({
            'id': hc['id'],
            'organization-id': module_org.id
        })
        assert len(hosts) == 2
        expected_hosts_ids = {host_info['id'], client_host['id']}
        hosts_ids = {host['id'] for host in hosts}
        assert hosts_ids == expected_hosts_ids
Beispiel #43
0
def test_positive_list_by_org_id(module_org):
    """Check if host collection list can be filtered by organization id

    :id: afbe077a-0de1-432c-a0c4-082129aab92e

    :expectedresults: Only host-collection within specific org is listed

    :CaseLevel: Integration
    """
    # Create two host collections within different organizations
    make_host_collection({'organization-id': module_org.id})
    new_org = make_org()
    new_host_col = make_host_collection({'organization-id': new_org['id']})
    # List all host collections
    assert len(HostCollection.list()) >= 2
    # Filter list by org id
    result = HostCollection.list({'organization-id': new_org['id']})
    assert len(result) == 1
    assert result[0]['id'] == new_host_col['id']
Beispiel #44
0
    def test_positive_update_description(self):
        """Check if host collection description can be updated

        @id: 298b1f86-d4ab-4e10-a948-a0034826505f

        @Assert: Host collection is created and description is updated

        @BZ: 1328925
        """
        new_host_col = self._new_host_collection()
        for desc in valid_data_list():
            with self.subTest(desc):
                HostCollection.update({
                    'description': desc,
                    'id': new_host_col['id'],
                    'organization-id': self.org['id'],
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['description'], desc)
Beispiel #45
0
    def test_positive_list_by_host_name(self):
        """Check if host collection list can be filtered by
        associated host name

        :id: 2a99e11f-50b8-48b4-8dce-e6ad8ff9c051

        :expectedresults: Only host-collection with specific host is listed

        :CaseLevel: Integration

        :BZ: 1379372
        """
        # Create two host collections within the same org but only one with
        # associated host that will be used for filtering
        host_col = make_host_collection({
            'organization-id':
            self.organization['id'],
        })
        make_host_collection({'organization-id': self.organization['id']})
        host = self._make_fake_host_helper()
        HostCollection.add_host({
            'hosts': host['name'],
            'name': host_col['name'],
            'organization': self.organization['name'],
        })
        host_col = HostCollection.info({
            'name':
            host_col['name'],
            'organization':
            self.organization['name']
        })
        self.assertEqual(host_col['total-hosts'], '1')
        # List all host collections within organization
        result = HostCollection.list(
            {'organization': self.organization['name']})
        self.assertGreaterEqual(len(result), 2)
        # Filter list by associated host name
        result = HostCollection.list({
            'organization': self.organization['name'],
            'host': host['name']
        })
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], host_col['name'])
Beispiel #46
0
def test_positive_copy_by_id(module_org):
    """Check if host collection can be cloned by id

    :id: fd7cea50-bc56-4938-a81d-4f7a60711814

    :customerscenario: true

    :expectedresults: Host collection is cloned successfully

    :BZ: 1328925

    :CaseLevel: Integration
    """
    host_collection = make_host_collection(
        {'name': gen_string('alpha', 15), 'organization-id': module_org.id}
    )
    new_name = gen_string('numeric')
    new_host_collection = HostCollection.copy({'id': host_collection['id'], 'new-name': new_name})
    result = HostCollection.info({'id': new_host_collection[0]['id']})
    assert result['name'] == new_name
Beispiel #47
0
    def test_positive_list_by_org_name(self):
        """Check if host collection list can be filtered by organization name

        :id: 0102094f-f5af-4067-8a07-541ba9d94f61

        :expectedresults: Only host-collection within specific org is listed

        :CaseLevel: Integration
        """
        # Create two host collections within different organizations
        self._new_host_collection()
        new_org = make_org()
        host_col = self._new_host_collection(
            {'organization-id': new_org['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by org id
        result = HostCollection.list({'organization': new_org['name']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], host_col['name'])
Beispiel #48
0
def host_collection(module_org, module_ak_cv_lce, register_hosts):
    """Create and setup host collection."""
    host_collection = make_host_collection({'organization-id': module_org.id})
    host_ids = [
        Host.info({'name': host.hostname})['id'] for host in register_hosts
    ]
    HostCollection.add_host({
        'id': host_collection['id'],
        'organization-id': module_org.id,
        'host-ids': host_ids,
    })
    ActivationKey.add_host_collection({
        'id':
        module_ak_cv_lce.id,
        'host-collection-id':
        host_collection['id'],
        'organization-id':
        module_org.id,
    })
    return host_collection
Beispiel #49
0
    def test_positive_update_limit(self):
        """Check if host collection limits be updated

        @id: 4c0e0c3b-82ac-4aa2-8378-6adc7946d4ec

        @Assert: Host collection limits is updated

        @BZ: 1245334

        """
        new_host_col = self._new_host_collection()
        for limit in ('3', '6', '9', '12', '15', '17', '19'):
            with self.subTest(limit):
                HostCollection.update({
                    'id': new_host_col['id'],
                    'max-hosts': limit,
                    'organization-id': self.org['id'],
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['limit'], limit)
Beispiel #50
0
    def test_positive_update_description(self):
        """Check if host collection description can be updated

        :id: 298b1f86-d4ab-4e10-a948-a0034826505f

        :expectedresults: Host collection is created and description is updated

        :BZ: 1328925

        :CaseImportance: Critical
        """
        new_host_col = make_host_collection(
            {'organization-id': self.organization['id']})
        for desc in valid_data_list():
            with self.subTest(desc):
                HostCollection.update({
                    'description': desc,
                    'id': new_host_col['id'],
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['description'], desc)
Beispiel #51
0
    def test_positive_update_name_by_id(self):
        """Check if host collection name can be updated by id

        :id: 10d395e6-4ac6-4c35-a78c-c59a78c55799

        :expectedresults: Host collection is created and name is updated

        :BZ: 1328925

        :CaseImportance: Critical
        """
        new_host_col = make_host_collection(
            {'organization-id': self.organization['id']})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                HostCollection.update({
                    'id': new_host_col['id'],
                    'new-name': new_name,
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['name'], new_name)
Beispiel #52
0
    def test_positive_remove_host_by_id(self):
        """Check if content host can be removed from host collection

        @id: 61f4aab1-398b-4d3a-a4f4-f558ad8d2679

        @Assert: Host collection is created and content-host is removed

        @CaseLevel: Integration
        """
        new_host_col = self._new_host_collection({
            'name': gen_string('alpha', 15)
        })
        new_system = self._make_content_host_helper()
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        no_of_content_host = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })['total-hosts']
        HostCollection.remove_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
Beispiel #53
0
    def test_positive_remove_chost_by_id(self):
        """Check if content host can be removed from host collection

        @Feature: Host Collection

        @Assert: Host collection is created and content-host is removed

        """
        new_host_col = self._new_host_collection({
            'name': gen_string('alpha', 15)})
        new_system = make_content_host({
            u'content-view-id': self.default_cv['id'],
            u'lifecycle-environment-id': self.library['id'],
            u'name': gen_string('alpha', 15),
            u'organization-id': self.org['id'],
        })
        HostCollection.add_host({
            u'hosts': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        no_of_content_host = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })['total-hosts']
        HostCollection.remove_host({
            u'hosts': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
Beispiel #54
0
    def test_positive_remove_host_by_name(self):
        """Check if content host can be removed from host collection by name

        :id: 924d0137-3a9e-4ecd-9631-c21f7e9a8d5d

        :customerscenario: true

        :expectedresults: Host collection is created and content-host is
            removed

        :CaseLevel: Integration
        """
        new_host_col = make_host_collection({
            'name':
            gen_string('alpha', 15),
            'organization-id':
            self.organization['id'],
        })
        new_system = self._make_fake_host_helper()
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        no_of_content_host = HostCollection.info({
            u'id': new_host_col['id'],
        })['total-hosts']
        HostCollection.remove_host({
            u'host-ids': new_system['id'],
            u'name': new_host_col['name'],
            u'organization': self.organization['name'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
    def test_positive_update_1(self, test_data):
        """@Test: Check if host collection name can be updated

        @Feature: Host Collection

        @Assert: Host collection is created and name is updated

        """

        new_host_col = self._new_host_collection()
        # Assert that name does not matches data passed
        self.assertNotEqual(new_host_col['name'], test_data['name'],
                            "Names should not match")

        # Update host collection
        result = HostCollection.update({
            'id': new_host_col['id'],
            'organization-id': self.org['id'],
            'name': test_data['name']
        })
        self.assertEqual(result.return_code, 0,
                         "Host collection was not updated")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Fetch it
        result = HostCollection.info({
            'id': new_host_col['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Host collection was not updated")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
        # Assert that name matches new value
        self.assertIsNotNone(result.stdout.get('name', None),
                             "The name field was not returned")
        self.assertEqual(result.stdout['name'], test_data['name'],
                         "Names should match")
        # Assert that name does not match original value
        self.assertNotEqual(new_host_col['name'], result.stdout['name'],
                            "Names should not match")
Beispiel #56
0
    def test_positive_update_limit(self):
        """Check if host collection limits can be updated

        :id: 4c0e0c3b-82ac-4aa2-8378-6adc7946d4ec

        :expectedresults: Host collection limits is updated

        :BZ: 1245334

        :CaseImportance: Critical
        """
        new_host_col = make_host_collection(
            {'organization-id': self.organization['id']})
        for limit in ('3', '6', '9', '12', '15', '17', '19'):
            with self.subTest(limit):
                HostCollection.update({
                    'id': new_host_col['id'],
                    'max-hosts': limit,
                    'unlimited-hosts': 0,
                })
                result = HostCollection.info({'id': new_host_col['id']})
                self.assertEqual(result['limit'], limit)
Beispiel #57
0
    def test_positive_update_name_by_name(self):
        """Check if host collection name can be updated by name

        :id: 447a7602-a017-4b08-b2f2-10ac868b3fee

        :customerscenario: true

        :expectedresults: Host collection is created and name is updated

        :BZ: 1328925

        :CaseImportance: Critical
        """
        new_host_col = make_host_collection(
            {'organization-id': self.organization['id']})
        new_name = gen_string('alphanumeric')
        HostCollection.update({
            'name': new_host_col['name'],
            'new-name': new_name,
            'organization-id': self.organization['id']
        })
        result = HostCollection.info({'id': new_host_col['id']})
        self.assertEqual(result['name'], new_name)
Beispiel #58
0
    def test_positive_add_host_by_id(self):
        """Check if content host can be added to host collection

        :id: db987da4-6326-43d5-a4c5-93a0c4da7f00

        :expectedresults: Host collection is created and content-host is added

        :CaseLevel: Integration
        """
        new_host_col = self._new_host_collection(
            {'name': gen_string('alpha', 15)})
        new_system = self._make_fake_host_helper()
        no_of_content_host = new_host_col['total-hosts']
        HostCollection.add_host({
            u'host-ids': new_system['id'],
            u'id': new_host_col['id'],
            u'organization-id': self.org['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
            u'organization-id': self.org['id']
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)