Ejemplo n.º 1
0
def download_openrc_files(quit_driver=True):
    """
    Download openrc files from Horizon to <LOG_DIR>/horizon/.

    """
    LOG.info("Download openrc files from horizon")
    local_dir = os.path.join(ProjVar.get_var('LOG_DIR'), 'horizon')

    from utils.horizon.pages import loginpage
    rc_files = []
    login_pg = loginpage.LoginPage()
    login_pg.go_to_target_page()
    try:
        for auth_info in (Tenant.get('admin'), Tenant.get('tenant1'), Tenant.get('tenant2')):
            user = auth_info['user']
            password = auth_info['password']
            openrc_file = '{}-openrc.sh'.format(user)
            home_pg = login_pg.login(user, password=password)
            home_pg.download_rc_v3()
            home_pg.log_out()
            openrc_path = os.path.join(local_dir, openrc_file)
            assert os.path.exists(openrc_path), "{} not found after download".format(openrc_file)
            rc_files.append(openrc_path)

    finally:
        if quit_driver:
            HorizonDriver.quit_driver()

    LOG.info("openrc files are successfully downloaded to: {}".format(local_dir))
    return rc_files
Ejemplo n.º 2
0
def test_horizon_password_change(new_user):
    # Changes the password, verifies it was indeed changed and
    # resets to default password.
    # !!!!! the password cannot be change to previous password

    password_change_pg, username = new_user
    password_change_pg.change_password(TEST_PASSWORD, NEW_PASSWORD1)
    login_pg = loginpage.LoginPage(password_change_pg.driver)
    assert login_pg.is_logout_reason_displayed(), \
        "The logout reason message was not found on the login page"
    home_pg = login_pg.login(username, NEW_PASSWORD1)
    assert home_pg.is_logged_in, "Failed to login with new password"
    password_change_pg.go_to_target_page()
    time.sleep(2)
    password_change_pg.change_password(NEW_PASSWORD1, NEW_PASSWORD2)
    assert login_pg.is_logout_reason_displayed(), \
        "The logout reason message was not found on the login page"
    home_pg = login_pg.login(username, NEW_PASSWORD2)
    assert home_pg.is_logged_in, "Failed to login with new password"
    password_change_pg.go_to_target_page()
    time.sleep(2)
    password_change_pg.reset_to_default_password(NEW_PASSWORD2)
    home_pg = login_pg.login(username, TEST_PASSWORD)
    assert home_pg.is_logged_in, "Failed to login with new password"
    horizon.test_result = True
Ejemplo n.º 3
0
def new_user(admin_home_pg_container, request):
    """
    Args:
        admin_home_pg_container:
        request:

    Setups:
        - Login as Admin
        - Go to Identity > User
        - Create a new user
        - Verify the user appears in the users table

    Teardown:
        - Delete the newly created user
        - Verify the user does not appear in the table after deletion
        - Back to Users page
        - Logout

    """
    LOG.fixture_step('Go to Identity > Users')
    users_pg = userspage.UsersPage(admin_home_pg_container.driver, port=admin_home_pg_container.port)
    users_pg.go_to_target_page()
    username = helper.gen_resource_name('user')
    password = TEST_PASSWORD

    LOG.fixture_step('Create new user {}'.format(username))
    users_pg.create_user(username, password=password,
                         project='admin', role='admin')
    assert users_pg.find_message_and_dismiss(messages.SUCCESS)
    assert not users_pg.find_message_and_dismiss(messages.ERROR)

    LOG.fixture_step('Verify the user appears in the users table')
    assert users_pg.is_user_present(username)
    login_pg = loginpage.LoginPage(users_pg.driver, port=users_pg.port)

    def delete_test_user():
        LOG.fixture_step('Go to users page and delete user {}'.format(username))
        users_pg.log_out()
        login_pg.go_to_target_page()
        login_pg.login(user='******', password=Tenant.get('admin')['password'])
        users_pg.go_to_target_page()
        users_pg.delete_user(username)
        assert users_pg.find_message_and_dismiss(messages.SUCCESS)
        assert not users_pg.find_message_and_dismiss(messages.ERROR)

        LOG.fixture_step('Verify the user does not appear in the table after deletion')
        assert not users_pg.is_user_present(username)

        LOG.fixture_step('Back to Users page')
        users_pg.go_to_target_page()
    request.addfinalizer(delete_test_user)

    LOG.fixture_step("Login as new user, and go to user password change page")
    users_pg.log_out()
    login_pg.go_to_target_page()
    home_pg = login_pg.login(user=username, password=TEST_PASSWORD)
    password_change_pg = changepasswordpage.ChangepasswordPage(home_pg.driver, port=home_pg.port)
    password_change_pg.go_to_target_page()
    return password_change_pg, username
