コード例 #1
0
    def test_positive_run_custom_job_template(self):
        """Run custom job template against a single host

        :id: 71928f36-61b4-46e6-842c-a051cfd9a68e

        :expectedresults: Verify the job was successfully ran against the host
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.name,
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        invocation_command = make_job_invocation({
            'job-template': template_name,
            'search-query': "name ~ {0}".format(self.client.hostname),
        })
        try:
            self.assertEqual(invocation_command['success'], u'1')
        except AssertionError:
            result = 'host output: {0}'.format(
                ' '.join(JobInvocation.get_output({
                    'id': invocation_command[u'id'],
                    'host': self.client.hostname})
                    )
                )
            raise AssertionError(result)
コード例 #2
0
    def test_positive_run_custom_job_template_by_ip(self):
        """Run custom template on host connected by ip

        :id: 9740eb1d-59f5-42b2-b3ab-659ca0202c74

        :expectedresults: Verify the job was successfully ran against the host
        """
        # set connecting to host via ip
        Host.set_parameter({
            'host': self.client.hostname,
            'name': 'remote_execution_connect_by_ip',
            'value': 'True',
        })
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.org.name,
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        invocation_command = make_job_invocation({
            'job-template': template_name,
            'search-query': "name ~ {0}".format(self.client.hostname),
        })
        try:
            self.assertEqual(invocation_command['success'], u'1')
        except AssertionError:
            result = 'host output: {0}'.format(
                ' '.join(JobInvocation.get_output({
                    'id': invocation_command[u'id'],
                    'host': self.client.hostname})
                    )
                )
            raise AssertionError(result)
コード例 #3
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'})
コード例 #4
0
    def test_positive_run_custom_job_template_by_ip(self):
        """Run custom template on host connected by ip

        :id: 9740eb1d-59f5-42b2-b3ab-659ca0202c74

        :expectedresults: Verify the job was successfully ran against the host
        """
        # set connecting to host via ip
        Host.set_parameter({
            'host': self.client.hostname,
            'name': 'remote_execution_connect_by_ip',
            'value': 'True',
        })
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.org.name,
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        invocation_command = make_job_invocation({
            'job-template': template_name,
            'search-query': "name ~ {0}".format(self.client.hostname),
        })
        try:
            self.assertEqual(invocation_command['success'], u'1')
        except AssertionError:
            result = 'host output: {0}'.format(
                ' '.join(JobInvocation.get_output({
                    'id': invocation_command[u'id'],
                    'host': self.client.hostname})
                    )
                )
            raise AssertionError(result)
コード例 #5
0
    def test_positive_run_custom_job_template_by_ip(self, fixture_vmsetup, module_org):
        """Run custom template on host connected by ip

        :id: 9740eb1d-59f5-42b2-b3ab-659ca0202c74

        :expectedresults: Verify the job was successfully ran against the host

        :parametrized: yes
        """
        self.org = module_org
        client = fixture_vmsetup
        template_file = 'template_file.txt'
        ssh.command(f'echo "echo Enforcing" > {template_file}')
        template_name = gen_string('alpha', 7)
        make_job_template(
            {'organizations': self.org.name, 'name': template_name, 'file': template_file}
        )
        invocation_command = make_job_invocation(
            {'job-template': template_name, 'search-query': f"name ~ {client.hostname}"}
        )
        try:
            assert invocation_command['success'] == '1'
        except AssertionError:
            result = 'host output: {}'.format(
                ' '.join(
                    JobInvocation.get_output(
                        {'id': invocation_command['id'], 'host': client.hostname}
                    )
                )
            )
            raise AssertionError(result)
コード例 #6
0
    def test_positive_run_custom_job_template(self):
        """Run custom job template against a single host

        :id: 71928f36-61b4-46e6-842c-a051cfd9a68e

        :expectedresults: Verify the job was successfully ran against the host
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.name,
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        invocation_command = make_job_invocation({
            'job-template': template_name,
            'search-query': "name ~ {0}".format(self.client.hostname),
        })
        try:
            self.assertEqual(invocation_command['success'], u'1')
        except AssertionError:
            result = 'host output: {0}'.format(
                ' '.join(JobInvocation.get_output({
                    'id': invocation_command[u'id'],
                    'host': self.client.hostname})
                    )
                )
            raise AssertionError(result)
