Ejemplo n.º 1
0
def test_negative_install_without_hc_info(module_org, host_collection):
    """Attempt to install an erratum on a host collection without specifying host collection info.
    This test only works with two or more host collections (BZ#1928281).
    We have the one from the fixture, just need to create one more at the start of the test.

    :id: 753d36f0-d19b-494d-a247-ce2d61c4cf74

    :Setup: Errata synced on satellite server.

    :Steps: host-collection erratum install --errata <errata>
        --organization-id <org_id>

    :expectedresults: Error message thrown.

    :BZ: 1928281

    :CaseImportance: Low

    :CaseLevel: System
    """
    make_host_collection({'organization-id': module_org.id})
    with pytest.raises(CLIReturnCodeError):
        HostCollection.erratum_install({
            'organization-id':
            module_org.id,
            'errata': [REPO_WITH_ERRATA['errata'][0]['id']]
        })
Ejemplo n.º 2
0
    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'])
Ejemplo n.º 3
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
        """
        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'])
Ejemplo n.º 4
0
    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'])
Ejemplo n.º 5
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
        """
        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'])
Ejemplo n.º 6
0
 def setUpClass(cls):
     """Prepare some data to be used in tests"""
     super(HostCollectionTestCase, cls).setUpClass()
     cls.organization = make_org()
     cls.library = LifecycleEnvironment.info(
         {'organization-id': cls.organization['id'], 'name': ENVIRONMENT}
     )
     cls.default_cv = ContentView.info(
         {'organization-id': cls.organization['id'], 'name': DEFAULT_CV}
     )
     make_host_collection({'organization-id': cls.organization['id']})
Ejemplo n.º 7
0
def test_negative_create_with_name(module_org, name):
    """Attempt to create host collection with invalid name of different
    types

    :id: 92a9eff0-693f-4ab8-b2c4-de08e5f709a7

    :parametrized: yes

    :expectedresults: Host collection is not created and error is raised

    :CaseImportance: Critical
    """
    with pytest.raises(CLIFactoryError):
        make_host_collection({'name': name, 'organization-id': module_org.id})
