Esempio n. 1
0
          "managers_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/managers",
          "auditors_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/auditors",
          "apps_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/apps",
          "routes_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/routes",
          "domains_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/domains",
          "service_instances_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/service_instances",
          "app_events_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/app_events",
          "events_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/events",
          "security_groups_url": "/v2/spaces/7e3b8b40-cced-4714-8d4a-2b6bddc10fda/security_groups"
       }
    }`))
})

var _ = Describe("LoadSpace", func() {
	var CCServer *httptest.Server
	var cc cf.CloudController

	BeforeEach(func() {
		CCServer = httptest.NewServer(SpacesEndpoint)
		cc = cf.NewCloudController(CCServer.URL, false)
	})

	AfterEach(func() {
		CCServer.Close()
	})

	It("loads the space from cloud controller", func() {
		space, err := cc.LoadSpace("space-guid", "notification-token")
		if err != nil {
			panic(err)
		}
          "quota_definition_url": "/v2/quota_definitions/caf592e1-bdac-40ec-b863-5d44ab785b7e",
          "spaces_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/spaces",
          "domains_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/domains",
          "private_domains_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/private_domains",
          "users_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/users",
          "managers_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/managers",
          "billing_managers_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/billing_managers",
          "auditors_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/auditors",
          "app_events_url": "/v2/organizations/cd1d0c26-0da8-42d8-9478-8c1d32235279/app_events"
       }
    }`))
})

var _ = Describe("LoadOrganization", func() {
	var CCServer *httptest.Server
	var cc cf.CloudController

	BeforeEach(func() {
		CCServer = httptest.NewServer(OrganizationsEndpoint)
		cc = cf.NewCloudController(CCServer.URL, false)
	})

	AfterEach(func() {
		CCServer.Close()
	})

	It("loads the organization from cloud controller", func() {
		org, err := cc.LoadOrganization("org-guid", "notification-token")
		if err != nil {
			panic(err)
		}
import (
	"net/http"
	"net/http/httptest"
	"strings"

	"github.com/cloudfoundry-incubator/notifications/cf"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("GetBillingManagersByOrgGuid", func() {
	var testOrganizationGuid = "test-organization-guid"
	var CCServer *httptest.Server
	var BillingManagersEndpoint http.HandlerFunc
	var cloudController cf.CloudController

	BeforeEach(func() {
		BillingManagersEndpoint = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			token := strings.TrimPrefix(req.Header.Get("Authorization"), "Bearer ")
			if token != testUAAToken {
				w.WriteHeader(http.StatusUnauthorized)
				w.Write([]byte(`{"code":10002,"description":"Authentication error","error_code":"CF-NotAuthenticated"}`))
				return
			}

			err := req.ParseForm()
			if err != nil {
				panic(err)
			}
import (
	"net/http"
	"net/http/httptest"
	"strings"

	"github.com/cloudfoundry-incubator/notifications/cf"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("GetAuditorsByOrgGuid", func() {
	var testOrganizationGuid = "test-organization-guid"
	var CCServer *httptest.Server
	var AuditorsEndpoint http.HandlerFunc
	var cloudController cf.CloudController

	BeforeEach(func() {
		AuditorsEndpoint = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			token := strings.TrimPrefix(req.Header.Get("Authorization"), "Bearer ")
			if token != testUAAToken {
				w.WriteHeader(http.StatusUnauthorized)
				w.Write([]byte(`{"code":10002,"description":"Authentication error","error_code":"CF-NotAuthenticated"}`))
				return
			}

			err := req.ParseForm()
			if err != nil {
				panic(err)
			}