예제 #1
0
def update_registration(appliance_set, rh_updates_data, reg_method):
    reg_data = rh_updates_data['registration'][reg_method]
    test_proxy = reg_data.get('use_http_proxy', False)

    if test_proxy:
        proxy = rh_updates_data['registration']['http_proxy']
        proxy_creds = conf.credentials['http_proxy']
    else:
        proxy = None
        proxy_creds = {}

    if reg_method in ('rhsm', 'sat6'):
        repo_or_channel = reg_data.get('enable_repo', None)
    else:
        repo_or_channel = reg_data.get('add_channel', None)

    with appliance_set.primary.browser_session():
        red_hat_updates.update_registration(
            service=reg_method,
            url=reg_data['url'],
            username=conf.credentials[reg_method]['username'],
            password=conf.credentials[reg_method]['password'],
            repo_name=repo_or_channel,
            organization=reg_data.get('organization', None),
            use_proxy=test_proxy,
            proxy_url=proxy['url'],
            proxy_username=proxy_creds['username'],
            proxy_password=proxy_creds['password']
        )
def test_rh_creds_validation(request, reg_method, reg_data, proxy_url,
                             proxy_creds):
    """ Tests whether credentials are validated correctly for RHSM and SAT6 """
    repo = reg_data.get('enable_repo')
    if not repo:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds['username']
        proxy_password = proxy_creds['password']
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data['url'],
        username=conf.credentials[reg_method]['username'],
        password=conf.credentials[reg_method]['password'],
        repo_name=repo,
        organization=reg_data.get('organization'),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        cancel=True)
예제 #3
0
def update_registration(appliance_set, rh_updates_data, reg_method):
    reg_data = rh_updates_data['registration'][reg_method]
    test_proxy = reg_data.get('use_http_proxy', False)

    if test_proxy:
        proxy = rh_updates_data['registration']['http_proxy']
        proxy_creds = conf.credentials['http_proxy']
    else:
        proxy = None
        proxy_creds = {}

    if reg_method in ('rhsm', 'sat6'):
        repo_or_channel = reg_data.get('enable_repo', None)
    else:
        repo_or_channel = reg_data.get('add_channel', None)

    appliance_set.primary.browser_steal = True
    with appliance_set.primary():
        red_hat_updates.update_registration(
            service=reg_method,
            url=reg_data['url'],
            username=conf.credentials[reg_method]['username'],
            password=conf.credentials[reg_method]['password'],
            repo_name=repo_or_channel,
            organization=reg_data.get('organization', None),
            use_proxy=test_proxy,
            proxy_url=proxy['url'],
            proxy_username=proxy_creds['username'],
            proxy_password=proxy_creds['password'])
def test_rh_creds_validation(request, unset_org_id, reg_method, reg_data,
                             proxy_url, proxy_creds):
    if reg_method in ('rhsm', 'sat6'):
        repo_or_channel = reg_data.get('enable_repo')
    else:
        repo_or_channel = reg_data.get('add_channel')

    if not repo_or_channel:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds['username']
        proxy_password = proxy_creds['password']
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data['url'],
        username=conf.credentials[reg_method]['username'],
        password=conf.credentials[reg_method]['password'],
        repo_name=repo_or_channel,
        organization=reg_data.get('organization'),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        cancel=True)
def test_rh_creds_validation(request, unset_org_id, reg_method, reg_data, proxy_url, proxy_creds):
    if reg_method in ("rhsm", "sat6"):
        repo_or_channel = reg_data.get("enable_repo", None)
    else:
        repo_or_channel = reg_data.get("add_channel", None)

    if not repo_or_channel:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds["username"]
        proxy_password = proxy_creds["password"]
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data["url"],
        username=conf.credentials[reg_method]["username"],
        password=conf.credentials[reg_method]["password"],
        repo_name=repo_or_channel,
        organization=reg_data.get("organization", None),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        cancel=True,
    )