Ejemplo n.º 8
0
    def test_positive_list_hosts(self):
        """Check if content hosts added to host collection is listed

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

        :expectedresults: Content-host added to host-collection is listed

        :CaseLevel: Integration
        """
        host_col_name = gen_string('alpha', 15)
        new_host_col = make_host_collection({
            'name':
            host_col_name,
            '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'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
        result = HostCollection.hosts({
            u'name':
            host_col_name,
            u'organization-id':
            self.organization['id']
        })
        self.assertEqual(new_system['name'].lower(), result[0]['name'])
Ejemplo n.º 9
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'])
Ejemplo n.º 10
0
    def test_positive_remove_host_by_id(self):
        """Check if content host can be removed from host collection by id

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

        :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'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    def test_positive_add_host_by_id(self):
        """Check if content host can be added to host collection by id

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

        :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'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
Ejemplo n.º 13
0
    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']})
Ejemplo n.º 14
0
    def test_positive_update_host_collection_with_default_org(self):
        """Test that host collection can be associated to Activation
        Keys with specified default organization setting in config

        :id: 01e830e9-91fd-4e45-9aaf-862e1fe134df

        :expectedresults: Host collection is successfully associated to
            Activation key

        :BZ: 1364876
        """
        Defaults.add({
            u'param-name': 'organization_id',
            u'param-value': self.org['id'],
        })
        try:
            activation_key = self._make_activation_key()
            host_col = make_host_collection()
            ActivationKey.add_host_collection({
                u'host-collection': host_col['name'],
                u'name': activation_key['name'],
            })
            activation_key = ActivationKey.info({
                u'id': activation_key['id'],
            })
            self.assertEqual(
                activation_key['host-collections'][0]['name'],
                host_col['name']
            )
        finally:
            Defaults.delete({u'param-name': 'organization_id'})
Ejemplo n.º 15
0
def test_positive_update_to_unlimited_hosts(module_org):
    """Create Host Collection with a limit and update it to unlimited hosts

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

    :expectedresults: Host Collection is created and updated to unlimited hosts

    :CaseImportance: High
    """
    host_collection = make_host_collection({
        'max-hosts': 1,
        'organization-id': module_org.id,
    })
    result = HostCollection.info({
        'name': host_collection['name'],
        'organization-id': module_org.id
    })
    assert result['limit'] == '1'
    HostCollection.update({
        'name': host_collection['name'],
        'organization-id': module_org.id,
        'unlimited-hosts': True,
    })
    result = HostCollection.info({
        'name': host_collection['name'],
        'organization-id': module_org.id
    })
    assert result['limit'] == 'None'
Ejemplo n.º 16
0
    def test_positive_remove_host_collection_by_id(self):
        """@Test: Test that hosts associated to Activation Keys can be removed
        using id of that host collection

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate host collection to Activation key
        4. Remove host collection associated to Activation key using id of that
           collection

        @Assert: Host collection successfully removed from activation key
        """
        activation_key = self._make_activation_key()
        new_host_col = make_host_collection({
            u'name': gen_string('alpha'),
            u'organization-id': self.org['id'],
        })
        ActivationKey.add_host_collection({
            u'host-collection-id': new_host_col['id'],
            u'name': activation_key['name'],
            u'organization': self.org['name'],
        })
        activation_key = ActivationKey.info({u'id': activation_key['id']})
        self.assertEqual(len(activation_key['host-collections']), 1)
        ActivationKey.remove_host_collection({
            u'host-collection-id': new_host_col['id'],
            u'name': activation_key['name'],
            u'organization': self.org['name'],
        })
        activation_key = ActivationKey.info({u'id': activation_key['id']})
        self.assertEqual(len(activation_key['host-collections']), 0)
Ejemplo n.º 17
0
def test_positive_host_collection_host_pagination(module_org):
    """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

    :expectedresults: Number of host per page follows per_page
        configuration restriction

    :CaseLevel: Integration
    """
    host_collection = make_host_collection({'organization-id': module_org.id})
    host_ids = ','.join(_make_fake_host_helper(module_org)['id'] for _ in range(2))
    HostCollection.add_host({'host-ids': host_ids, 'id': host_collection['id']})
    for number in range(1, 3):
        listed_hosts = HostCollection.hosts(
            {
                'id': host_collection['id'],
                'organization-id': module_org.id,
                'per-page': number,
            }
        )
        assert len(listed_hosts) == number
Ejemplo n.º 18
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')
Ejemplo n.º 19
0
    def test_positive_update_host_collection(self):
        """Test that host collection can be associated to Activation
        Keys

        @Feature: Activation key - Host

        @BZ: 1110476

        @Assert: Hosts are successfully associated to Activation key
        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({"name": host_col_name})["name"]
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection(
                    {
                        u"host-collection": new_host_col_name,
                        u"name": activation_key["name"],
                        u"organization-id": self.org["id"],
                    }
                )
                activation_key = ActivationKey.info({u"id": activation_key["id"]})
                self.assertEqual(activation_key["host-collection"], host_col_name)
Ejemplo n.º 20
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'
Ejemplo n.º 21
0
    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({
            'id': host_collection['id'],
            'new-name': new_name
        })
        result = HostCollection.info({'id': new_host_collection[0]['id']})
        self.assertEqual(result['name'], new_name)
Ejemplo n.º 22
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')
Ejemplo n.º 23
0
    def test_negative_create_with_name(self):
        """Attempt to create host collection with invalid name of different
        types

        :id: 92a9eff0-693f-4ab8-b2c4-de08e5f709a7

        :expectedresults: Host collection is not created and error is raised

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIFactoryError):
                    make_host_collection(
                        {'name': name, 'organization-id': self.organization['id']}
                    )
Ejemplo n.º 24
0
    def test_positive_update_host_collection_with_default_org(self):
        """Test that host collection can be associated to Activation
        Keys with specified default organization setting in config

        :id: 01e830e9-91fd-4e45-9aaf-862e1fe134df

        :expectedresults: Host collection is successfully associated to
            Activation key

        :BZ: 1364876
        """
        Defaults.add({
            u'param-name': 'organization_id',
            u'param-value': self.org['id'],
        })
        try:
            activation_key = self._make_activation_key()
            host_col = make_host_collection()
            ActivationKey.add_host_collection({
                u'host-collection': host_col['name'],
                u'name': activation_key['name'],
            })
            activation_key = ActivationKey.info({
                u'id': activation_key['id'],
            })
            self.assertEqual(
                activation_key['host-collections'][0]['name'],
                host_col['name']
            )
        finally:
            Defaults.delete({u'param-name': 'organization_id'})
Ejemplo n.º 25
0
    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)