コード例 #7
0
    def test_negative_create_job_template_with_same_name(self):
        """Create Job Template with duplicate name

        :id: 66100c82-97f5-4300-a0c9-8cf041f7789f

        :expectedresults: The name duplication is caught and error is raised

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template(
            {
                'organizations': self.organization['name'],
                'name': template_name,
                'file': TEMPLATE_FILE,
            }
        )
        with self.assertRaisesRegex(CLIFactoryError, 'Could not create the job template:'):
            make_job_template(
                {
                    'organizations': self.organization['name'],
                    'name': template_name,
                    'file': TEMPLATE_FILE,
                }
            )
コード例 #8
0
    def test_positive_create_job_template(self):
        """Create a simple Job Template

        @id: a5a67b10-61b0-4362-b671-9d9f095c452c

        @Assert: The job template was successfully created
        """
        template_name = gen_string("alpha", 7)
        make_job_template({u"organizations": self.organization["name"], u"name": template_name, u"file": TEMPLATE_FILE})
        self.assertIsNotNone(JobTemplate.info({u"name": template_name}))
コード例 #9
0
    def test_positive_view_dump(self):
        """Export contents of a job template

        @id: 25fcfcaa-fc4c-425e-919e-330e36195c4a

        @Assert: Verify no errors are thrown
        """
        template_name = gen_string("alpha", 7)
        make_job_template({u"organizations": self.organization["name"], u"name": template_name, u"file": TEMPLATE_FILE})
        dumped_content = JobTemplate.dump({u"name": template_name})
        self.assertGreater(len(dumped_content), 0)
コード例 #10
0
    def test_negative_create_empty_job_template(self):
        """Create Job Template with empty template file

        @id: 749be863-94ae-4008-a242-c23f353ca404

        @Assert: The empty file is detected and error is raised
        """
        template_name = gen_string("alpha", 7)
        with self.assertRaisesRegex(CLIFactoryError, u"Could not create the job template:"):
            make_job_template(
                {u"organizations": self.organization["name"], u"name": template_name, u"file": TEMPLATE_FILE_EMPTY}
            )
コード例 #11
0
    def test_positive_delete_job_template(self):
        """Delete a job template

        @id: 33104c04-20e9-47aa-99da-4bf3414ea31a

        @Assert: The Job Template has been deleted
        """
        template_name = gen_string("alpha", 7)
        make_job_template({u"organizations": self.organization["name"], u"name": template_name, u"file": TEMPLATE_FILE})
        JobTemplate.delete({u"name": template_name})
        with self.assertRaises(CLIReturnCodeError):
            JobTemplate.info({u"name": template_name})
コード例 #12
0
    def test_negative_create_job_template_with_same_name(self):
        """Create Job Template with duplicate name

        @id: 66100c82-97f5-4300-a0c9-8cf041f7789f

        @Assert: The name duplication is caught and error is raised
        """
        template_name = gen_string("alpha", 7)
        make_job_template({u"organizations": self.organization["name"], u"name": template_name, u"file": TEMPLATE_FILE})
        with self.assertRaisesRegex(CLIFactoryError, u"Could not create the job template:"):
            make_job_template(
                {u"organizations": self.organization["name"], u"name": template_name, u"file": TEMPLATE_FILE}
            )
コード例 #13
0
    def test_positive_create_job_template(self):
        """Create a simple Job Template

        @id: a5a67b10-61b0-4362-b671-9d9f095c452c

        @Assert: The job template was successfully created
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        self.assertIsNotNone(JobTemplate.info({u'name': template_name}))
コード例 #14
0
    def test_negative_create_empty_job_template(self):
        """Create Job Template with empty template file

        @id: 749be863-94ae-4008-a242-c23f353ca404

        @Assert: The empty file is detected and error is raised
        """
        template_name = gen_string('alpha', 7)
        with self.assertRaisesRegex(CLIFactoryError,
                                    u'Could not create the job template:'):
            make_job_template({
                u'organizations': self.organization['name'],
                u'name': template_name,
                u'file': TEMPLATE_FILE_EMPTY
            })
コード例 #15
0
    def test_negative_create_job_template_with_invalid_name(self):
        """Create Job Template with invalid name

        @id: eb51afd4-e7b3-42c3-81c3-6e18ef3d7efe

        @Assert: Job Template with invalid name cannot be created and error is
        raised
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaisesRegex(CLIFactoryError, u"Could not create the job template:"):
                    for name in invalid_values_list():
                        make_job_template(
                            {u"organizations": self.organization["name"], u"name": name, u"file": TEMPLATE_FILE}
                        )
コード例 #16
0
    def test_positive_run_custom_job_template(self):
        """Run custom job template against a single host

        @id: 71928f36-61b4-46e6-842c-a051cfd9a68e

        @Assert: Verify the job was successfully ran against the host
        """
        template_name = gen_string("alpha", 7)
        make_job_template(
            {u"organizations": self.organization[u"name"], u"name": template_name, u"file": TEMPLATE_FILE}
        )
        invocation_command = make_job_invocation(
            {"job-template": template_name, "search-query": "name ~ {0}".format(self.client.hostname)}
        )
        self.assertEqual(invocation_command[u"success"], u"1")
コード例 #17
0
    def test_positive_view_dump(self):
        """Export contents of a job template

        @id: 25fcfcaa-fc4c-425e-919e-330e36195c4a

        @Assert: Verify no errors are thrown
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        dumped_content = JobTemplate.dump({u'name': template_name})
        self.assertGreater(len(dumped_content), 0)
