func NewCloudController(host string, skipVerifySSL bool) CloudController { return CloudController{ client: rainmaker.NewClient(rainmaker.Config{ Host: host, SkipVerifySSL: skipVerifySSL, }), } }
import ( "os" "github.com/pivotal-cf-experimental/rainmaker" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Fetch all the auditors of an organization", func() { It("fetches the user records of all auditors associated with an organization", func() { token := os.Getenv("UAA_TOKEN") client := rainmaker.NewClient(rainmaker.Config{ Host: os.Getenv("CC_HOST"), SkipVerifySSL: true, }) user, err := client.Users.Create(NewGUID("user"), token) Expect(err).NotTo(HaveOccurred()) org, err := client.Organizations.Create(NewOrgName("org"), token) Expect(err).NotTo(HaveOccurred()) err = org.Auditors.Associate(user.GUID, token) Expect(err).NotTo(HaveOccurred()) list, err := client.Organizations.ListAuditors(org.GUID, token) Expect(err).NotTo(HaveOccurred()) Expect(list.Users).To(HaveLen(1))
package rainmaker_test import ( "github.com/pivotal-cf-experimental/rainmaker" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Client", func() { var client rainmaker.Client BeforeEach(func() { client = rainmaker.NewClient(rainmaker.Config{ Host: "http://example.com", }) }) It("has a organizations service", func() { Expect(client.Organizations).To(BeAssignableToTypeOf(rainmaker.OrganizationsService{})) }) It("has a spaces service", func() { Expect(client.Spaces).To(BeAssignableToTypeOf(rainmaker.SpacesService{})) }) It("has an applications service", func() { Expect(client.Applications).To(BeAssignableToTypeOf(rainmaker.ApplicationsService{})) }) It("has a users service", func() {
var _ = Describe("OrganizationsService", func() { var ( config rainmaker.Config token string service rainmaker.OrganizationsService organization rainmaker.Organization ) BeforeEach(func() { var err error token = "token" config = rainmaker.Config{ Host: fakeCloudController.URL(), } client := rainmaker.NewClient(config) service = client.Organizations organization, err = service.Create("test-org", token) Expect(err).NotTo(HaveOccurred()) }) Describe("Create", func() { It("creates a new organization that can be fetched from the API", func() { organization, err := service.Create("my-new-org", token) Expect(err).NotTo(HaveOccurred()) Expect(organization.Name).To(Equal("my-new-org")) fetchedOrg, err := service.Get(organization.GUID, token) Expect(err).NotTo(HaveOccurred()) Expect(fetchedOrg).To(Equal(organization))