Ejemplo n.º 26
0
    def test_positive_update_host_collection(self):
        """Test that host collection can be associated to Activation
        Keys

        @Feature: Activation key - Host

        @BZ: 1110476

        @Assert: Hosts are successfully associated to Activation key
        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({
                    'name': host_col_name,
                })['name']
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col_name,
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(
                    activation_key['host-collection'], host_col_name)
Ejemplo n.º 27
0
    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)
Ejemplo n.º 28
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
Ejemplo n.º 29
0
    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

        :expectedresults: Number of host per page follows per_page
            configuration restriction

        :CaseLevel: Integration
        """
        host_collection = make_host_collection({
            'organization-id': self.organization['id'],
        })
        host_ids = ','.join(
            self._make_fake_host_helper()['id'] for _ in range(2)
        )
        HostCollection.add_host({
            u'host-ids': host_ids,
            u'id': host_collection['id'],
        })
        for number in range(1, 3):
            listed_hosts = HostCollection.hosts({
                u'id': host_collection['id'],
                u'organization-id': self.organization['id'],
                u'per-page': number
            })
            self.assertEqual(len(listed_hosts), number)
Ejemplo n.º 30
0
    def test_positive_update_host_collection(self):
        """Test that host collection can be associated to Activation
        Keys

        :id: 2114132a-fede-4791-98e7-a463ad79f398

        :BZ: 1110476

        :expectedresults: Hosts are successfully associated to Activation key

        :CaseLevel: Integration
        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({
                    'name': host_col_name,
                })['name']
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col_name,
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(
                    activation_key['host-collection'], host_col_name)
Ejemplo n.º 31
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

        @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')
Ejemplo n.º 32
0
    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)
Ejemplo n.º 33
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'])
Ejemplo n.º 34
0
    def test_positive_list_hosts(self):
        """Check if content hosts added to host collection is listed

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

        :expectedresults: Content-host added to host-collection is listed

        :CaseLevel: Integration
        """
        host_col_name = gen_string('alpha', 15)
        new_host_col = make_host_collection({
            'name': host_col_name,
            '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'host-ids': new_system['id'],
            u'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(result['total-hosts'], no_of_content_host)
        result = HostCollection.hosts({
            u'name': host_col_name,
            u'organization-id': self.organization['id']
        })
        self.assertEqual(new_system['name'].lower(), result[0]['name'])
Ejemplo n.º 35
0
    def test_associate_host(self):
        """@Test: Test that host collection can be associated to Activation
        Keys

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate the host collection to Activation key

        @Assert: Hosts are successfully associated to Activation key

        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({
                    'name': host_col_name,
                })['name']
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col_name,
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(
                    activation_key['host-collection'], host_col_name)