コード例 #18
0
def test_positive_view_dump(module_org):
    """Export contents of a job template

    :id: 25fcfcaa-fc4c-425e-919e-330e36195c4a

    :expectedresults: Verify no errors are thrown

    """
    template_name = gen_string('alpha', 7)
    make_job_template({
        'organizations': module_org.name,
        'name': template_name,
        'file': TEMPLATE_FILE,
    })
    dumped_content = JobTemplate.dump({'name': template_name})
    assert len(dumped_content) > 0
コード例 #19
0
    def test_positive_delete_job_template(self):
        """Delete a job template

        @id: 33104c04-20e9-47aa-99da-4bf3414ea31a

        @Assert: The Job Template has been deleted
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        JobTemplate.delete({u'name': template_name})
        with self.assertRaises(CLIReturnCodeError):
            JobTemplate.info({u'name': template_name})
コード例 #20
0
ファイル: test_jobtemplate.py プロジェクト: tstrych/robottelo
    def test_positive_create_job_template(self):
        """Create a simple Job Template

        :id: a5a67b10-61b0-4362-b671-9d9f095c452c

        :expectedresults: The job template was successfully created

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            'organizations': self.organization['name'],
            'name': template_name,
            'file': TEMPLATE_FILE,
        })
        self.assertIsNotNone(JobTemplate.info({'name': template_name}))
コード例 #21
0
ファイル: test_jobtemplate.py プロジェクト: tstrych/robottelo
    def test_negative_create_empty_job_template(self):
        """Create Job Template with empty template file

        :id: 749be863-94ae-4008-a242-c23f353ca404

        :expectedresults: The empty file is detected and error is raised

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        with self.assertRaisesRegex(CLIFactoryError,
                                    'Could not create the job template:'):
            make_job_template({
                'organizations': self.organization['name'],
                'name': template_name,
                'file': TEMPLATE_FILE_EMPTY,
            })
コード例 #22
0
    def test_positive_view_dump(self):
        """Export contents of a job template

        :id: 25fcfcaa-fc4c-425e-919e-330e36195c4a

        :expectedresults: Verify no errors are thrown

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        dumped_content = JobTemplate.dump({u'name': template_name})
        self.assertGreater(len(dumped_content), 0)
コード例 #23
0
    def test_positive_create_job_template(self):
        """Create a simple Job Template

        :id: a5a67b10-61b0-4362-b671-9d9f095c452c

        :expectedresults: The job template was successfully created

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        self.assertIsNotNone(
            JobTemplate.info({u'name': template_name})
        )
コード例 #24
0
    def test_positive_delete_job_template(self):
        """Delete a job template

        :id: 33104c04-20e9-47aa-99da-4bf3414ea31a

        :expectedresults: The Job Template has been deleted

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        JobTemplate.delete({u'name': template_name})
        with self.assertRaises(CLIReturnCodeError):
            JobTemplate.info({u'name': template_name})
コード例 #25
0
ファイル: test_jobtemplate.py プロジェクト: tstrych/robottelo
    def test_positive_delete_job_template(self):
        """Delete a job template

        :id: 33104c04-20e9-47aa-99da-4bf3414ea31a

        :expectedresults: The Job Template has been deleted

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            'organizations': self.organization['name'],
            'name': template_name,
            'file': TEMPLATE_FILE,
        })
        JobTemplate.delete({'name': template_name})
        with self.assertRaises(CLIReturnCodeError):
            JobTemplate.info({'name': template_name})
コード例 #26
0
def test_negative_create_job_template_with_invalid_name(module_org, name):
    """Create Job Template with invalid name

    :id: eb51afd4-e7b3-42c3-81c3-6e18ef3d7efe

    :parametrized: yes

    :expectedresults: Job Template with invalid name cannot be created and
        error is raised

    :CaseImportance: Critical
    """
    with pytest.raises(CLIFactoryError,
                       match='Could not create the job template:'):
        make_job_template({
            'organizations': module_org.name,
            'name': name,
            'file': TEMPLATE_FILE,
        })
コード例 #27
0
    def test_negative_create_empty_job_template(self):
        """Create Job Template with empty template file

        :id: 749be863-94ae-4008-a242-c23f353ca404

        :expectedresults: The empty file is detected and error is raised

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        with self.assertRaisesRegex(
            CLIFactoryError,
            u'Could not create the job template:'
        ):
            make_job_template({
                u'organizations': self.organization['name'],
                u'name': template_name,
                u'file': TEMPLATE_FILE_EMPTY
            })
