Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service plan uniqueness #1086

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions services/service_broker_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ package services_test
import (
"encoding/json"
"fmt"

. "github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"

"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/random_name"
. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
"github.com/cloudfoundry/cf-test-helpers/v2/cf"
"github.com/cloudfoundry/cf-test-helpers/v2/helpers"
"github.com/cloudfoundry/cf-test-helpers/v2/workflowhelpers"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
)

var _ = ServicesDescribe("Service Broker Lifecycle", func() {
Expand All @@ -28,6 +25,7 @@ var _ = ServicesDescribe("Service Broker Lifecycle", func() {
var output []byte
var oldServiceName string
var oldPlanName string
var otherOrgName string

BeforeEach(func() {
broker = NewServiceBroker(
Expand Down Expand Up @@ -142,14 +140,30 @@ var _ = ServicesDescribe("Service Broker Lifecycle", func() {
})

Describe("enabling", func() {
It("is visible to a regular user", func() {
BeforeEach(func() {
workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
otherOrgName = random_name.CATSRandomName("ORG")
createOrg := cf.Cf("create-org", otherOrgName).Wait()
Expect(createOrg).To(Exit(0), "failed to create org")

addOrgManager := cf.Cf("set-org-role", TestSetup.RegularUserContext().Username, otherOrgName, "OrgManager").Wait()
Expect(addOrgManager).To(Exit(0), "failed to add org manager role")

commandResult := cf.Cf("enable-service-access", broker.Service.Name, "-p", globallyPublicPlan.Name).Wait()
Expect(commandResult).To(Exit(0))
commandResult = cf.Cf("enable-service-access", broker.Service.Name, "-p", orgPublicPlan.Name, "-o", TestSetup.RegularUserContext().Org).Wait()
Expect(commandResult).To(Exit(0))
commandResult = cf.Cf("enable-service-access", broker.Service.Name, "-p", orgPublicPlan.Name, "-o", otherOrgName).Wait()
Expect(commandResult).To(Exit(0))
})

})
It("is visible to a regular user", func() {
var plansResponse ServicesPlansResponse
workflowhelpers.ApiRequest("GET", fmt.Sprintf("/v3/service_plans?service_offering_names=%s", broker.Service.Name), &plansResponse, Config.DefaultTimeoutDuration())
// Ensure that there no duplicates
Expect(len(plansResponse.Resources)).To(Equal(2))
Expect(plansResponse.Resources[0].Name).To(Equal(globallyPublicPlan.Name))
Expect(plansResponse.Resources[1].Name).To(Equal(orgPublicPlan.Name))
plans := cf.Cf("marketplace").Wait()
Expect(plans).To(Exit(0))
Expect(plans).To(Say(broker.Service.Name))
Expand All @@ -160,11 +174,6 @@ var _ = ServicesDescribe("Service Broker Lifecycle", func() {

It("is visible to an admin user", func() {
workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
commandResult := cf.Cf("enable-service-access", broker.Service.Name, "-p", globallyPublicPlan.Name).Wait()
Expect(commandResult).To(Exit(0))
commandResult = cf.Cf("enable-service-access", broker.Service.Name, "-p", orgPublicPlan.Name, "-o", TestSetup.RegularUserContext().Org).Wait()
Expect(commandResult).To(Exit(0))

acls = cf.Cf("service-access", "-e", broker.Service.Name).Wait()
Expect(acls).To(Exit(0))
output = acls.Out.Contents()
Expand Down