Ejemplo n.º 36
0
    def test_positive_remove_host_by_id(self):
        """Check if content host can be removed from host collection by id

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

        :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'id': new_host_col['id'],
        })
        result = HostCollection.info({
            u'id': new_host_col['id'],
        })
        self.assertGreater(no_of_content_host, result['total-hosts'])
Ejemplo n.º 37
0
    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']})
Ejemplo n.º 38
0
    def test_positive_remove_host_collection_by_id(self):
        """Test that hosts associated to Activation Keys can be removed
        using id of that host collection

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate host collection to Activation key
        4. Remove host collection associated to Activation key using id of that
           collection

        @Assert: Host collection successfully removed from activation key
        """
        activation_key = self._make_activation_key()
        new_host_col = make_host_collection({
            u'name': gen_string('alpha'),
            u'organization-id': self.org['id'],
        })
        ActivationKey.add_host_collection({
            u'host-collection-id': new_host_col['id'],
            u'name': activation_key['name'],
            u'organization': self.org['name'],
        })
        activation_key = ActivationKey.info({u'id': activation_key['id']})
        self.assertEqual(len(activation_key['host-collections']), 1)
        ActivationKey.remove_host_collection({
            u'host-collection-id': new_host_col['id'],
            u'name': activation_key['name'],
            u'organization': self.org['name'],
        })
        activation_key = ActivationKey.info({u'id': activation_key['id']})
        self.assertEqual(len(activation_key['host-collections']), 0)
Ejemplo n.º 39
0
    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)
Ejemplo n.º 40
0
    def test_positive_update_host_collection(self):
        """Test that host collections can be associated to Activation
        Keys

        :id: 2114132a-fede-4791-98e7-a463ad79f398

        :BZ: 1110476

        :expectedresults: Host collections are successfully associated to
            Activation key

        :CaseLevel: Integration
        """
        for host_col_name in valid_data_list():
            with self.subTest(host_col_name):
                activation_key = self._make_activation_key()
                new_host_col_name = make_host_collection({
                    u'name': host_col_name,
                    u'organization-id': self.org['id'],
                })['name']
                # Assert that name matches data passed
                self.assertEqual(new_host_col_name, host_col_name)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col_name,
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col_name
                )
Ejemplo n.º 41
0
    def test_positive_remove_host_collection_by_name(self):
        """Test that hosts associated to Activation Keys can be removed
        using name of that host collection

        :id: 1a559a82-db5f-48b0-beeb-2fa02aed7ef9

        :Steps:

            1. Create Activation key
            2. Create host collection
            3. Associate host collection to Activation key
            4. Remove the host collection associated to Activation key using
               name of that collection

        :expectedresults: Host collection successfully removed from activation
            key

        :CaseLevel: Integration
        """
        for host_col in valid_data_list():
            with self.subTest(host_col):
                activation_key = self._make_activation_key()
                new_host_col = make_host_collection({
                    u'name':
                    host_col,
                    u'organization-id':
                    self.org['id'],
                })
                # Assert that name matches data passed
                self.assertEqual(new_host_col['name'], host_col)
                ActivationKey.add_host_collection({
                    u'host-collection':
                    new_host_col['name'],
                    u'name':
                    activation_key['name'],
                    u'organization-id':
                    self.org['id'],
                })
                activation_key = ActivationKey.info({
                    'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 1)
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col,
                )
                ActivationKey.remove_host_collection({
                    u'host-collection':
                    new_host_col['name'],
                    u'name':
                    activation_key['name'],
                    u'organization-id':
                    self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id':
                    activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 0)
Ejemplo n.º 42
0
    def test_negative_create_with_name(self):
        """Attempt to create host collection with invalid name of different
        types

        :id: 92a9eff0-693f-4ab8-b2c4-de08e5f709a7

        :expectedresults: Host collection is not created and error is raised

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaises(CLIFactoryError):
                    make_host_collection({
                        'name': name,
                        'organization-id': self.organization['id'],
                    })
Ejemplo n.º 43
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']

        return make_host_collection(options)