예제 #6
0
def test_rh_registration(request, unset_org_id,
                         reg_method, reg_data, proxy_url, proxy_creds):

    if reg_method in ('rhsm', 'sat6'):
        repo_or_channel = reg_data.get('enable_repo', None)
    else:
        repo_or_channel = reg_data.get('add_channel', None)

    if not repo_or_channel:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds['username']
        proxy_password = proxy_creds['password']
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data['url'],
        username=conf.credentials[reg_method]['username'],
        password=conf.credentials[reg_method]['password'],
        repo_name=repo_or_channel,
        organization=reg_data.get('organization', None),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        # Satellite 6 registration requires validation to be able to choose organization
        validate=False if reg_method != 'sat6' else True
    )

    used_repo_or_channel = InfoBlock('Red Hat Software Updates', version.pick({
        version.LOWEST: 'Update Repository',
        "5.4": 'Channel Name(s)' if reg_method == 'sat5' else 'Repository Name(s)'})
    ).text

    red_hat_updates.register_appliances()  # Register all

    if reg_method == 'rhsm':
        request.addfinalizer(rhsm_unregister)
    elif reg_method == 'sat5':
        request.addfinalizer(sat5_unregister)
    else:
        request.addfinalizer(sat6_unregister)

    wait_for(
        func=is_registration_complete,
        func_args=[used_repo_or_channel],
        delay=40,
        num_sec=400,
        fail_func=red_hat_updates.register_appliances
    )
def test_sat5_incorrect_url_format_check(request, unset_org_id):
    # Check that we weren't allowed to save the data
    with error.expected("No matching flash message"):
        red_hat_updates.update_registration(
            service="sat5", url="url.not.matching.format.example.com", username="******", password="******"
        )
    # Confirm that it was the Sat5 url check that blocked it
    flash.assert_message_contain("https://server.example.com/XMLRPC")
def test_rh_registration(request, unset_org_id,
                         reg_method, reg_data, proxy_url, proxy_creds):

    if reg_method in ('rhsm', 'sat6'):
        repo_or_channel = reg_data.get('enable_repo', None)
    else:
        repo_or_channel = reg_data.get('add_channel', None)

    if not repo_or_channel:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds['username']
        proxy_password = proxy_creds['password']
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data['url'],
        username=conf.credentials[reg_method]['username'],
        password=conf.credentials[reg_method]['password'],
        repo_name=repo_or_channel,
        organization=reg_data.get('organization', None),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        # Satellite 6 registration requires validation to be able to choose organization
        validate=False if reg_method != 'sat6' else True
    )

    used_repo_or_channel = InfoBlock('Red Hat Software Updates', 'Update Repository').text

    red_hat_updates.register_appliances()  # Register all

    if reg_method == 'rhsm':
        request.addfinalizer(rhsm_unregister)
    elif reg_method == 'sat5':
        request.addfinalizer(sat5_unregister)
    else:
        request.addfinalizer(sat6_unregister)

    wait_for(
        func=is_registration_complete,
        func_args=[used_repo_or_channel],
        delay=40,
        num_sec=400,
        fail_func=red_hat_updates.register_appliances
    )
def test_sat5_incorrect_url_format_check(request, unset_org_id):
    # Check that we weren't allowed to save the data
    with error.expected('No matching flash message'):
        red_hat_updates.update_registration(
            service="sat5",
            url="url.not.matching.format.example.com",
            username="******",
            password="******")
    # Confirm that it was the Sat5 url check that blocked it
    flash.assert_message_contain("https://server.example.com/XMLRPC")
예제 #10
0
def unset_org_id():
    try:
        red_hat_updates.update_registration(
            service='sat5',
            url=None,
            username='******',
            password='******',
            organization=''
        )
    except sel.NoSuchElementException:
        pass
def unset_org_id():
    try:
        red_hat_updates.update_registration(
            service='sat5',
            url="http://not.used.for.reg/XMLRPC",
            username='******',
            password='******',
            organization='')
    except Exception as ex:
        # Did this happen because the save button was dimmed?
        try:
            # If so, its fine - just return
            if red_hat_updates.form_buttons.save.is_dimmed:
                return
        except:
            # And if we cant access the save button
            pass
        # Something else happened so return the original exception
        raise ex
def unset_org_id():
    try:
        red_hat_updates.update_registration(
            service="sat5",
            url="http://not.used.for.reg/XMLRPC",
            username="******",
            password="******",
            organization="",
        )
    except Exception as ex:
        # Did this happen because the save button was dimmed?
        try:
            # If so, its fine - just return
            if red_hat_updates.form_buttons.save.is_dimmed:
                return
        except:
            # And if we cant access the save button
            pass
        # Something else happened so return the original exception
        raise ex