コード例 #28
0
    def test_positive_run_custom_job_template_by_ip(self, rex_contenthost,
                                                    module_org, default_sat):
        """Run custom template on host connected by ip

        :id: 9740eb1d-59f5-42b2-b3ab-659ca0202c74

        :expectedresults: Verify the job was successfully ran against the host

        :bz: 1872688, 1811166

        :customerscenario: true

        :CaseImportance: Critical

        :parametrized: yes
        """
        self.org = module_org
        client = rex_contenthost
        template_file = 'template_file.txt'
        default_sat.execute(f'echo "echo Enforcing" > {template_file}')
        template_name = gen_string('alpha', 7)
        make_job_template({
            'organizations': self.org.name,
            'name': template_name,
            'file': template_file
        })
        invocation_command = make_job_invocation({
            'job-template':
            template_name,
            'search-query':
            f'name ~ {client.hostname}'
        })
        result = JobInvocation.info({'id': invocation_command['id']})
        try:
            assert result['success'] == '1'
        except AssertionError:
            result = 'host output: {}'.format(' '.join(
                JobInvocation.get_output({
                    'id': invocation_command['id'],
                    'host': client.hostname
                })))
            raise AssertionError(result)
コード例 #29
0
    def test_positive_run_custom_job_template(self):
        """Run custom job template against a single host

        @id: 71928f36-61b4-46e6-842c-a051cfd9a68e

        @Assert: Verify the job was successfully ran against the host
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization[u'name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        invocation_command = make_job_invocation({
            'job-template':
            template_name,
            'search-query':
            "name ~ {0}".format(self.client.hostname),
        })
        self.assertEqual(invocation_command[u'success'], u'1')
コード例 #30
0
    def test_negative_create_job_template_with_same_name(self):
        """Create Job Template with duplicate name

        @id: 66100c82-97f5-4300-a0c9-8cf041f7789f

        @Assert: The name duplication is caught and error is raised
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        with self.assertRaisesRegex(CLIFactoryError,
                                    u'Could not create the job template:'):
            make_job_template({
                u'organizations': self.organization['name'],
                u'name': template_name,
                u'file': TEMPLATE_FILE
            })
コード例 #31
0
    def test_negative_create_job_template_with_invalid_name(self):
        """Create Job Template with invalid name

        :id: eb51afd4-e7b3-42c3-81c3-6e18ef3d7efe

        :expectedresults: Job Template with invalid name cannot be created and
            error is raised

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaisesRegex(CLIFactoryError, 'Could not create the job template:'):
                    make_job_template(
                        {
                            'organizations': self.organization['name'],
                            'name': name,
                            'file': TEMPLATE_FILE,
                        }
                    )
コード例 #32
0
    def test_negative_create_job_template_with_invalid_name(self):
        """Create Job Template with invalid name

        :id: eb51afd4-e7b3-42c3-81c3-6e18ef3d7efe

        :expectedresults: Job Template with invalid name cannot be created and
            error is raised

        :CaseImportance: Critical
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaisesRegex(
                    CLIFactoryError,
                    u'Could not create the job template:'
                ):
                    make_job_template({
                        u'organizations': self.organization['name'],
                        u'name': name,
                        u'file': TEMPLATE_FILE
                    })
コード例 #33
0
    def test_negative_create_job_template_with_invalid_name(self):
        """Create Job Template with invalid name

        @id: eb51afd4-e7b3-42c3-81c3-6e18ef3d7efe

        @Assert: Job Template with invalid name cannot be created and error is
        raised
        """
        for name in invalid_values_list():
            with self.subTest(name):
                with self.assertRaisesRegex(
                        CLIFactoryError,
                        u'Could not create the job template:'):
                    for name in invalid_values_list():
                        make_job_template({
                            u'organizations':
                            self.organization['name'],
                            u'name':
                            name,
                            u'file':
                            TEMPLATE_FILE
                        })
コード例 #34
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'})
コード例 #35
0
    def test_negative_create_job_template_with_same_name(self):
        """Create Job Template with duplicate name

        :id: 66100c82-97f5-4300-a0c9-8cf041f7789f

        :expectedresults: The name duplication is caught and error is raised

        :CaseImportance: Critical
        """
        template_name = gen_string('alpha', 7)
        make_job_template({
            u'organizations': self.organization['name'],
            u'name': template_name,
            u'file': TEMPLATE_FILE
        })
        with self.assertRaisesRegex(
            CLIFactoryError,
            u'Could not create the job template:'
        ):
            make_job_template({
                u'organizations': self.organization['name'],
                u'name': template_name,
                u'file': TEMPLATE_FILE
            })