func setUpSpaceWithUserAccess(uc cf.UserContext) {
	spaceSetupTimeout := 10.0
	Eventually(cf.Cf("create-space", "-o", uc.Org, uc.Space), spaceSetupTimeout).Should(Exit(0))
	Eventually(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceManager"), spaceSetupTimeout).Should(Exit(0))
	Eventually(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceDeveloper"), spaceSetupTimeout).Should(Exit(0))
	Eventually(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceAuditor"), spaceSetupTimeout).Should(Exit(0))
}
Example #2
0
func (context *ConfiguredContext) Setup() {
	cf.AsUser(context.AdminUserContext(), func() {
		definition := quotaDefinition{
			Name: context.quotaDefinitionName,

			TotalServices: 100,
			TotalRoutes:   1000,

			MemoryLimit: 10240,

			NonBasicServicesAllowed: true,
		}

		definitionPayload, err := json.Marshal(definition)
		Expect(err).ToNot(HaveOccurred())

		var response cf.GenericResource

		cf.ApiRequest("POST", "/v2/quota_definitions", &response, string(definitionPayload))

		context.quotaDefinitionGUID = response.Metadata.Guid
		fmt.Printf("QuotaDefinition Response: %#v\n", response)
		println("GUID", context.quotaDefinitionGUID)

		Expect(cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)).To(SayBranches(
			cmdtest.ExpectBranch{"OK", func() {}},
			cmdtest.ExpectBranch{"scim_resource_already_exists", func() {}},
		))

		Expect(cf.Cf("create-org", context.organizationName)).To(ExitWith(0))
		Expect(cf.Cf("set-quota", context.organizationName, definition.Name)).To(ExitWith(0))
	})
}
Example #3
0
func (context *ConfiguredContext) Teardown() {
	cf.AsUser(context.AdminUserContext(), func() {
		Eventually(cf.Cf("delete-user", "-f", context.regularUserUsername), 30).Should(Exit(0))

		if !context.isPersistent {
			Eventually(cf.Cf("delete-org", "-f", context.organizationName), 30).Should(Exit(0))

			Eventually(cf.Cf("delete-quota", "-f", context.quotaDefinitionName), 30).Should(Exit(0))
		}
	})
}
Example #4
0
func (context *ConfiguredContext) Teardown() {
	cf.AsUser(context.AdminUserContext(), func() {
		Expect(cf.Cf("delete-user", "-f", context.regularUserUsername)).To(Say("OK"))

		if !context.isPersistent {
			Expect(cf.Cf("delete-org", "-f", context.organizationName)).To(Say("OK"))

			cf.ApiRequest(
				"DELETE",
				"/v2/quota_definitions/"+context.quotaDefinitionGUID+"?recursive=true",
				nil,
			)
		}
	})
}
Example #5
0
func (context *ConfiguredContext) Setup() {
	cf.AsUser(context.AdminUserContext(), func() {
		definition := quotaDefinition{
			Name: context.quotaDefinitionName,

			TotalServices: "100",
			TotalRoutes:   "1000",
			MemoryLimit:   "10G",

			NonBasicServicesAllowed: true,
		}

		args := []string{
			"create-quota",
			context.quotaDefinitionName,
			"-m", definition.MemoryLimit,
			"-r", definition.TotalRoutes,
			"-s", definition.TotalServices,
		}
		if definition.NonBasicServicesAllowed {
			args = append(args, "--allow-paid-service-plans")
		}

		Eventually(cf.Cf(args...), 30).Should(Exit(0))

		createUserSession := cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)

		select {
		case <-createUserSession.Out.Detect("OK"):
		case <-createUserSession.Out.Detect("scim_resource_already_exists"):
		case <-time.After(30 * time.Second):
			ginkgo.Fail("Failed to create user")
		}
		createUserSession.Out.CancelDetects()

		Eventually(cf.Cf("create-org", context.organizationName), 30).Should(Exit(0))
		Eventually(cf.Cf("set-quota", context.organizationName, definition.Name), 30).Should(Exit(0))
	})
}
package helpers

import (
	"fmt"
	"testing"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/vito/cmdtest/matchers"

	ginkgoconfig "github.com/onsi/ginkgo/config"
	"github.com/onsi/ginkgo/reporters"

	"github.com/pivotal-cf-experimental/cf-test-helpers/cf"
)

func GinkgoBootstrap(t *testing.T, suiteName string) {
	RegisterFailHandler(Fail)

	cf.AsUser(RegularUserContext, func() {
		outputFile := fmt.Sprintf("../results/%s-junit_%d.xml", suiteName, ginkgoconfig.GinkgoConfig.ParallelNode)
		RunSpecsWithDefaultAndCustomReporters(t, suiteName, []Reporter{reporters.NewJUnitReporter(outputFile)})
	})
}

var _ = BeforeEach(func() {
	Expect(cf.Cf("target", "-s", RegularUserContext.Space)).To(ExitWith(0))
})
func setUpSpaceWithUserAccess(uc cf.UserContext) {
	Expect(cf.Cf("create-space", "-o", uc.Org, uc.Space)).To(ExitWith(0))
	Expect(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceManager")).To(ExitWith(0))
	Expect(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceDeveloper")).To(ExitWith(0))
	Expect(cf.Cf("set-space-role", uc.Username, uc.Org, uc.Space, "SpaceAuditor")).To(ExitWith(0))
}