コード例 #1
0
def ssh_client(vm_obj, console_template):
    """Provide vm_ssh_client for ssh operations in the test."""
    console_vm_username = credentials.get(console_template.creds).username
    console_vm_password = credentials.get(console_template.creds).password
    with ssh.SSHClient(hostname=vm_obj.ip_address, username=console_vm_username,
            password=console_vm_password) as vm_ssh_client:
        yield vm_ssh_client
コード例 #2
0
def ssh_client(vm_obj, console_template):
    """Provide vm_ssh_client for ssh operations in the test."""
    console_vm_username = credentials.get(console_template.creds).username
    console_vm_password = credentials.get(console_template.creds).password
    with ssh.SSHClient(hostname=vm_obj.ip_address, username=console_vm_username,
            password=console_vm_password) as vm_ssh_client:
        yield vm_ssh_client
コード例 #3
0
ファイル: bz.py プロジェクト: LandoCalrizzian/cfme_tests
 def from_config(cls):
     url = cfme_data.get("bugzilla", {}).get("url")
     product = cfme_data.get("bugzilla", {}).get("product")
     if url is None:
         raise Exception("No Bugzilla URL specified!")
     cr_root = cfme_data.get("bugzilla", {}).get("credentials")
     username = credentials.get(cr_root, {}).get("username")
     password = credentials.get(cr_root, {}).get("password")
     return cls(
         url=url, user=username, password=password, cookiefile=None,
         tokenfile=None, product=product)
コード例 #4
0
ファイル: client.py プロジェクト: hhovsepy/cfme_tests
 def from_config(cls, **kwargs):
     host = env.get("sprout", {}).get("hostname", "localhost")
     port = env.get("sprout", {}).get("port", 8000)
     user = os.environ.get("SPROUT_USER", credentials.get("sprout", {}).get("username"))
     password = os.environ.get(
         "SPROUT_PASSWORD", credentials.get("sprout", {}).get("password"))
     if user and password:
         auth = user, password
     else:
         auth = None
     return cls(host=host, port=port, auth=auth, **kwargs)
コード例 #5
0
ファイル: bz.py プロジェクト: t-fischer/integration_tests
 def from_config(cls):
     url = cfme_data.get("bugzilla", {}).get("url")
     product = cfme_data.get("bugzilla", {}).get("product")
     if url is None:
         raise Exception("No Bugzilla URL specified!")
     cr_root = cfme_data.get("bugzilla", {}).get("credentials")
     username = credentials.get(cr_root, {}).get("username")
     password = credentials.get(cr_root, {}).get("password")
     return cls(
         url=url, user=username, password=password, cookiefile=None,
         tokenfile=None, product=product)
コード例 #6
0
ファイル: client.py プロジェクト: okolisny/integration_tests
 def from_config(cls, **kwargs):
     host = env.get("sprout", {}).get("hostname", "localhost")
     port = env.get("sprout", {}).get("port", 8000)
     user = os.environ.get("SPROUT_USER",
                           credentials.get("sprout", {}).get("username"))
     password = os.environ.get(
         "SPROUT_PASSWORD",
         credentials.get("sprout", {}).get("password"))
     if user and password:
         auth = user, password
     else:
         auth = None
     return cls(host=host, port=port, auth=auth, **kwargs)
コード例 #7
0
ファイル: bz.py プロジェクト: amritrajck/integration_tests
 def from_config(cls):
     bz_conf = env.get('bugzilla', {})  # default empty so we can call .get() later
     url = bz_conf.get('url')
     if url is None:
         url = 'https://bugzilla.redhat.com/xmlrpc.cgi'
         logger.warning("No Bugzilla URL specified in conf, using default: %s", url)
     cred_key = bz_conf.get("bugzilla", {}).get("credentials")
     return cls(url=url,
                user=credentials.get(cred_key, {}).get("username"),
                password=credentials.get(cred_key, {}).get("password"),
                cookiefile=None,
                tokenfile=None,
                product=bz_conf.get("bugzilla", {}).get("product"))
コード例 #8
0
ファイル: bz.py プロジェクト: lcouzens/cfme_tests
 def from_config(cls):
     bz_conf = env.get('bugzilla', {})  # default empty so we can call .get() later
     url = bz_conf.get('url')
     if url is None:
         url = 'https://bugzilla.redhat.com/xmlrpc.cgi'
         logger.warning("No Bugzilla URL specified in conf, using default: %s", url)
     cred_key = bz_conf.get("bugzilla", {}).get("credentials")
     return cls(url=url,
                user=credentials.get(cred_key, {}).get("username"),
                password=credentials.get(cred_key, {}).get("password"),
                cookiefile=None,
                tokenfile=None,
                product=bz_conf.get("bugzilla", {}).get("product"),
                config_options=bz_conf)
