Exemplo n.º 1
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'})
    def test_positive_os_list_with_default_organization_set(self):
        """list operating systems when the default organization is set

        :id: 2c1ba416-a5d5-4031-b154-54794569a85b

        :BZ: 1649011

        :expectedresults: os list should list operating systems when the
            default organization is set
        """
        make_os()
        os_list_before_default = OperatingSys.list()
        self.assertTrue(len(os_list_before_default) > 0)
        try:
            Defaults.add({'param-name': 'organization', 'param-value': DEFAULT_ORG})
            result = ssh.command('hammer defaults list')
            self.assertEqual(result.return_code, 0)
            self.assertTrue(DEFAULT_ORG in "".join(result.stdout))
            os_list_after_default = OperatingSys.list()
            self.assertTrue(len(os_list_after_default) > 0)

        finally:
            Defaults.delete({'param-name': 'organization'})
            result = ssh.command('hammer defaults list')
            self.assertEqual(result.return_code, 0)
            self.assertTrue(DEFAULT_ORG not in "".join(result.stdout))
Exemplo n.º 3
0
def test_product_list_with_default_settings(module_org, default_sat):
    """Listing product of an organization apart from default organization using hammer
     does not return output if a defaults settings are applied on org.

    :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef

    :BZ: 1745575

    :customerscenario: true

    :expectedresults: product/reporsitory list should work as expected.

    """
    org_id = str(module_org.id)
    default_product_name = gen_string('alpha')
    non_default_product_name = gen_string('alpha')
    non_default_org = make_org()
    default_product = make_product({
        'name': default_product_name,
        'organization-id': org_id
    })
    non_default_product = make_product({
        'name': non_default_product_name,
        'organization-id': non_default_org['id']
    })
    for product in default_product, non_default_product:
        make_repository(
            {
                'organization-id': org_id,
                'product-id': product['id'],
                'url': settings.repos.yum_0.url,
            }, )

    Defaults.add({'param-name': 'organization_id', 'param-value': org_id})
    result = default_sat.cli.Defaults.list(per_page=False)
    assert any([
        res['value'] == org_id for res in result
        if res['parameter'] == 'organization_id'
    ])

    try:
        # Verify --organization-id is not required to pass if defaults are set
        result = default_sat.cli.Product.list()
        assert any([res['name'] == default_product_name for res in result])
        result = default_sat.cli.Repository.list()
        assert any([res['product'] == default_product_name for res in result])

        # verify that defaults setting should not affect other entities
        product_list = Product.list({'organization-id': non_default_org['id']})
        assert non_default_product_name == product_list[0]['name']
        repository_list = Repository.list(
            {'organization-id': non_default_org['id']})
        assert non_default_product_name == repository_list[0]['product']

    finally:
        Defaults.delete({'param-name': 'organization_id'})
        result = default_sat.cli.Defaults.list(per_page=False)
        assert not [
            res for res in result if res['parameter'] == 'organization_id'
        ]
Exemplo n.º 4
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'})
Exemplo n.º 5
0
    def test_product_list_with_default_settings(self):
        """Listing product of an organization apart from default organization using hammer
         does not return output if a defaults settings are applied on org.

        :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef

        :BZ: 1745575

        :expectedresults: product/reporsitory list should work as expected.

        """
        default_product_name = gen_string('alpha')
        non_default_product_name = gen_string('alpha')
        default_org = self.org
        non_default_org = make_org()
        default_product = make_product({
            'name': default_product_name,
            'organization-id': default_org['id']
        })
        non_default_product = make_product({
            'name':
            non_default_product_name,
            'organization-id':
            non_default_org['id']
        })
        for product in (default_product, non_default_product):
            make_repository({
                'product-id': product['id'],
                'url': FAKE_0_YUM_REPO
            })

        Defaults.add({
            'param-name': 'organization_id',
            'param-value': default_org['id']
        })
        result = ssh.command('hammer defaults list')
        self.assertTrue(default_org['id'] in "".join(result.stdout))
        try:
            # Verify --organization-id is not required to pass if defaults are set
            result = ssh.command('hammer product list')
            self.assertTrue(default_product_name in "".join(result.stdout))
            result = ssh.command('hammer repository list')
            self.assertTrue(default_product_name in "".join(result.stdout))

            # verify that defaults setting should not affect other entities
            product_list = Product.list(
                {'organization-id': non_default_org['id']})
            self.assertEquals(non_default_product_name,
                              product_list[0]['name'])
            repository_list = Repository.list(
                {'organization-id': non_default_org['id']})
            self.assertEquals(non_default_product_name,
                              repository_list[0]['product'])

        finally:
            Defaults.delete({'param-name': 'organization_id'})
            result = ssh.command('hammer defaults list')
            self.assertTrue(default_org['id'] not in "".join(result.stdout))
