Example #1
0
    def test_proxy_update(self, data):
        """@Test: Proxy name update with the home proxy

        @Feature: Smart Proxy

        @Assert: Proxy has the name updated

        """
        try:
            proxy = make_proxy({u'name': data['name']})
        except CLIFactoryError as err:
            self.fail(err)

        self.assertEquals(proxy['name'], data['name'],
                          "Input and output name should be consistent")

        with default_url_on_new_port(9090, random.randint(9091, 49090)) as url:
            result = Proxy.update({
                u'id': proxy['id'],
                u'name': data['update'],
                u'url': url
            })
        self.assertEqual(result.return_code, 0, "Proxy should be updated")
        result = Proxy.info({u'id': proxy['id']})
        self.assertEqual(result.return_code, 0, "Proxy should be found")
        self.assertEqual(result.stdout['name'], data['update'],
                         "Proxy name should be updated")
Example #2
0
    def test_proxy_delete(self, data):
        """@Test: Proxy deletion with the home proxy

        @Feature: Smart Proxy

        @Assert: Proxy is deleted

        """
        try:
            proxy = make_proxy({u'name': data['name']})
        except CLIFactoryError as err:
            self.fail(err)

        self.assertEquals(proxy['name'], data['name'],
                          "Input and output name should be consistent")

        result = Proxy.info({u'id': proxy['id']})
        self.assertEqual(result.return_code, 0, "Proxy should be found")
        self.assertEqual(len(result.stderr), 0, "No error excepted")
        result = Proxy.delete({u'id': proxy['id']})
        self.assertEqual(result.return_code, 0, "Proxy should be deleted")
        self.assertEqual(len(result.stderr), 0, "No error excepted")

        result = Proxy.info({u'id': proxy['id']})
        self.assertNotEqual(result.return_code, 0, "Proxy should not be found")
        self.assertGreater(len(result.stderr), 0, "Expected an error here")
Example #3
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test. Raise an
     exception and skip all tests in case not enough parameters returned.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force puppetlabs/ntp')
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
     sc_params_list = SmartClassParameter.list({
         'environment':
         cls.env['name'],
         'search':
         'puppetclass=ntp'
     })
     if len(sc_params_list) < 45:
         raise RuntimeError('There are not enough smart class parameters to'
                            ' work with in provided puppet class')
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in sc_params_list
     ]
Example #4
0
    def test_proxy_refresh_features_by_name(self):
        """@Test: Refresh smart proxy features, search for proxy by name

        @Feature: Smart Proxy

        @Assert: Proxy features are refreshed
        """
        proxy = make_proxy()
        Proxy.refresh_features({u'name': proxy['name']})
Example #5
0
    def test_refresh_refresh_features_by_id(self):
        """@Test: Refresh smart proxy features, search for proxy by id

        @Feature: Smart Proxy

        @Assert: Proxy features are refreshed
        """
        proxy = make_proxy()
        Proxy.refresh_features({u'id': proxy['id']})
Example #6
0
def capsule_cleanup(proxy_id=None):
    """Deletes the capsule with the given id"""
    if bz_bug_is_open(1398695):
        try:
            Proxy.delete({'id': proxy_id})
        except CLIReturnCodeError as err:
            if err.return_code != 70:
                raise err
    else:
        Proxy.delete({'id': proxy_id})
Example #7
0
def capsule_cleanup(proxy_id=None):
    """Deletes the capsule with the given id"""
    if bz_bug_is_open(1398695):
        try:
            Proxy.delete({"id": proxy_id})
        except CLIReturnCodeError as err:
            if err.return_code != 70:
                raise err
    else:
        Proxy.delete({"id": proxy_id})