Ejemplo n.º 44
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']
Ejemplo n.º 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'])
Ejemplo n.º 46
0
def test_positive_register_host_ak_with_host_collection(
        katello_agent_client, module_cv, module_lce, module_org,
        rhel7_contenthost, default_sat):
    """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
    """
    # client = katello_agent_client['client']
    host_info = katello_agent_client['host_info']
    # create a new activation key
    activation_key = make_activation_key({
        'lifecycle-environment-id':
        module_lce.id,
        'organization-id':
        module_org.id,
        'content-view-id':
        module_cv.id,
    })
    hc = make_host_collection({'organization-id': module_org.id})
    ActivationKey.add_host_collection({
        'id': activation_key['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 vm:
        vm.install_katello_ca(default_sat)
        # register the client host with the current activation key
        vm.register_contenthost(module_org.name,
                                activation_key=activation_key['name'])
        assert vm.subscribed
        # note: when registering the host, it should be automatically added to the host-collection
        client_host = Host.info({'name': vm.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
Ejemplo n.º 47
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()
        make_host_collection({
            'organization-id': self.organization['id'],
        })
        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'])
Ejemplo n.º 48
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
        new_org = make_org()
        make_host_collection({
            'organization-id': self.organization['id'],
        })
        host_col = make_host_collection({'organization-id': new_org['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by org name
        result = HostCollection.list({'organization': new_org['name']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], host_col['name'])
Ejemplo n.º 49
0
def test_positive_create_with_limit(module_org):
    """Check if host collection can be created with correct limits

    :id: 682b5624-1095-48e6-a0dd-c76e70ca6540

    :expectedresults: Host collection is created and has expected limits

    :CaseImportance: Critical
    """
    for limit in ('1', '3', '5', '10', '20'):
        new_host_col = make_host_collection({'max-hosts': limit, 'organization-id': module_org.id})
        assert new_host_col['limit'] == limit
Ejemplo n.º 50
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
        new_org = make_org()
        make_host_collection({
            'organization-id': self.organization['id'],
        })
        host_col = make_host_collection({'organization-id': new_org['id']})
        # List all host collections
        self.assertGreaterEqual(len(HostCollection.list()), 2)
        # Filter list by org name
        result = HostCollection.list({'organization': new_org['name']})
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0]['name'], host_col['name'])
Ejemplo n.º 51
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'])
Ejemplo n.º 52
0
    def test_associate_host(self, test_data):
        """@Test: Test that hosts can be associated to Activation Keys

        @Feature: Activation key - Host

        @Steps:
        1. Create Activation key
        2. Create different hosts
        3. Associate the hosts to Activation key

        @Assert: Hosts are successfully associated to Activation key

        """

        try:
            activation_key = self._make_activation_key({
                u'organization-id': self.org['id'],
            })
            new_host_col = make_host_collection({
                'name': test_data['host-col']
            })
        except CLIFactoryError as err:
            self.fail(err)

        # Assert that name matches data passed
            self.assertEqual(
                new_host_col['name'],
                test_data['host-col'],
                "Names don't match"
            )

        result = ActivationKey.add_host_collection({
            u'name': activation_key['name'],
            u'host-collection': new_host_col['name'],
            u'organization-id': self.org['id'],
        })
        self.assertEqual(
            result.return_code, 0, 'Failed to add host-col activation key')
        self.assertEqual(
            len(result.stderr), 0, 'There should not be an error here')

        result = ActivationKey.info({
            u'id': activation_key['id'],
        })
        self.assertEqual(
            result.return_code, 0, 'Failed to get info for activation key')
        self.assertEqual(
            len(result.stderr), 0, 'There should not be an error here')
        self.assertEqual(
            result.stdout['host-collection'], test_data['host-col'],
            'Activation key host-collection added')
Ejemplo n.º 53
0
    def test_positive_remove_host_collection_by_name(self):
        """Test that hosts associated to Activation Keys can be removed
        using name of that host collection

        :id: 1a559a82-db5f-48b0-beeb-2fa02aed7ef9

        :Steps:

            1. Create Activation key
            2. Create host collection
            3. Associate host collection to Activation key
            4. Remove the host collection associated to Activation key using
               name of that collection

        :expectedresults: Host collection successfully removed from activation
            key

        :CaseLevel: Integration
        """
        for host_col in valid_data_list():
            with self.subTest(host_col):
                activation_key = self._make_activation_key()
                new_host_col = make_host_collection({
                    u'name': host_col,
                    u'organization-id': self.org['id'],
                })
                # Assert that name matches data passed
                self.assertEqual(new_host_col['name'], host_col)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 1)
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col,
                )
                ActivationKey.remove_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 0)
Ejemplo n.º 54
0
    def test_remove_hc_by_name(self):
        """@Test: Test that hosts associated to Activation Keys can be removed
        using name of that host collection

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Create host collection
        3. Associate host collection to Activation key
        4. Remove the host collection associated to Activation key using name
           of that collection

        @Assert: Host collection successfully removed from activation key

        """
        for host_col in valid_data_list():
            with self.subTest(host_col):
                activation_key = self._make_activation_key()
                new_host_col = make_host_collection({
                    u'name': host_col,
                    u'organization-id': self.org['id'],
                })
                # Assert that name matches data passed
                self.assertEqual(new_host_col['name'], host_col)
                ActivationKey.add_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 1)
                self.assertEqual(
                    activation_key['host-collections'][0]['name'],
                    host_col,
                )
                ActivationKey.remove_host_collection({
                    u'host-collection': new_host_col['name'],
                    u'name': activation_key['name'],
                    u'organization-id': self.org['id'],
                })
                activation_key = ActivationKey.info({
                    u'id': activation_key['id'],
                })
                self.assertEqual(len(activation_key['host-collections']), 0)
Ejemplo n.º 55
0
    def test_remove_host(self, test_data):
        """@Test: Test that hosts associated to Activation Keys can be removed

        @Feature: Activation key - Host

        @Steps:
        1. Create Activation key
        2. Create different hosts
        3. Associate the hosts to Activation key
        4. Remove the hosts associated to Activation key

        @Assert: Hosts successfully removed that
        are associated to Activation key

        """
        try:
            org = make_org()
            activation_key = self._make_activation_key({u"organization-id": org["id"]})
            new_host_col = make_host_collection({u"name": test_data["host-col"], u"organization-id": org["id"]})
        except CLIFactoryError as err:
            self.fail(err)

        # Assert that name matches data passed
        self.assertEqual(new_host_col["name"], test_data["host-col"], "Names don't match")

        result = ActivationKey.add_host_collection(
            {u"name": activation_key["name"], u"host-collection": new_host_col["name"], u"organization-id": org["id"]}
        )
        self.assertEqual(result.return_code, 0, "Failed to add host-col activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")

        result = ActivationKey.info({u"id": activation_key["id"]})
        self.assertEqual(result.return_code, 0, "Failed to get info for activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")
        self.assertEqual(
            result.stdout["host-collections"][0]["name"], test_data["host-col"], "Activation key host-collection added"
        )

        result = ActivationKey.remove_host_collection(
            {u"name": activation_key["name"], u"host-collection": new_host_col["name"], u"organization-id": org["id"]}
        )
        self.assertEqual(result.return_code, 0, "Failed to remove host-col activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")

        result = ActivationKey.info({u"id": activation_key["id"]})
        self.assertEqual(result.return_code, 0, "Failed to get info for activation key")
        self.assertEqual(len(result.stderr), 0, "There should not be an error here")
        self.assertEqual(len(result.stdout["host-collections"]), 0, "Activation key host-collection removed")
Ejemplo n.º 56
0
    def test_positive_create_with_limit(self):
        """Check if host collection can be created with correct limits

        :id: 682b5624-1095-48e6-a0dd-c76e70ca6540

        :expectedresults: Host collection is created and has expected limits

        :CaseImportance: Critical
        """
        for limit in ('1', '3', '5', '10', '20'):
            with self.subTest(limit):
                new_host_col = make_host_collection({
                    'max-hosts': limit,
                    'organization-id': self.organization['id'],
                })
                self.assertEqual(new_host_col['limit'], limit)
Ejemplo n.º 57
0
    def test_positive_create_with_description(self):
        """Check if host collection can be created with random description

        :id: 9736e3aa-bbc1-4c5f-98e9-b9dd18ba47ca

        :expectedresults: Host collection is created and has expected
            description

        :CaseImportance: Critical
        """
        for desc in valid_data_list():
            with self.subTest(desc):
                new_host_col = make_host_collection({
                    'description': desc,
                    'organization-id': self.organization['id'],
                })
                self.assertEqual(new_host_col['description'], desc)