def step_impl(context):
    ADMIN.create_user(config.TEST_USER, config.TEST_USER_PASSWORD)
    user = Client(api_url=config.API_URL,
                  username=config.TEST_USER,
                  password=config.TEST_USER_PASSWORD,
                  verify_ssl=False)
    assert user.is_logged_in()
Beispiel #2
0
def step_impl(context, times):
    for _ in range(times):
        user = Client(api_url=config.API_URL,
                      username=config.TEST_USER,
                      password=config.TEST_USER_PASSWORD + 'wrong',
                      verify_ssl=False)
        assert not user.is_logged_in()
Beispiel #3
0
def step_impl(context):
    # Attempt to correctly login
    user = Client(api_url=config.API_URL,
                  username=config.TEST_USER,
                  password=config.TEST_USER_PASSWORD,
                  verify_ssl=False)
    assert user.is_logged_in()
    ADMIN.get_user(config.TEST_USER).delete()
Beispiel #4
0
import config

from behave import given, when, then

from cloudfoundry import Client

ADMIN = Client(api_url=config.API_URL,
               username=config.MASTER_USERNAME,
               password=config.MASTER_PASSWORD,
               verify_ssl=False)


# Givens
@given('a space')
def step_impl(context):
    org = ADMIN.get_org(config.TEST_ORG)
    assert org.get_space(config.TEST_SPACE)


@given('a security group that closes all outgoing tcp connections')
def step_impl(context):
    assert ADMIN.get_security_group(name=config.CLOSED_SECURITY_GROUP)


@given('a security group that is open to all public outgoing connections')
def step_impl(context):
    assert ADMIN.get_security_group(name=config.OPEN_SECURITY_GROUP)


@when('I try to view all the ASGs')
def step_impl(context):
Beispiel #5
0
def after_feature(context, feature):
    """ Destroys a work space after Access Control feature is tested """
    admin_client = Client(api_url=config.API_URL,
                          username=config.MASTER_USERNAME,
                          password=config.MASTER_PASSWORD,
                          verify_ssl=False)

    if 'Cloud Controller' in feature.name:
        # Delete users
        admin_client.get_user(config.ORG_MANAGER).delete()
        admin_client.get_user(config.ORG_AUDITOR).delete()
        admin_client.get_user(config.SPACE_MANAGER).delete()
        admin_client.get_user(config.SPACE_DEVELOPER).delete()
        admin_client.get_user(config.SPACE_AUDITOR).delete()

    if 'Application Security Groups' in feature.name:
        admin_client.get_security_group(
            name=config.OPEN_SECURITY_GROUP).delete()
        admin_client.get_security_group(
            name=config.CLOSED_SECURITY_GROUP).delete()

    # Delete org and space
    org = admin_client.get_org(config.TEST_ORG)
    space = org.get_space(config.TEST_SPACE)
    space.delete()
    org.delete()
Beispiel #6
0
def before_feature(context, feature):
    """ Creates a work space before Access Control feature is tested """
    admin_client = Client(api_url=config.API_URL,
                          username=config.MASTER_USERNAME,
                          password=config.MASTER_PASSWORD,
                          verify_ssl=False)
    # Create and org
    org = admin_client.create_org(config.TEST_ORG)
    # Create a space
    space = org.create_space(config.TEST_SPACE)
    if 'Cloud Controller' in feature.name:
        # Create accounts that will be used and set permissions
        admin = admin_client.get_user(config.MASTER_USERNAME)
        org.set_user_role('user', admin.guid)
        org.set_user_role('manager', admin.guid)
        space.set_user_role('user', admin.guid)
        space.set_user_role('manager', admin.guid)

        org_manager = admin_client.create_user(
            config.ORG_MANAGER,
            config.ORG_MANAGER_PASSWORD,
        )
        org.set_user_role('user', org_manager.guid)
        org.set_user_role('manager', org_manager.guid)

        org_auditor = admin_client.create_user(
            config.ORG_AUDITOR,
            config.ORG_AUDITOR_PASSWORD,
        )
        org.set_user_role('user', org_auditor.guid)
        org.set_user_role('auditor', org_auditor.guid)

        space_manager = admin_client.create_user(
            config.SPACE_MANAGER,
            config.SPACE_MANAGER_PASSWORD,
        )
        org.set_user_role('user', space_manager.guid)
        space.set_user_role('user', space_manager.guid)
        space.set_user_role('manager', space_manager.guid)

        space_developer = admin_client.create_user(
            config.SPACE_DEVELOPER,
            config.SPACE_DEVELOPER_PASSWORD,
        )
        org.set_user_role('user', space_developer.guid)
        space.set_user_role('user', space_developer.guid)
        space.set_user_role('developer', space_developer.guid)

        space_auditor = admin_client.create_user(
            config.SPACE_AUDITOR,
            config.SPACE_AUDITOR_PASSWORD,
        )
        org.set_user_role('user', space_auditor.guid)
        space.set_user_role('auditor', space_auditor.guid)

    if 'Application Security Groups' in feature.name:
        admin_client.create_security_group(name=config.CLOSED_SECURITY_GROUP,
                                           rules=[{
                                               "protocol": "udp",
                                               "destination": "1.1.1.1",
                                               "ports": "1"
                                           }])
        admin_client.create_security_group(name=config.OPEN_SECURITY_GROUP,
                                           rules=[{
                                               "protocol":
                                               "all",
                                               "destination":
                                               "0.0.0.0-255.255.255.255",
                                           }])
def step_impl(context):
    context.user = Client(api_url=config.API_URL,
                          username=config.SPACE_AUDITOR,
                          password=config.SPACE_AUDITOR_PASSWORD,
                          verify_ssl=False)
def step_impl(context):
    context.user = Client(api_url=config.API_URL,
                          username=config.ORG_MANAGER,
                          password=config.ORG_MANAGER_PASSWORD,
                          verify_ssl=False)