def test_rh_creds_validation(request, unset_org_id,
                             reg_method, reg_data, proxy_url, proxy_creds):
    if reg_method in ('rhsm', 'sat6'):
        repo_or_channel = reg_data.get('enable_repo', None)
    else:
        repo_or_channel = reg_data.get('add_channel', None)

    if not repo_or_channel:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds['username']
        proxy_password = proxy_creds['password']
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data['url'],
        username=conf.credentials[reg_method]['username'],
        password=conf.credentials[reg_method]['password'],
        repo_name=repo_or_channel,
        organization=reg_data.get('organization', None),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        cancel=True
    )
def test_rh_registration(appliance, request, reg_method, reg_data, proxy_url,
                         proxy_creds):
    """ Tests whether an appliance can be registered againt RHSM and SAT6 """
    repo = reg_data.get('enable_repo')
    if not repo:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds['username']
        proxy_password = proxy_creds['password']
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data['url'],
        username=conf.credentials[reg_method]['username'],
        password=conf.credentials[reg_method]['password'],
        repo_name=repo,
        organization=reg_data.get('organization'),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        # Satellite 6 registration requires validation to be able to fetch organization
        validate=False if reg_method != 'sat6' else True)

    used_repo_or_channel = InfoBlock('Red Hat Software Updates',
                                     'Repository Name(s)').text

    red_hat_updates.register_appliances()  # Register all

    request.addfinalizer(appliance.unregister)

    wait_for(func=red_hat_updates.is_registering,
             func_args=[appliance.server.name],
             delay=10,
             num_sec=100,
             fail_func=red_hat_updates.refresh)
    '''if/else added to overcome bz #1463588 these can be removed once fixed'''

    if reg_method == 'rhsm':
        wait_for(func=red_hat_updates.is_registered,
                 handle_exception=True,
                 func_args=[appliance.server.name],
                 delay=40,
                 num_sec=400,
                 fail_func=red_hat_updates.refresh)
    else:
        # First registration with sat6 fails; we need to click it after this failure
        wait_for(func=red_hat_updates.is_registered,
                 func_args=[appliance.server.name],
                 delay=50,
                 num_sec=1200,
                 fail_func=red_hat_updates.register_appliances)

    wait_for(func=appliance.is_registration_complete,
             func_args=[used_repo_or_channel],
             delay=20,
             num_sec=400)
def test_rh_registration(request, unset_org_id, reg_method, reg_data, proxy_url, proxy_creds):

    if reg_method in ("rhsm", "sat6"):
        repo_or_channel = reg_data.get("enable_repo", None)
    else:
        repo_or_channel = reg_data.get("add_channel", None)

    if not repo_or_channel:
        set_default_repo = True
    else:
        set_default_repo = False

    if proxy_url:
        use_proxy = True
        proxy_username = proxy_creds["username"]
        proxy_password = proxy_creds["password"]
    else:
        use_proxy = False
        proxy_url = None
        proxy_username = None
        proxy_password = None

    red_hat_updates.update_registration(
        service=reg_method,
        url=reg_data["url"],
        username=conf.credentials[reg_method]["username"],
        password=conf.credentials[reg_method]["password"],
        repo_name=repo_or_channel,
        organization=reg_data.get("organization", None),
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        set_default_repository=set_default_repo,
        # Satellite 6 registration requires validation to be able to choose organization
        validate=False if reg_method != "sat6" else True,
    )

    used_repo_or_channel = InfoBlock(
        "Red Hat Software Updates",
        version.pick(
            {
                version.LOWEST: "Update Repository",
                "5.4": "Channel Name(s)" if reg_method == "sat5" else "Repository Name(s)",
            }
        ),
    ).text

    red_hat_updates.register_appliances()  # Register all

    if reg_method == "rhsm":
        request.addfinalizer(rhsm_unregister)
    elif reg_method == "sat5":
        request.addfinalizer(sat5_unregister)
    else:
        request.addfinalizer(sat6_unregister)

    wait_for(
        func=is_registration_complete,
        func_args=[used_repo_or_channel],
        delay=40,
        num_sec=400,
        fail_func=red_hat_updates.register_appliances,
    )