Ejemplo n.º 1
0
    def test_non_developer_cannot_manage_app(self, context, test_org,
                                             test_space, test_org_manager,
                                             test_org_manager_client):
        step("Push example app as admin")
        cf.cf_login(test_org.name, test_space.name)
        example_app_path = ApplicationPath.SAMPLE_PYTHON_APP
        test_app = Application.push(context,
                                    space_guid=test_space.guid,
                                    source_directory=example_app_path)
        apps = Application.cf_api_get_list_by_space(test_space.guid)
        assert test_app in apps

        step("Add user to space as manager")
        space_manager = test_org_manager
        space_manager_client = test_org_manager_client
        space_manager.api_add_to_space(space_guid=test_space.guid,
                                       org_guid=test_org.guid,
                                       roles=User.SPACE_ROLES["manager"])
        step("Check that manager cannot stop app")
        assertions.assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                                HttpStatus.MSG_FORBIDDEN,
                                                test_app.api_stop,
                                                client=space_manager_client)
        step("Check that manager cannot start app")
        assertions.assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                                HttpStatus.MSG_FORBIDDEN,
                                                test_app.api_start,
                                                client=space_manager_client)
        step("Check that manager cannot delete app")
        assertions.assert_raises_http_exception(HttpStatus.CODE_FORBIDDEN,
                                                HttpStatus.MSG_FORBIDDEN,
                                                test_app.api_delete,
                                                client=space_manager_client)
        apps = Application.cf_api_get_list_by_space(test_space.guid)
        assert test_app in apps
 def test_delete_service_instance(self, org_space, instance):
     test_org, test_space = org_space
     step('Login to cf')
     cf.cf_login(test_org.name, test_space.name)
     instance.api_delete()
     _, cf_service_instances_list = summaries.cf_api_get_space_summary(
         test_space.guid)
     assert cf_service_instances_list == []
 def test_create_service_instance(self, org_space, instance):
     test_org, test_space = org_space
     step('Login to cf')
     cf.cf_login(test_org.name, test_space.name)
     _, cf_service_instances_list = summaries.cf_api_get_space_summary(
         test_space.guid)
     cf_service_instance_guids = [s.guid for s in cf_service_instances_list]
     assert cf_service_instance_guids == list((instance.guid, ))
 def org_space_app(self, context):
     step("Create test organization and space")
     test_org = Organization.api_create(context)
     test_space = Space.api_create(test_org)
     step("Login to cf targeting test org and test space")
     cf.cf_login(test_org.name, test_space.name)
     step("Push example app")
     example_app_path = ApplicationPath.SAMPLE_PYTHON_APP
     test_app = Application.push(context, space_guid=test_space.guid, source_directory=example_app_path)
     return test_org, test_space, test_app
Ejemplo n.º 5
0
def sample_python_app(request, test_org, test_space):
    context = Context()
    log_fixture("sample_python_app: Push app to cf")
    cf.cf_login(test_org.name, test_space.name)
    app = Application.push(context=context,
                           space_guid=test_space.guid,
                           source_directory=ApplicationPath.SAMPLE_PYTHON_APP)

    def fin():
        log_fixture("sample_python_app: Delete sample app")
        context.cleanup()

    request.addfinalizer(fin)

    return app
Ejemplo n.º 6
0
 def test_developer_can_manage_app(self, test_org, test_space,
                                   test_org_manager,
                                   test_org_manager_client, context):
     space_developer = test_org_manager
     space_developer.api_add_to_space(space_guid=test_space.guid,
                                      org_guid=test_org.guid,
                                      roles=User.SPACE_ROLES["developer"])
     cf.cf_login(test_org.name,
                 test_space.name,
                 credentials=(space_developer.username,
                              space_developer.password))
     space_developer_client = test_org_manager_client
     self._check_user_can_do_app_flow(test_space,
                                      client=space_developer_client,
                                      context=context)
Ejemplo n.º 7
0
    def test_non_developer_cannot_push_app(self, context, test_org, test_space,
                                           test_org_manager):
        step("Add user to space as manager")
        space_manager = test_org_manager
        space_manager.api_add_to_space(space_guid=test_space.guid,
                                       org_guid=test_org.guid,
                                       roles=User.SPACE_ROLES["manager"])
        step("Login as this user")
        cf.cf_login(test_org.name,
                    test_space.name,
                    credentials=(space_manager.username,
                                 space_manager.password))

        step("Check that manager cannot push app")
        example_app_path = ApplicationPath.SAMPLE_PYTHON_APP
        with pytest.raises(CommandExecutionException):
            Application.push(context,
                             space_guid=test_space.guid,
                             source_directory=example_app_path)
Ejemplo n.º 8
0
def sample_java_app(request, test_org, test_space):
    context = Context()
    test_app_sources = AppSources.from_local_path(
        sources_directory=ApplicationPath.SAMPLE_JAVA_APP)
    log_fixture("sample_java_app: Compile the sources")
    test_app_sources.compile_mvn()
    log_fixture("sample_java_app: Push app to cf")
    cf.cf_login(test_org.name, test_space.name)
    app = Application.push(context=context,
                           space_guid=test_space.guid,
                           source_directory=ApplicationPath.SAMPLE_JAVA_APP)
    app.ensure_started()
    log_fixture("Check the application is running")

    def fin():
        log_fixture("sample_java_app: Delete sample app")
        context.cleanup()

    request.addfinalizer(fin)

    return app
Ejemplo n.º 9
0
def login_to_cf(test_org, test_space):
    log_fixture("login_to_cf: Login to cf targeting test org and test space")
    cf.cf_login(test_org.name, test_space.name)
Ejemplo n.º 10
0
 def test_admin_can_manage_app(self, test_org, test_space, admin_client,
                               context):
     cf.cf_login(test_org.name, test_space.name)
     self._check_user_can_do_app_flow(test_space,
                                      client=admin_client,
                                      context=context)