コード例 #9
0
 def from_config(cls, **kwargs):
     host = env.get("sprout", {}).get("hostname", "localhost")
     port = env.get("sprout", {}).get("port", 8000)
     user_key = kwargs.pop('sprout_user_key') if 'sprout_user_key' in kwargs else None
     # First choose env var creds, then look in kwargs for a sprout_user_key to lookup
     user = (os.environ.get("SPROUT_USER") or
             (credentials.get(user_key, {}).get("username") if user_key else None))
     password = (os.environ.get("SPROUT_PASSWORD") or
                 (credentials.get(user_key, {}).get("password") if user_key else None))
     if user and password:
         auth = user, password
     else:
         auth = None
     return cls(host=host, port=port, auth=auth, **kwargs)
コード例 #10
0
ファイル: bz.py プロジェクト: shahmitul/integration_tests
    def from_config(cls):
        bz_conf = env.get('bugzilla', {})  # default empty so we can call .get() later
        url = bz_conf.get('url')
        if url is None:
            url = 'https://bugzilla.redhat.com/xmlrpc.cgi'
            logger.warning("No Bugzilla URL specified in conf, using default: %s", url)
        cred_key = bz_conf.get("credentials")
        bz_kwargs = dict(
            url=url,
            cookiefile=None,
            tokenfile=None,
            product=bz_conf.get("bugzilla", {}).get("product"),
            config_options=bz_conf)
        if cred_key:
            bz_creds = credentials.get(cred_key, {})
            if bz_creds.get('username'):
                logger.info('Using username/password for Bugzilla authentication')
                bz_kwargs.update(dict(
                    user=bz_creds.get("username"),
                    password=bz_creds.get("password")
                ))
            elif bz_creds.get('api_key'):
                logger.info('Using api key for Bugzilla authentication')
                bz_kwargs.update(dict(api_key=bz_creds.get('api_key')))
            else:
                logger.error('Credentials key for bugzilla does not have username or api key')
        else:
            logger.warn('No credentials found for bugzilla')

        return cls(**bz_kwargs)
コード例 #11
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    current_appliance = get_or_create_current_appliance()
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = current_appliance.address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    with SSHClient(**connect_kwargs) as ipaserver_ssh:
        ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
        ipaserver_ssh.run_command(
            "sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
        command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address,
                                                       appliance_fqdn)
        ipaserver_ssh.run_command(command)
    with current_appliance.ssh_client as ssh:
        result = ssh.run_command(
            'appliance_console_cli --host {}'.format(appliance_fqdn)).success
        if not current_appliance.is_pod:
            assert result
        else:
            # appliance_console_cli fails when calls hostnamectl --host. it seems docker issue
            # raise BZ ?
            assert str(ssh.run_command('hostname')).rstrip() == appliance_fqdn

        ensure_browser_open()
        current_appliance.server.login_admin()

        if data["ipaserver"] not in (
                current_appliance.server.settings.ntp_servers_form.values()):
            current_appliance.server.settings.update_ntp_servers(
                {'ntp_server_1': data["ipaserver"]})
            sleep(120)
        appliance.server.authentication.set_auth_mode(mode='external',
                                                      get_groups=data.pop(
                                                          "get_groups", False))
        creds = credentials.get(data.pop("credentials"), {})
        data.update(**creds)
        assert ssh.run_command(
            "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
            "--ipaprincipal {principal} --ipapassword {password}".format(
                **data))
    current_appliance.server.login_admin()
コード例 #12
0
ファイル: ext_auth.py プロジェクト: hhovsepy/cfme_tests
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    current_appliance = get_or_create_current_appliance()
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = current_appliance.hostname
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    with SSHClient(**connect_kwargs) as ipaserver_ssh:
        ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
        ipaserver_ssh.run_command("sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
        command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
        ipaserver_ssh.run_command(command)
    with current_appliance.ssh_client as ssh:
        result = ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn)).success
        if not current_appliance.is_pod:
            assert result
        else:
            # appliance_console_cli fails when calls hostnamectl --host. it seems docker issue
            # raise BZ ?
            assert str(ssh.run_command('hostname')).rstrip() == appliance_fqdn

        ensure_browser_open()
        current_appliance.server.login_admin()

        if data["ipaserver"] not in (
                current_appliance.server.settings.ntp_servers_values):
            current_appliance.server.settings.update_ntp_servers(
                {'ntp_server_1': data["ipaserver"]})
            sleep(120)
        current_appliance.server.authentication.set_auth_mode(
            mode='external', get_groups=data.pop("get_groups", False)
        )
        creds = credentials.get(data.pop("credentials"), {})
        data.update(**creds)
        assert ssh.run_command(
            "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
            "--ipaprincipal {principal} --ipapassword {password}".format(**data)
        )
    current_appliance.server.login_admin()
コード例 #13
0
ファイル: bz.py プロジェクト: xlab-si/integration_tests
    def logged_into_bugzilla(self):
        bz_creds = credentials.get("bugzilla", None)

        # login to bzapi
        if not bz_creds:
            # error out if there are no creds available in yamls
            raise BugzillaError("No creds available to log into Bugzilla")
        try:
            yield self.bugzilla.login(bz_creds.get("username"), bz_creds.get("password"))
        except BugzillaError:
            logger.exception("Unable to login to Bugzilla with those creds.")
            raise
        else:
            self.bugzilla.logout()
