예제 #1
0
def before_all_scenarios():
    """
    Actions before all scenarios
    Get the initial time at start the tests
    """
    # Remove lettuce log file
    file = open('logs/lettuce.log', 'w')
    file.write('')
    file.close()
    world.log = log
    world.test_time_init = time.strftime("%c")
    log.debug('Starting environment')
    # Start proxys and mocks
    start_environment()

    # At first, there are not configuration for PEP
    world.config_set = ''

    log.debug('Initialize environment')
    initialize_keystone(world.ks['platform'], world.ks['environment_general'])
    initialize_keystone(world.ks['platform'], world.ks['environment_general_ko'])
    initialize_keystone(world.ks['platform'], world.ks['environment_general_no_roles'])
    initialize_keystone(world.ks['platform'], world.ks['environment_domain'])
    initialize_keystone(world.ks['platform'], world.ks['environment_project'])
    initialize_keystone(world.ks['platform'], world.ks['environment_bypass'])
    world.structure = IdmUtils.get_structure(world.ks['platform'])

    # General
    user_roles_general = [(world.ks['user_all'], x['name']) for x in
                          world.ks['environment_general']['domains'][0]['users'][0]['projects'][0]['roles']]
    initialize_ac(user_roles_general,
                  world.ac['ip'], world.ac['port'],
                  world.structure,
                  world.ks['domain_ok'],
                  world.ks['project_ok'],
                  'general')
    # #Domain
    user_roles_domain = [(x['name'], x['roles'][0]['name']) for x in
                         world.ks['environment_domain']['domains'][0]['users']]
    initialize_ac(user_roles_domain,
                  world.ac['ip'], world.ac['port'],
                  world.structure,
                  world.ks['domain_domain_only'],
                  world.ks['project_domain_only'],
                  'domain')
    # Project
    user_roles_project = [(x['name'], x['projects'][0]['roles'][0]['name']) for x in
                          world.ks['environment_project']['domains'][0]['users']]
    initialize_ac(user_roles_project,
                  world.ac['ip'], world.ac['port'],
                  world.structure,
                  world.ks['domain_project_only'],
                  world.ks['project_project_only'],
                  'project')
    reset_test_variables()
    log.debug('Environment ready')
예제 #2
0
def before_all_scenarios():
    """
    Actions before all scenarios
    Get the initial time at start the tests
    """
    # Remove lettuce log file
    file = open('logs/lettuce.log', 'w')
    file.write('')
    file.close()
    world.log = log
    world.test_time_init = time.strftime("%c")
    log.debug('Starting environment')
    # Start proxys and mocks
    start_environment()

    # At first, there are not configuration for PEP
    world.config_set = ''

    log.debug('Initialize environment')
    initialize_keystone(world.ks['platform'], world.ks['environment_general'])
    initialize_keystone(world.ks['platform'],
                        world.ks['environment_general_ko'])
    initialize_keystone(world.ks['platform'],
                        world.ks['environment_general_no_roles'])
    initialize_keystone(world.ks['platform'], world.ks['environment_domain'])
    initialize_keystone(world.ks['platform'], world.ks['environment_project'])
    initialize_keystone(world.ks['platform'], world.ks['environment_bypass'])
    world.structure = IdmUtils.get_structure(world.ks['platform'])

    # General
    user_roles_general = [(world.ks['user_all'], x['name'])
                          for x in world.ks['environment_general']['domains']
                          [0]['users'][0]['projects'][0]['roles']]
    initialize_ac(user_roles_general, world.ac['ip'], world.ac['port'],
                  world.structure, world.ks['domain_ok'],
                  world.ks['project_ok'], 'general')
    # #Domain
    user_roles_domain = [
        (x['name'], x['roles'][0]['name'])
        for x in world.ks['environment_domain']['domains'][0]['users']
    ]
    initialize_ac(user_roles_domain, world.ac['ip'], world.ac['port'],
                  world.structure, world.ks['domain_domain_only'],
                  world.ks['project_domain_only'], 'domain')
    # Project
    user_roles_project = [
        (x['name'], x['projects'][0]['roles'][0]['name'])
        for x in world.ks['environment_project']['domains'][0]['users']
    ]
    initialize_ac(user_roles_project, world.ac['ip'], world.ac['port'],
                  world.structure, world.ks['domain_project_only'],
                  world.ks['project_project_only'], 'project')
    reset_test_variables()
    log.debug('Environment ready')
예제 #3
0
def after_each_scenario(scenario):

    reset_test_variables()
    """ If the mocks/proxys are changed, restore ir after each test """
    if hasattr(world, 'ks_faked') and world.ks_faked:
        stop_process(world.ks_proxy)
        world.ks_proxy = start_proxy(world.ks_proxy_bind_ip, world.ks_proxy_port, world.ks['platform']['address']['ip'],
                                     world.ks['platform']['address']['port'])
        world.ks_faked = False
    if hasattr(world, 'ac_faked') and world.ac_faked:
        stop_process(world.ac_proxy)
        world.ac_proxy = start_proxy(world.ac_proxy_bind_ip, world.ac_proxy_port, world.ac['ip'], world.ac['port'])
        world.ac_faked = False
    if hasattr(world, 'target_faked') and world.target_faked:
        stop_process(world.mock_dest)
        world.mock_dest = start_mock('mock.py', world.mock['ip'], world.mock['port'])
        world.target_faked = False
    sys.stdout.write(("*****Se ha ejecutado el scenario: " + str(scenario.name).encode('utf-8')))
예제 #4
0
def after_each_scenario(scenario):

    reset_test_variables()
    """ If the mocks/proxys are changed, restore ir after each test """
    if hasattr(world, 'ks_faked') and world.ks_faked:
        stop_process(world.ks_proxy)
        world.ks_proxy = start_proxy(world.ks_proxy_bind_ip,
                                     world.ks_proxy_port,
                                     world.ks['platform']['address']['ip'],
                                     world.ks['platform']['address']['port'])
        world.ks_faked = False
    if hasattr(world, 'ac_faked') and world.ac_faked:
        stop_process(world.ac_proxy)
        world.ac_proxy = start_proxy(world.ac_proxy_bind_ip,
                                     world.ac_proxy_port, world.ac['ip'],
                                     world.ac['port'])
        world.ac_faked = False
    if hasattr(world, 'target_faked') and world.target_faked:
        stop_process(world.mock_dest)
        world.mock_dest = start_mock('mock.py', world.mock['ip'],
                                     world.mock['port'])
        world.target_faked = False
    sys.stdout.write(("*****Se ha ejecutado el scenario: " +
                      str(scenario.name).encode('utf-8')))
예제 #5
0
def reset_data(scenario, *args):
    reset_test_variables()
예제 #6
0
def reset_data(scenario, *args):
    reset_test_variables()