Exemplo n.º 6
0
def test_product_list_with_default_settings(module_org):
    """Listing product of an organization apart from default organization using hammer
     does not return output if a defaults settings are applied on org.

    :id: d5c5edac-b19c-4277-92fe-28d9b9fa43ef

    :BZ: 1745575

    :customerscenario: true

    :expectedresults: product/reporsitory list should work as expected.

    """
    org_id = str(module_org.id)
    default_product_name = gen_string('alpha')
    non_default_product_name = gen_string('alpha')
    non_default_org = make_org()
    default_product = make_product({
        'name': default_product_name,
        'organization-id': org_id
    })
    non_default_product = make_product({
        'name': non_default_product_name,
        'organization-id': non_default_org['id']
    })
    for product in default_product, non_default_product:
        make_repository(
            {
                'organization-id': org_id,
                'product-id': product['id'],
                'url': FAKE_0_YUM_REPO,
            }, )

    Defaults.add({'param-name': 'organization_id', 'param-value': org_id})
    result = ssh.command('hammer defaults list')
    assert org_id in "".join(result.stdout)
    try:
        # Verify --organization-id is not required to pass if defaults are set
        result = ssh.command('hammer product list')
        assert default_product_name in "".join(result.stdout)
        result = ssh.command('hammer repository list')
        assert default_product_name in "".join(result.stdout)

        # verify that defaults setting should not affect other entities
        product_list = Product.list({'organization-id': non_default_org['id']})
        assert non_default_product_name == product_list[0]['name']
        repository_list = Repository.list(
            {'organization-id': non_default_org['id']})
        assert non_default_product_name == repository_list[0]['product']

    finally:
        Defaults.delete({'param-name': 'organization_id'})
        result = ssh.command('hammer defaults list')
        assert org_id not in "".join(result.stdout)
Exemplo n.º 7
0
    def test_positive_list_job_template_with_saved_org_and_loc(self):
        """List available job templates with saved default organization and
        location in config

        :id: 4fd05dd7-53e3-41ba-ba90-6181a7190ad8

        :expectedresults: The Job Template can be listed without errors

        :BZ: 1368173
        """
        template_name = gen_string('alpha')
        location = make_location()
        make_job_template(
            {
                'organizations': self.organization['name'],
                'name': template_name,
                'file': TEMPLATE_FILE,
            }
        )
        templates = JobTemplate.list({'organization-id': self.organization['id']})
        self.assertGreaterEqual(len(templates), 1)
        Defaults.add({'param-name': 'organization_id', 'param-value': self.organization['id']})
        Defaults.add({'param-name': 'location_id', 'param-value': location['id']})
        try:
            templates = JobTemplate.list()
            self.assertGreaterEqual(len(templates), 1)
        finally:
            Defaults.delete({'param-name': 'organization_id'})
            Defaults.delete({'param-name': 'location_id'})
Exemplo n.º 8
0
    def test_positive_create_with_default_taxonomies(
        self, module_org, module_location, content_view
    ):
        """Create new content view filter and assign it to existing content
        view by name. Use default organization and location to find necessary
        content view

        :id: 5fd6db3f-5723-44a9-a138-864693680a2f

        :expectedresults: Content view filter created successfully and has
            correct and expected name

        :BZ: 1369609

        :CaseImportance: Critical
        """
        name = gen_string('alpha')
        Defaults.add({'param-name': 'organization_id', 'param-value': module_org.id})
        Defaults.add({'param-name': 'location_id', 'param-value': module_location.id})
        try:
            ContentView.filter.create(
                {
                    'content-view': content_view['name'],
                    'name': name,
                    'type': 'erratum',
                    'inclusion': 'true',
                },
            )
            cvf = ContentView.filter.info({'content-view': content_view['name'], 'name': name})
            assert cvf['name'] == name
        finally:
            Defaults.delete({'param-name': 'organization_id'})
            Defaults.delete({'param-name': 'location_id'})