コード例 #14
0
def test_multiple_host_good_creds(setup_provider, provider, creds):
    """

    Bugzilla:
        1619626
        1201092

    Polarion:
        assignee: nachandr
        casecomponent: Infra
        initialEstimate: 1/4h
    """
    if len(provider.data.get('hosts', {})) < 2:
        pytest.skip('not enough hosts to run test')
    """  Tests multiple host credentialing  with good credentials """
    host = random.choice(provider.data["hosts"])
    host_creds = credentials.get(host['credentials'].get(creds, None), None)
    if not host_creds:
        pytest.skip(
            "This host {} doesn't have necessary creds {}. skipping test. "
            "Please check yaml data".format(host, creds))
    cred = Credential(principal=host_creds.username,
                      secret=host_creds.password)

    edit_view = navigate_and_select_quads(provider=provider)

    # Fill form with valid credentials for default endpoint and validate
    edit_view.endpoints.default.fill_with(cred.view_value_mapping)
    edit_view.validation_host.fill(host.name)
    edit_view.endpoints.default.validate_button.click()

    edit_view.flash.assert_no_error()
    edit_view.flash.assert_success_message(
        'Credential validation was successful')

    # Save changes
    edit_view.save_button.click()
    view = provider.create_view(ProviderNodesView)
    view.flash.assert_no_error()
    view.flash.assert_success_message(
        'Credentials/Settings saved successfully')
コード例 #15
0
ファイル: test_host.py プロジェクト: apagac/cfme_tests
def test_multiple_host_good_creds(setup_provider, provider, creds):
    """

    Bugzilla:
        1619626
        1201092

    Polarion:
        assignee: nachandr
        casecomponent: Infra
        initialEstimate: 1/4h
    """
    if len(provider.data.get('hosts', {})) < 2:
        pytest.skip('not enough hosts to run test')
    """  Tests multiple host credentialing  with good credentials """
    host = random.choice(provider.data["hosts"])
    host_creds = credentials.get(host['credentials'].get(creds, None), None)
    if not host_creds:
        pytest.skip("This host {} doesn't have necessary creds {}. skipping test. "
                    "Please check yaml data".format(host, creds))
    cred = Credential(principal=host_creds.username, secret=host_creds.password)

    edit_view = navigate_and_select_quads(provider=provider)

    # Fill form with valid credentials for default endpoint and validate
    edit_view.endpoints.default.fill_with(cred.view_value_mapping)
    edit_view.validation_host.fill(host.name)
    edit_view.endpoints.default.validate_button.click()

    edit_view.flash.assert_no_error()
    edit_view.flash.assert_success_message('Credential validation was successful')

    # Save changes
    edit_view.save_button.click()
    view = provider.create_view(ProviderNodesView)
    view.flash.assert_no_error()
    view.flash.assert_success_message('Credentials/Settings saved successfully')
コード例 #16
0
import os.path
from datetime import datetime

import requests

from artifactor.plugins.post_result import test_report
from cfme.utils.conf import cfme_data, credentials
from cfme.utils.trackerbot import post_jenkins_result

job_name = os.environ['JOB_NAME']
number = int(os.environ['BUILD_NUMBER'])
date = str(datetime.now())

# no env var for build status, have to query Jenkins API directly and parse json
jenkins_url = cfme_data.jenkins.url
jenkins_user = credentials.get(cfme_data.jenkins.credentials).msgbus_username
jenkins_token = credentials.get(cfme_data.jenkins.credentials).msgbus_token
build_data_url = '/'.join([jenkins_url, 'job', job_name, 'lastBuild', 'api', 'json'])
build_data = requests.get(build_data_url,
                          verify=False,
                          auth=(jenkins_user, jenkins_token))
if build_data.status_code != 200:
    raise ValueError('Bad return status ({}) from jenkins lastBuild API url: {}'
                     .format(build_data.status_code, build_data_url))
else:
    build_data_json = build_data.json()

build_status = build_data_json.get('result')

stream = os.environ['stream']
template = os.environ['appliance_template']
コード例 #17
0
import os.path
from datetime import datetime

import requests

from artifactor.plugins.post_result import test_report
from cfme.utils.conf import cfme_data, credentials
from cfme.utils.trackerbot import post_jenkins_result

job_name = os.environ['JOB_NAME']
number = int(os.environ['BUILD_NUMBER'])
date = str(datetime.now())

# no env var for build status, have to query Jenkins API directly and parse json
jenkins_url = cfme_data.jenkins.url
jenkins_user = credentials.get(cfme_data.jenkins.credentials).msgbus_username
jenkins_token = credentials.get(cfme_data.jenkins.credentials).msgbus_token
build_data_url = '/'.join(
    [jenkins_url, 'job', job_name, 'lastBuild', 'api', 'json'])
build_data = requests.get(build_data_url,
                          verify=False,
                          auth=(jenkins_user, jenkins_token))
if build_data.status_code != 200:
    raise ValueError(
        'Bad return status ({}) from jenkins lastBuild API url: {}'.format(
            build_data.status_code, build_data_url))
else:
    build_data_json = build_data.json()

build_status = build_data_json.get('result')