Example #8
0
 def setUpClass(cls):
     """Import a parametrized puppet class.
     """
     super(PuppetClassTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force puppetlabs/ntp')
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
Example #9
0
    def test_positive_delete_by_id(self):
        """Proxy deletion with the home proxy

        @id: 1b6973b1-259d-4866-b36f-c2d5fb154035

        @Assert: Proxy is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                proxy = make_proxy({u'name': name})
                Proxy.delete({'id': proxy['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Proxy.info({u'id': proxy['id']})
Example #10
0
    def test_positive_delete_by_id(self):
        """Proxy deletion with the home proxy

        @Feature: Smart Proxy

        @Assert: Proxy is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                proxy = make_proxy({u'name': name})
                Proxy.delete({u'id': proxy['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Proxy.info({u'id': proxy['id']})
Example #11
0
    def test_positive_import_puppet_classes(self):
        """Import puppet classes from proxy

        :id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04

        :expectedresults: Puppet classes are imported from proxy

        :CaseImportance: Critical
        """
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = self._make_proxy({u'url': url})
            Proxy.import_classes({u'id': proxy['id']})
Example #12
0
    def test_positive_delete_by_id(self):
        """Proxy deletion with the home proxy

        @id: 1b6973b1-259d-4866-b36f-c2d5fb154035

        @Assert: Proxy is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                proxy = make_proxy({u'name': name})
                Proxy.delete({u'id': proxy['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Proxy.info({u'id': proxy['id']})
Example #13
0
    def test_positive_import_puppet_classes(self):
        """Import puppet classes from proxy

        :id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04

        :expectedresults: Puppet classes are imported from proxy

        :CaseImportance: Critical
        """
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = self._make_proxy({u'url': url})
            Proxy.import_classes({u'id': proxy['id']})
Example #14
0
    def test_proxy_delete(self, data):
        """@Test: Proxy deletion with the home proxy

        @Feature: Smart Proxy

        @Assert: Proxy is deleted

        """
        try:
            proxy = make_proxy({u'name': data['name']})
        except CLIFactoryError as err:
            self.fail(err)

        self.assertEquals(
            proxy['name'],
            data['name'], "Input and output name should be consistent")

        result = Proxy.info({u'id': proxy['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Proxy should be found"
        )
        self.assertEqual(
            len(result.stderr),
            0,
            "No error excepted"
        )
        result = Proxy.delete({u'id': proxy['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Proxy should be deleted"
        )
        self.assertEqual(
            len(result.stderr),
            0,
            "No error excepted"
        )

        result = Proxy.info({u'id': proxy['id']})
        self.assertNotEqual(
            result.return_code,
            0,
            "Proxy should not be found"
        )
        self.assertGreater(
            len(result.stderr),
            0,
            "Expected an error here"
        )
Example #15
0
def test_positive_import_puppet_classes(request):
    """Import puppet classes from proxy

    :id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04

    :expectedresults: Puppet classes are imported from proxy

    :CaseLevel: Component

    """
    port = get_available_capsule_port()
    with default_url_on_new_port(9090, port) as url:
        proxy = _make_proxy(request, {'url': url})
        Proxy.import_classes({'id': proxy['id']})
Example #16
0
    def test_positive_import_puppet_classes(self):
        """Import puppet classes from proxy

        @id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04

        @Assert: Puppet classes are imported from proxy
        """
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port):
            url = u'https://{0}:{1}'.format(settings.server.hostname, port)
            proxy = make_proxy({u'url': url})
            Proxy.importclasses({u'id': proxy['id']})
        # Add capsule id to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
Example #17
0
    def test_positive_import_puppet_classes(self):
        """Import puppet classes from proxy

        @id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04

        @Assert: Puppet classes are imported from proxy
        """
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port):
            url = u'https://{0}:{1}'.format(settings.server.hostname, port)
            proxy = make_proxy({u'url': url})
            Proxy.importclasses({u'id': proxy['id']})
        # Add capsule id to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
Example #18
0
    def test_positive_delete_by_id(self):
        """Proxy deletion with the home proxy

        :id: 1b6973b1-259d-4866-b36f-c2d5fb154035

        :expectedresults: Proxy is deleted

        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                proxy = make_proxy({u'name': name})
                Proxy.delete({'id': proxy['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Proxy.info({u'id': proxy['id']})
Example #19
0
 def setUp(self):
     """Create a host to use in tests"""
     super(HostDeleteTestCase, self).setUp()
     # Use the default installation smart proxy
     result = Proxy.list()
     self.assertGreater(len(result), 0)
     self.puppet_proxy = result[0]
     self.host = entities.Host()
     self.host.create_missing()
     self.host = Host.create({
         u'architecture-id': self.host.architecture.id,
         u'domain-id': self.host.domain.id,
         u'environment-id': self.host.environment.id,
         # pylint:disable=no-member
         u'location-id': self.host.location.id,
         u'mac': self.host.mac,
         u'medium-id': self.host.medium.id,
         u'name': gen_string('alphanumeric'),
         u'operatingsystem-id': self.host.operatingsystem.id,
         # pylint:disable=no-member
         u'organization-id': self.host.organization.id,
         u'partition-table-id': self.host.ptable.id,
         u'puppet-proxy-id': self.puppet_proxy['id'],
         u'root-pass': self.host.root_pass,
     })
Example #20
0
 def setUp(self):
     """Create a host to reuse later"""
     super(HostUpdateTestCase, self).setUp()
     self.proxies = Proxy.list()
     self.assertGreater(len(self.proxies), 0)
     self.puppet_proxy = self.proxies[0]
     # using nailgun to create dependencies
     self.host_args = entities.Host()
     self.host_args.create_missing()
     # using CLI to create host
     self.host = Host.create({
         u'architecture-id': self.host_args.architecture.id,
         u'domain-id': self.host_args.domain.id,
         u'environment-id': self.host_args.environment.id,
         # pylint:disable=no-member
         u'location-id': self.host_args.location.id,
         u'mac': self.host_args.mac,
         u'medium-id': self.host_args.medium.id,
         u'name': self.host_args.name,
         u'operatingsystem-id': self.host_args.operatingsystem.id,
         # pylint:disable=no-member
         u'organization-id': self.host_args.organization.id,
         u'partition-table-id': self.host_args.ptable.id,
         u'puppet-proxy-id': self.puppet_proxy['id'],
         u'root-pass': self.host_args.root_pass,
     })
Example #21
0
 def setUpClass(cls):
     """Create host to tests parameters for"""
     super(HostParameterTestCase, cls).setUpClass()
     cls.proxies = Proxy.list()
     assert len(cls.proxies) > 0
     cls.puppet_proxy = cls.proxies[0]
     # using nailgun to create dependencies
     cls.host = entities.Host()
     cls.host.create_missing()
     # using CLI to create host
     cls.host = Host.create({
         u'architecture-id': cls.host.architecture.id,
         u'domain-id': cls.host.domain.id,
         u'environment-id': cls.host.environment.id,
         u'location-id': cls.host.location.id,  # pylint:disable=no-member
         u'mac': cls.host.mac,
         u'medium-id': cls.host.medium.id,
         u'name': cls.host.name,
         u'operatingsystem-id': cls.host.operatingsystem.id,
         # pylint:disable=no-member
         u'organization-id': cls.host.organization.id,
         u'partition-table-id': cls.host.ptable.id,
         u'puppet-proxy-id': cls.puppet_proxy['id'],
         u'root-pass': cls.host.root_pass,
     })
Example #22
0
    def test_positive_refresh_features_by_id(self):
        """Refresh smart proxy features, search for proxy by id

        @Feature: Smart Proxy

        @Assert: Proxy features are refreshed
        """
        proxy = make_proxy()
        # parse the port number so we can reopen the SSH tunnel
        port_regexp = re.search(u':([0-9]+)', proxy['url'])
        if port_regexp:
            port = port_regexp.group(1)
            with default_url_on_new_port(9090, port):
                Proxy.refresh_features({u'id': proxy['id']})
        else:
            raise ValueError('Unable to parse port number from proxy URL')
Example #23
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have data to be able to perform interactions with smart
     class variables.
     """
     super(SmartVariablesTestCase, cls).setUpClass()
     cls.puppet_module = "puppetlabs/ntp"
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force {0}'.format(
         cls.puppet_module))
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
Example #24
0
def test_positive_import_puppet_classes(session_puppet_enabled_sat, puppet_proxy_port_range):
    """Import puppet classes from proxy

    :id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04

    :expectedresults: Puppet classes are imported from proxy

    :CaseLevel: Component

    """
    with session_puppet_enabled_sat:
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = make_proxy({'url': url})
            Proxy.import_classes({'id': proxy['id']})
        Proxy.delete({'id': proxy['id']})
Example #25
0
 def setUp(self):
     """Create a host to use in tests"""
     super(HostDeleteTestCase, self).setUp()
     # Use the default installation smart proxy
     result = Proxy.list()
     self.assertGreater(len(result), 0)
     self.puppet_proxy = result[0]
     self.host = entities.Host()
     self.host.create_missing()
     self.host = Host.create({
         u'architecture-id': self.host.architecture.id,
         u'domain-id': self.host.domain.id,
         u'environment-id': self.host.environment.id,
         # pylint:disable=no-member
         u'location-id': self.host.location.id,
         u'mac': self.host.mac,
         u'medium-id': self.host.medium.id,
         u'name': gen_string('alphanumeric'),
         u'operatingsystem-id': self.host.operatingsystem.id,
         # pylint:disable=no-member
         u'organization-id': self.host.organization.id,
         u'partition-table-id': self.host.ptable.id,
         u'puppet-proxy-id': self.puppet_proxy['id'],
         u'root-pass': self.host.root_pass,
     })
    def test_positive_update_content_source(self):
        """Update hostgroup's content source

        :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

        :customerscenario: true

        :BZ: 1260697, 1313056

        :expectedresults: Hostgroup was successfully updated with new content
            source

        :CaseImportance: High
        """
        content_source = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        new_content_source = make_proxy()
        self.addCleanup(capsule_cleanup, new_content_source['id'])
        self.addCleanup(HostGroup.delete, {'id': hostgroup['id']})
        HostGroup.update({
            'id': hostgroup['id'],
            'content-source-id': new_content_source['id'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(
            hostgroup['content-source']['name'], new_content_source['name'])
Example #27
0
 def setUpClass(cls):
     super(HostGroupTestCase, cls).setUpClass()
     cls.org = make_org()
     # Setup for puppet class related tests
     puppet_modules = [
         {
             'author': 'robottelo',
             'name': 'generic_1'
         },
         {
             'author': 'robottelo',
             'name': 'generic_2'
         },
     ]
     cls.cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO,
                                    cls.org['id'])
     cls.env = Environment.list(
         {'search': 'content_view="{0}"'.format(cls.cv['name'])})[0]
     cls.puppet_classes = [
         Puppet.info({
             'name': mod['name'],
             'puppet-environment': cls.env['name']
         }) for mod in puppet_modules
     ]
     cls.content_source = Proxy.list({
         'search':
         'url = https://{0}:9090'.format(settings.server.hostname)
     })[0]
     cls.hostgroup = make_hostgroup({
         'content-source-id':
         cls.content_source['id'],
         'organization-ids':
         cls.org['id']
     })
Example #28
0
    def test_positive_update_content_source(self):
        """Update hostgroup's content source

        :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde

        :customerscenario: true

        :BZ: 1260697, 1313056

        :expectedresults: Hostgroup was successfully updated with new content
            source

        :CaseImportance: High
        """
        content_source = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        new_content_source = make_proxy()
        self.addCleanup(capsule_cleanup, new_content_source['id'])
        self.addCleanup(HostGroup.delete, {'id': hostgroup['id']})
        HostGroup.update({
            'id': hostgroup['id'],
            'content-source-id': new_content_source['id'],
        })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(hostgroup['content-source']['name'],
                         new_content_source['name'])
    def test_negative_update_content_source(self):
        """Attempt to update hostgroup's content source with invalid value

        :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26

        :BZ: 1260697, 1313056

        :expectedresults: Host group was not updated. Content source remains
            the same as it was before update

        :CaseImportance: Medium
        """
        content_source = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        with self.assertRaises(CLIBaseError):
            HostGroup.update({
                'id': hostgroup['id'],
                'content-source-id': gen_integer(10000, 99999),
            })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(
            hostgroup['content-source']['name'], content_source['name'])
Example #30
0
    def test_negative_update_content_source(self):
        """Attempt to update hostgroup's content source with invalid value

        :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26

        :BZ: 1260697, 1313056

        :expectedresults: Host group was not updated. Content source remains
            the same as it was before update

        :CaseImportance: Medium
        """
        content_source = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({
            'content-source-id': content_source['id'],
            'organization-ids': self.org['id'],
        })
        with self.assertRaises(CLIReturnCodeError):
            HostGroup.update({
                'id': hostgroup['id'],
                'content-source-id': gen_integer(10000, 99999),
            })
        hostgroup = HostGroup.info({'id': hostgroup['id']})
        self.assertEqual(hostgroup['content-source']['name'],
                         content_source['name'])
Example #31
0
 def setUp(self):
     """Create a host to reuse later"""
     super(HostUpdateTestCase, self).setUp()
     self.proxies = Proxy.list()
     self.assertGreater(len(self.proxies), 0)
     self.puppet_proxy = self.proxies[0]
     # using nailgun to create dependencies
     self.host_args = entities.Host()
     self.host_args.create_missing()
     # using CLI to create host
     self.host = Host.create({
         u'architecture-id': self.host_args.architecture.id,
         u'domain-id': self.host_args.domain.id,
         u'environment-id': self.host_args.environment.id,
         # pylint:disable=no-member
         u'location-id': self.host_args.location.id,
         u'mac': self.host_args.mac,
         u'medium-id': self.host_args.medium.id,
         u'name': self.host_args.name,
         u'operatingsystem-id': self.host_args.operatingsystem.id,
         # pylint:disable=no-member
         u'organization-id': self.host_args.organization.id,
         u'partition-table-id': self.host_args.ptable.id,
         u'puppet-proxy-id': self.puppet_proxy['id'],
         u'root-pass': self.host_args.root_pass,
     })
Example #32
0
 def setUpClass(cls):
     """Create host to tests parameters for"""
     super(HostParameterTestCase, cls).setUpClass()
     cls.proxies = Proxy.list()
     assert len(cls.proxies) > 0
     cls.puppet_proxy = cls.proxies[0]
     # using nailgun to create dependencies
     cls.host = entities.Host()
     cls.host.create_missing()
     # using CLI to create host
     cls.host = Host.create({
         u'architecture-id': cls.host.architecture.id,
         u'domain-id': cls.host.domain.id,
         u'environment-id': cls.host.environment.id,
         u'location-id': cls.host.location.id,  # pylint:disable=no-member
         u'mac': cls.host.mac,
         u'medium-id': cls.host.medium.id,
         u'name': cls.host.name,
         u'operatingsystem-id': cls.host.operatingsystem.id,
         # pylint:disable=no-member
         u'organization-id': cls.host.organization.id,
         u'partition-table-id': cls.host.ptable.id,
         u'puppet-proxy-id': cls.puppet_proxy['id'],
         u'root-pass': cls.host.root_pass,
     })
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test. Raise an
     exception and skip all tests in case not enough parameters returned.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command("puppet module install --force puppetlabs/ntp")
     cls.env = Environment.info({u"name": "production"})
     Proxy.importclasses({u"environment": cls.env["name"], u"name": cls.host_name})
     cls.puppet = Puppet.info({u"name": "ntp"})
     sc_params_list = SmartClassParameter.list({"environment": cls.env["name"], "search": "puppetclass=ntp"})
     if len(sc_params_list) < 45:
         raise RuntimeError("There are not enough smart class parameters to" " work with in provided puppet class")
     cls.sc_params_ids_list = [sc_param["id"] for sc_param in sc_params_list]
Example #34
0
def test_positive_delete_by_id(name):
    """Proxy deletion with the home proxy

    :id: 1b6973b1-259d-4866-b36f-c2d5fb154035

    :expectedresults: Proxy is deleted

    :CaseLevel: Component

    :Parametrized: Yes

    :BZ: 1398695
    """
    proxy = make_proxy({'name': name})
    Proxy.delete({'id': proxy['id']})
    with pytest.raises(CLIReturnCodeError):
        Proxy.info({'id': proxy['id']})
Example #35
0
    def test_positive_refresh_features_by_name(self):
        """Refresh smart proxy features, search for proxy by name

        :id: 2ddd0097-8f65-430e-963d-a3b5dcffe86b

        :expectedresults: Proxy features are refreshed

        :CaseLevel: Integration
        """
        # Since we want to run multiple commands against our fake capsule, we
        # need the tunnel kept open in order not to allow different concurrent
        # test to claim it. Thus we want to manage the tunnel manually.

        # get an available port for our fake capsule
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = self._make_proxy({u'url': url})
            Proxy.refresh_features({u'id': proxy['name']})
Example #36
0
    def test_positive_refresh_features_by_id(self):
        """Refresh smart proxy features, search for proxy by id

        :id: d3db63ce-b877-40eb-a863-294c12489ddd

        :expectedresults: Proxy features are refreshed

        :CaseLevel: Integration
        """
        # Since we want to run multiple commands against our fake capsule, we
        # need the tunnel kept open in order not to allow different concurrent
        # test to claim it. Thus we want to manage the tunnel manually.

        # get an available port for our fake capsule
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = self._make_proxy({u'url': url})
            Proxy.refresh_features({u'id': proxy['id']})
Example #37
0
    def test_positive_refresh_features_by_id(self):
        """Refresh smart proxy features, search for proxy by id

        :id: d3db63ce-b877-40eb-a863-294c12489ddd

        :expectedresults: Proxy features are refreshed

        :CaseLevel: Integration
        """
        # Since we want to run multiple commands against our fake capsule, we
        # need the tunnel kept open in order not to allow different concurrent
        # test to claim it. Thus we want to manage the tunnel manually.

        # get an available port for our fake capsule
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = self._make_proxy({u'url': url})
            Proxy.refresh_features({u'id': proxy['id']})
Example #38
0
    def test_positive_refresh_features_by_name(self):
        """Refresh smart proxy features, search for proxy by name

        :id: 2ddd0097-8f65-430e-963d-a3b5dcffe86b

        :expectedresults: Proxy features are refreshed

        :CaseLevel: Integration
        """
        # Since we want to run multiple commands against our fake capsule, we
        # need the tunnel kept open in order not to allow different concurrent
        # test to claim it. Thus we want to manage the tunnel manually.

        # get an available port for our fake capsule
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port) as url:
            proxy = self._make_proxy({u'url': url})
            Proxy.refresh_features({u'id': proxy['name']})
Example #39
0
def default_proxy():
    """ Returns default capsule/proxy id"""
    proxy = Proxy.list({'search': settings.server.hostname})[0]
    p_features = set(proxy.get('features').split(', '))
    if {'Puppet', 'Ansible', 'Openscap'}.issubset(p_features):
        proxy_id = proxy.get('id')
    else:
        raise ProxyError('Some features like Puppet, DHCP, Openscap, Ansible are not present')
    return proxy_id
Example #40
0
def test_positive_update_name(request):
    """Proxy name update with the home proxy

    :id: 1a02a06b-e9ab-4b9b-bcb0-ac7060188316

    :expectedresults: Proxy has the name updated

    :CaseLevel: Component

    :BZ: 1398695
    """
    proxy = _make_proxy(request, {'name': gen_alphanumeric()})
    for new_name in valid_data_list().values():
        newport = get_available_capsule_port()
        with default_url_on_new_port(9090, newport) as url:
            Proxy.update({'id': proxy['id'], 'name': new_name, 'url': url})
            proxy = Proxy.info({'id': proxy['id']})
            assert proxy['name'] == new_name
Example #41
0
def default_proxy(module_target_sat):
    """Returns default capsule/proxy id"""
    proxy = Proxy.list({'search': module_target_sat.hostname})[0]
    p_features = set(proxy.get('features').split(', '))
    if {'Ansible', 'Openscap'}.issubset(p_features):
        proxy_id = proxy.get('id')
    else:
        raise ProxyError(
            'Some features like DHCP, Openscap, Ansible are not present')
    return proxy_id
Example #42
0
    def setUp(self):
        """Find an existing puppet proxy.

        Record information about this puppet proxy as ``self.puppet_proxy``.
        """
        super(HostCreateTestCase, self).setUp()
        # Use the default installation smart proxy
        result = Proxy.list()
        self.assertGreater(len(result), 0)
        self.puppet_proxy = result[0]
Example #43
0
    def setUp(self):
        """Find an existing puppet proxy.

        Record information about this puppet proxy as ``self.puppet_proxy``.
        """
        super(HostCreateTestCase, self).setUp()
        # Use the default installation smart proxy
        result = Proxy.list()
        self.assertGreater(len(result), 0)
        self.puppet_proxy = result[0]
Example #44
0
    def test_positive_update_name(self):
        """Proxy name update with the home proxy

        @Feature: Smart Proxy

        @Assert: Proxy has the name updated
        """
        proxy = make_proxy({u'name': gen_alphanumeric()})
        newport = random.randint(9091, 49090)
        for new_name in valid_data_list():
            with self.subTest(new_name):
                with default_url_on_new_port(9090, newport) as url:
                    Proxy.update({
                        u'id': proxy['id'],
                        u'name': new_name,
                        u'url': url,
                    })
                    proxy = Proxy.info({u'id': proxy['id']})
                    self.assertEqual(proxy['name'], new_name)
Example #45
0
    def test_create_hostgroup_with_puppet_proxy(self):
        """@Test: Check if hostgroup with puppet proxy server can be created

        @Feature: Hostgroup - Positive create

        @Assert: Hostgroup is created and has puppet proxy server assigned

        """
        puppet_proxy = Proxy.list()[0]
        hostgroup = make_hostgroup({"puppet-proxy": puppet_proxy["name"]})
        self.assertEqual(puppet_proxy["id"], hostgroup["puppet-master-proxy-id"])
Example #46
0
    def test_create_hostgroup_with_puppet_ca_proxy(self):
        """@Test: Check if hostgroup with puppet CA proxy server can be created

        @Feature: Hostgroup - Positive create

        @Assert: Hostgroup is created and has puppet CA proxy server assigned

        """
        puppet_proxy = Proxy.list()[0]
        hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']})
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
Example #47
0
    def test_positive_create_with_puppet_ca_proxy(self):
        """Check if hostgroup with puppet CA proxy server can be created

        @id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c

        @Assert: Hostgroup is created and has puppet CA proxy server assigned

        """
        puppet_proxy = Proxy.list()[0]
        hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']})
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
Example #48
0
    def test_positive_create_with_puppet_ca_proxy(self):
        """Check if hostgroup with puppet CA proxy server can be created

        @id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c

        @Assert: Hostgroup is created and has puppet CA proxy server assigned

        """
        puppet_proxy = Proxy.list()[0]
        hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']})
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
    def test_positive_create_with_puppet_ca_proxy(self):
        """Check if hostgroup with puppet CA proxy server can be created

        @Feature: Hostgroup - Positive create

        @Assert: Hostgroup is created and has puppet CA proxy server assigned

        """
        puppet_proxy = Proxy.list()[0]
        hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']})
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
Example #50
0
    def test_positive_refresh_features_by_id(self):
        """Refresh smart proxy features, search for proxy by id

        :id: d3db63ce-b877-40eb-a863-294c12489ddd

        :expectedresults: Proxy features are refreshed

        :CaseLevel: Integration
        """
        # Since we want to run multiple commands against our fake capsule, we
        # need the tunnel kept open in order not to allow different concurrent
        # test to claim it. Thus we want to manage the tunnel manually.

        # get an available port for our fake capsule
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port):
            url = u'https://{0}:{1}'.format(settings.server.hostname, port)
            proxy = make_proxy({u'url': url})
            Proxy.refresh_features({u'id': proxy['id']})
        # Add capsule id to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
Example #51
0
    def test_positive_update_name(self):
        """Proxy name update with the home proxy

        :id: 1a02a06b-e9ab-4b9b-bcb0-ac7060188316

        :expectedresults: Proxy has the name updated

        :CaseImportance: Critical
        """
        proxy = self._make_proxy({u'name': gen_alphanumeric()})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                newport = get_available_capsule_port()
                with default_url_on_new_port(9090, newport) as url:
                    Proxy.update({
                        u'id': proxy['id'],
                        u'name': new_name,
                        u'url': url,
                    })
                    proxy = Proxy.info({u'id': proxy['id']})
                    self.assertEqual(proxy['name'], new_name)
Example #52
0
    def test_positive_refresh_features_by_name(self):
        """Refresh smart proxy features, search for proxy by name

        @id: 2ddd0097-8f65-430e-963d-a3b5dcffe86b

        @Assert: Proxy features are refreshed

        @CaseLevel: Integration
        """
        # Since we want to run multiple commands against our fake capsule, we
        # need the tunnel kept open in order not to allow different concurrent
        # test to claim it. Thus we want to manage the tunnel manually.

        # get an available port for our fake capsule
        port = get_available_capsule_port()
        with default_url_on_new_port(9090, port):
            url = u'https://{0}:{1}'.format(settings.server.hostname, port)
            proxy = make_proxy({u'url': url})
            Proxy.refresh_features({u'id': proxy['name']})
        # Add capsule id to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
Example #53
0
    def test_positive_update_name(self):
        """Proxy name update with the home proxy

        @id: 1a02a06b-e9ab-4b9b-bcb0-ac7060188316

        @Assert: Proxy has the name updated
        """
        proxy = make_proxy({u'name': gen_alphanumeric()})
        for new_name in valid_data_list():
            with self.subTest(new_name):
                newport = get_available_capsule_port()
                with default_url_on_new_port(9090, newport) as url:
                    Proxy.update({
                        u'id': proxy['id'],
                        u'name': new_name,
                        u'url': url,
                    })
                    proxy = Proxy.info({u'id': proxy['id']})
                    self.assertEqual(proxy['name'], new_name)
        # Add capsule id to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
Example #54
0
    def setUp(self):
        """Find an existing puppet proxy.

        Record information about this puppet proxy as ``self.puppet_proxy``.

        """
        # Use the default installation smart proxy
        result = Proxy.list()
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertGreater(len(result.stdout), 0)
        self.puppet_proxy = result.stdout[0]
Example #55
0
    def test_positive_create_with_puppet_proxy(self):
        """Check if hostgroup with puppet proxy server can be created

        @id: 3a922d9f-7466-4565-b279-c1481f63a4ce

        @Assert: Hostgroup is created and has puppet proxy server assigned
        """
        puppet_proxy = Proxy.list()[0]
        hostgroup = make_hostgroup({'puppet-proxy': puppet_proxy['name']})
        self.assertEqual(
            puppet_proxy['id'],
            hostgroup['puppet-master-proxy-id'],
        )
Example #56
0
    def test_positive_create_with_puppet_ca_proxy(self):
        """Check if hostgroup with puppet CA proxy server can be created

        @id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c

        @Assert: Hostgroup is created and has puppet CA proxy server assigned

        """
        puppet_proxy = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']})
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
Example #57
0
    def test_proxy_update(self, data):
        """@Test: Proxy name update with the home proxy

        @Feature: Smart Proxy

        @Assert: Proxy has the name updated

        """
        try:
            proxy = make_proxy({u'name': data['name']})
        except CLIFactoryError as err:
            self.fail(err)

        self.assertEquals(
            proxy['name'],
            data['name'], "Input and output name should be consistent")

        with default_url_on_new_port(9090, random.randint(9091, 49090)) as url:
            result = Proxy.update({
                u'id': proxy['id'],
                u'name': data['update'],
                u'url': url})
        self.assertEqual(
            result.return_code,
            0,
            "Proxy should be updated"
        )
        result = Proxy.info({u'id': proxy['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Proxy should be found"
        )
        self.assertEqual(
            result.stdout['name'],
            data['update'],
            "Proxy name should be updated"
        )