Exemplo n.º 9
0
def test_positive_disable_hammer_defaults(default_sat):
    """Verify hammer disable defaults command.

    :id: d0b65f36-b91f-4f2f-aaf8-8afda3e23708

    :steps:
        1. Add hammer defaults as organization-id.
        2. Verify hammer product list successful.
        3. Run hammer --no-use-defaults product list.

    :expectedresults: Hammer --no-use-defaults product list should fail.

    :CaseImportance: Critical

    :BZ: 1640644, 1368173
    """
    default_org = make_org()
    default_product_name = gen_string('alpha')
    make_product({
        'name': default_product_name,
        'organization-id': default_org['id']
    })
    try:
        Defaults.add({
            'param-name': 'organization_id',
            'param-value': default_org['id']
        })
        # list templates for BZ#1368173
        result = default_sat.execute('hammer job-template list')
        assert result.status == 0
        # Verify --organization-id is not required to pass if defaults are set
        result = default_sat.execute('hammer product list')
        assert result.status == 0
        # Verify product list fail without using defaults
        result = default_sat.execute('hammer --no-use-defaults product list')
        assert result.status != 0
        assert default_product_name not in result.stdout
        # Verify --organization-id is not required to pass if defaults are set
        result = default_sat.execute('hammer --use-defaults product list')
        assert result.status == 0
        assert default_product_name in result.stdout
    finally:
        Defaults.delete({'param-name': 'organization_id'})
        result = default_sat.execute('hammer defaults list')
        assert default_org['id'] not in result.stdout
Exemplo n.º 10
0
    def test_positive_disable_hammer_defaults(self):
        """Verify hammer disable defaults command.

        :id: d0b65f36-b91f-4f2f-aaf8-8afda3e23708

        :steps:
            1. Add hammer defaults as organization-id.
            2. Verify hammer product list successful.
            3. Run hammer --no-use-defaults product list.

        :expectedresults: Hammer --no-use-defaults product list should fail.

        :CaseImportance: Critical

        :BZ: 1640644
        """
        default_org = make_org()
        default_product_name = gen_string('alpha')
        make_product({
            'name': default_product_name,
            'organization-id': default_org['id']
        })
        try:
            Defaults.add({
                'param-name': 'organization_id',
                'param-value': default_org['id']
            })
            # Verify --organization-id is not required to pass if defaults are set
            result = ssh.command('hammer product list')
            self.assertEqual(result.return_code, 0)
            # Verify product list fail without using defaults
            result = ssh.command('hammer --no-use-defaults product list')
            self.assertNotEqual(result.return_code, 0)
            self.assertFalse(default_product_name in "".join(result.stdout))
            # Verify --organization-id is not required to pass if defaults are set
            result = ssh.command('hammer --use-defaults product list')
            self.assertEqual(result.return_code, 0)
            self.assertTrue(default_product_name in "".join(result.stdout))
        finally:
            Defaults.delete({'param-name': 'organization_id'})
            result = ssh.command('hammer defaults list')
            self.assertTrue(default_org['id'] not in "".join(result.stdout))
Exemplo n.º 11
0
    def test_positive_create_with_default_taxonomies(self):
        """Create new content view filter and assign it to existing content
        view by name. Use default organization and location to find necessary
        content view

        :id: 5fd6db3f-5723-44a9-a138-864693680a2f

        :expectedresults: Content view filter created successfully and has
            correct and expected name

        :BZ: 1369609

        :CaseImportance: Critical
        """
        name = gen_string('alpha')
        location = make_location()
        Defaults.add({
            u'param-name': 'organization_id',
            u'param-value': self.org['id'],
        })
        Defaults.add({
            u'param-name': 'location_id',
            u'param-value': location['id'],
        })
        try:
            ContentView.filter.create({
                'content-view': self.content_view['name'],
                'name': name,
                'type': 'erratum',
                'inclusion': 'true',

            })
            cvf = ContentView.filter.info({
                u'content-view': self.content_view['name'],
                u'name': name,
            })
            self.assertEqual(cvf['name'], name)
        finally:
            Defaults.delete({u'param-name': 'organization_id'})
            Defaults.delete({u'param-name': 'location_id'})
Exemplo n.º 12
0
    def test_positive_list_job_template_with_saved_org_and_loc(self):
        """List available job templates with saved default organization and
        location in config

        :id: 4fd05dd7-53e3-41ba-ba90-6181a7190ad8

        :expectedresults: The Job Template can be listed without errors

        :BZ: 1368173

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha')
        location = make_location()
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE,
        })
        templates = JobTemplate.list({
            'organization-id': self.organization['id']})
        self.assertGreaterEqual(len(templates), 1)
        Defaults.add({
            u'param-name': 'organization_id',
            u'param-value': self.organization['id'],
        })
        Defaults.add({
            u'param-name': 'location_id',
            u'param-value': location['id'],
        })
        try:
            templates = JobTemplate.list()
            self.assertGreaterEqual(len(templates), 1)
        finally:
            Defaults.delete({u'param-name': 'organization_id'})
            Defaults.delete({u'param-name': 'location_id'})