func NewServiceBroker(name string, path string) ServiceBroker { b := ServiceBroker{} b.Path = path b.Name = name b.Service.Name = generator.RandomName() b.Service.ID = generator.RandomName() b.Plan.Name = generator.RandomName() b.Plan.ID = generator.RandomName() return b }
func NewBigApp(runner command_runner.CommandRunner, appPath string, sizeInMegabytes int) (*BigApp, error) { tempDirName, err := ioutil.TempDir("", "big-app") if err != nil { return nil, err } cmd := &exec.Cmd{Path: "cp", Args: []string{"-r", appPath + "/", tempDirName}} err = runner.Run(cmd) if err != nil { return nil, err } ddOutputArg := "of=" + tempDirName + "/payload" ddCountArg := fmt.Sprintf("count=%d", sizeInMegabytes) cmd = &exec.Cmd{Path: "dd", Args: []string{"if=/dev/urandom", ddOutputArg, ddCountArg, "bs=1048576"}} err = runner.Run(cmd) if err != nil { return nil, err } return &BigApp{ Location: tempDirName, runner: runner, Name: "big-app-" + generator.RandomName(), }, nil }
func NewServiceBroker(name string, path string) ServiceBroker { b := ServiceBroker{} b.Path = path b.Name = name b.Service.Name = generator.RandomName() b.Service.ID = generator.RandomName() b.Plan.Name = generator.RandomName() b.Plan.ID = generator.RandomName() b.Service.DashboardClient.ID = generator.RandomName() b.Service.DashboardClient.Secret = generator.RandomName() b.Service.DashboardClient.RedirectUri = generator.RandomName() return b }
. "github.com/onsi/gomega" . "github.com/vito/cmdtest/matchers" . "github.com/cloudfoundry/cf-acceptance-tests/helpers" "github.com/cloudfoundry/cf-acceptance-tests/services/helpers" . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) var _ = Describe("Purging service offerings", func() { var broker helpers.ServiceBroker BeforeEach(func() { helpers.LoginAsAdmin() broker = helpers.NewServiceBroker(generator.RandomName(), NewAssets().ServiceBroker) broker.Push() broker.Configure() broker.Create(LoadConfig().AppsDomain) broker.PublicizePlans() }) AfterEach(func() { broker.Destroy() helpers.LoginAsUser() }) It("removes all instances and plans of the service, then removes the service offering", func() { defer helpers.Recover() // Catches panic thrown by Require expectations instanceName := "purge-offering-instance"
. "github.com/cloudfoundry/cf-acceptance-tests/helpers" . "github.com/cloudfoundry/cf-acceptance-tests/services/helpers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) var _ = Describe("SSO Lifecycle", func() { var broker ServiceBroker var config OAuthConfig var apiEndpoint = LoadConfig().ApiEndpoint redirectUri := `http://example.com` BeforeEach(func() { broker = NewServiceBroker(generator.RandomName(), NewAssets().ServiceBroker, context) broker.Push() broker.Service.DashboardClient.RedirectUri = redirectUri broker.Configure() config = OAuthConfig{} config.ClientId = broker.Service.DashboardClient.ID config.ClientSecret = broker.Service.DashboardClient.Secret config.RedirectUri = redirectUri config.RequestedScopes = `openid,cloud_controller.read,cloud_controller.write` SetOauthEndpoints(apiEndpoint, &config) }) AfterEach(func() { broker.Destroy()
. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/vito/cmdtest/matchers" . "github.com/cloudfoundry/cf-acceptance-tests/helpers" "github.com/cloudfoundry/cf-acceptance-tests/services/helpers" . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) var _ = Describe("Service Broker Lifecycle", func() { var broker helpers.ServiceBroker BeforeEach(func() { helpers.LoginAsAdmin() broker = helpers.NewServiceBroker(generator.RandomName(), NewAssets().ServiceBroker) broker.Push() broker.Configure() }) AfterEach(func() { helpers.LoginAsUser() }) It("confirms correct behavior in the lifecycle of a service broker", func() { defer helpers.Recover() // Catches panic thrown by Require expectations // Adding the service broker helpers.Require(Cf("create-service-broker", broker.Name, "username", "password", AppUri(broker.Name, "", LoadConfig().AppsDomain))).To(ExitWithTimeout(0, 10*time.Second)) Expect(Cf("service-brokers")).To(Say(broker.Name))