Ejemplo n.º 4
0
def test_remote_cli():
    LOG.info("Download openrc files from horizon")
    horizon_dir = os.path.join(ProjVar.get_var('LOG_DIR'), 'horizon')
    tenant1 = Tenant.get('tenant1')['tenant']
    tenant2 = Tenant.get('tenant2')['tenant']
    admin_openrc = '{}-openrc.sh'.format(Tenant.get('admin')['tenant'])
    tenant1_openrc = '{}-openrc.sh'.format(tenant1)
    tenant2_openrc = '{}-openrc.sh'.format(tenant2)

    # from utils.horizon.pages.project.apiaccesspage import ApiAccessPage
    from utils.horizon.pages import loginpage
    driver = HorizonDriver.get_driver()
    login_pg = loginpage.LoginPage(driver)
    login_pg.go_to_target_page()
    home_pg = login_pg.login('admin', 'Li69nux*')
    home_pg.download_rc_v3()

    # api_access_page = ApiAccessPage(home_pg.driver)
    # api_access_page.go_to_target_page()
    # api_access_page.download_openstack_rc_file()
    assert os.path.exists(os.path.join(horizon_dir, admin_openrc)), "{} not found after download".format(admin_openrc)

    # api_access_page.change_project(name=tenant1)
    # api_access_page.download_openstack_rc_file()
    home_pg.change_project(name=tenant1)
    home_pg.download_rc_v3()
    assert os.path.exists(os.path.join(horizon_dir, tenant1_openrc)), \
        "{} not found after download".format(tenant1_openrc)

    # api_access_page.change_project(name=tenant2)
    # api_access_page.download_openstack_rc_file()
    home_pg.change_project(name=tenant2)
    home_pg.download_rc_v3()
    assert os.path.exists(os.path.join(horizon_dir, tenant2_openrc)), \
        "{} not found after download".format(tenant2_openrc)

    RemoteCLIClient.get_remote_cli_client()

    nova_helper.get_basic_flavor()
    cinder_helper.get_volume_qos_list()
    glance_helper.get_images()
    system_helper.get_computes()
    ceilometer_helper.get_alarms()
    keystone_helper.is_https_enabled()
Ejemplo n.º 5
0
def test_horizon_login(driver, username, service):
    """
    Test the login functionality:

    Test Steps:
        - Login as username with password
        - Verify is-logged-in
        - Logout
    """
    if service == 'container' and not container_helper.is_stx_openstack_deployed():
        skip('Skip OpenStack horizon test when stx-openstack not deployed')

    port = 31000 if service == 'container' else None
    login_pg = loginpage.LoginPage(driver, port=port)
    login_pg.go_to_target_page()
    password = Tenant.get(username)['password']
    home_pg = login_pg.login(username, password=password)
    assert home_pg.is_logged_in
    home_pg.log_out()
Ejemplo n.º 6
0
def __login_base(request, driver, auth_info, port=None):

    horizon.test_result = False
    if not auth_info:
        auth_info = Tenant.get_primary()

    user = auth_info['user']
    password = auth_info['password']
    project = auth_info['tenant']
    if not port and not auth_info.get('platform'):
        port = 31000

    gmttime = datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S")
    video_path = ProjVar.get_var('LOG_DIR') + '/horizon/' + \
        str(gmttime) + '.mp4'
    recorder = video_recorder.VideoRecorder(1920, 1080, os.environ['DISPLAY'],
                                            video_path)
    recorder.start()
    home_pg = None

    try:
        LOG.fixture_step('Login as {}'.format(user))
        login_pg = loginpage.LoginPage(driver, port=port)
        login_pg.go_to_target_page()
        home_pg = login_pg.login(user=user, password=password)
        home_pg.change_project(name=project)
    finally:

        def teardown():
            if home_pg:
                LOG.fixture_step('Logout')
                home_pg.log_out()
            recorder.stop()
            if horizon.test_result:
                recorder.clear()

        request.addfinalizer(teardown)

    return home_pg