github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/endpoints/endpoints_test.go (about) 1 package endpoints 2 3 import ( 4 . "github.com/onsi/ginkgo" 5 . "github.com/onsi/gomega" 6 ) 7 8 var _ = Describe("EndPoints", func() { 9 10 Context("When region is us-south", func() { 11 locator := newEndpointLocator("us-south", "public", "") 12 13 It("should return endpoints with region us-south", func() { 14 Expect(locator.CFAPIEndpoint()).To(Equal("https://api.ng.bluemix.net")) 15 Expect(locator.UAAEndpoint()).To(Equal("https://iam.cloud.ibm.com/cloudfoundry/login/us-south")) 16 Expect(locator.ICDEndpoint()).To(Equal("https://api.us-south.databases.cloud.ibm.com")) 17 Expect(locator.MCCPAPIEndpoint()).To(Equal("https://mccp.us-south.cf.cloud.ibm.com")) 18 Expect(locator.ContainerRegistryEndpoint()).To(Equal("https://us.icr.io")) 19 }) 20 }) 21 22 Context("When region is eu-gb", func() { 23 locator := newEndpointLocator("eu-gb", "public", "") 24 25 It("should return endpoints with region eu-gb", func() { 26 Expect(locator.CFAPIEndpoint()).To(Equal("https://api.eu-gb.bluemix.net")) 27 Expect(locator.UAAEndpoint()).To(Equal("https://iam.cloud.ibm.com/cloudfoundry/login/uk-south")) 28 Expect(locator.AccountManagementEndpoint()).To(Equal("https://accounts.cloud.ibm.com")) 29 Expect(locator.ICDEndpoint()).To(Equal("https://api.eu-gb.databases.cloud.ibm.com")) 30 }) 31 }) 32 33 Context("When region is au-syd", func() { 34 locator := newEndpointLocator("au-syd", "public", "") 35 36 It("should return endpoints with region au-syd", func() { 37 Expect(locator.CFAPIEndpoint()).To(Equal("https://api.au-syd.bluemix.net")) 38 Expect(locator.UAAEndpoint()).To(Equal("https://iam.cloud.ibm.com/cloudfoundry/login/ap-south")) 39 Expect(locator.AccountManagementEndpoint()).To(Equal("https://accounts.cloud.ibm.com")) 40 Expect(locator.ICDEndpoint()).To(Equal("https://api.au-syd.databases.cloud.ibm.com")) 41 }) 42 }) 43 44 Context("When region is eu-de", func() { 45 locator := newEndpointLocator("eu-de", "public", "") 46 47 It("should return endpoints with region eu-de", func() { 48 Expect(locator.CFAPIEndpoint()).To(Equal("https://api.eu-de.bluemix.net")) 49 Expect(locator.UAAEndpoint()).To(Equal("https://iam.cloud.ibm.com/cloudfoundry/login/eu-central")) 50 Expect(locator.CisEndpoint()).To(Equal("https://api.cis.cloud.ibm.com")) 51 Expect(locator.ICDEndpoint()).To(Equal("https://api.eu-de.databases.cloud.ibm.com")) 52 }) 53 }) 54 55 Context("When region is us-east", func() { 56 locator := newEndpointLocator("us-east", "public", "") 57 58 It("should return endpoints with region us-east", func() { 59 Expect(locator.CFAPIEndpoint()).To(Equal("https://api.us-east.bluemix.net")) 60 Expect(locator.UAAEndpoint()).To(Equal("https://iam.cloud.ibm.com/cloudfoundry/login/us-east")) 61 Expect(locator.ICDEndpoint()).To(Equal("https://api.us-east.databases.cloud.ibm.com")) 62 }) 63 }) 64 65 Context("When region is jp-tok", func() { 66 locator := newEndpointLocator("jp-tok", "public", "") 67 68 It("should return endpoints with region jp-tok", func() { 69 Expect(locator.CFAPIEndpoint()).To(Equal("https://api.jp-tok.bluemix.net")) 70 Expect(locator.ICDEndpoint()).To(Equal("https://api.jp-tok.databases.cloud.ibm.com")) 71 }) 72 }) 73 74 Context("When region is global", func() { 75 locator := newEndpointLocator("global", "public", "") 76 77 It("should return endpoints with global endpoits", func() { 78 Expect(locator.AccountManagementEndpoint()).To(Equal("https://accounts.cloud.ibm.com")) 79 Expect(locator.IAMEndpoint()).To(Equal("https://iam.cloud.ibm.com")) 80 Expect(locator.IAMPAPEndpoint()).To(Equal("https://iam.cloud.ibm.com")) 81 Expect(locator.CisEndpoint()).To(Equal("https://api.cis.cloud.ibm.com")) 82 Expect(locator.GlobalTaggingEndpoint()).To(Equal("https://tags.global-search-tagging.cloud.ibm.com")) 83 Expect(locator.GlobalSearchEndpoint()).To(Equal("https://api.global-search-tagging.cloud.ibm.com")) 84 Expect(locator.ContainerEndpoint()).To(Equal("https://containers.cloud.ibm.com/global")) 85 Expect(locator.ResourceManagementEndpoint()).To(Equal("https://resource-controller.cloud.ibm.com")) 86 Expect(locator.ResourceControllerEndpoint()).To(Equal("https://resource-controller.cloud.ibm.com")) 87 Expect(locator.ResourceCatalogEndpoint()).To(Equal("https://globalcatalog.cloud.ibm.com")) 88 Expect(locator.CseEndpoint()).To(Equal("https://api.serviceendpoint.cloud.ibm.com")) 89 }) 90 }) 91 92 Context("When region is not supported", func() { 93 locator := newEndpointLocator("in", "public", "") 94 95 It("should return error", func() { 96 _, err := locator.CFAPIEndpoint() 97 Expect(err).To(HaveOccurred()) 98 _, err = locator.UAAEndpoint() 99 Expect(err).To(HaveOccurred()) 100 _, err = locator.ContainerRegistryEndpoint() 101 Expect(err).To(HaveOccurred()) 102 }) 103 }) 104 105 }) 106 107 func newEndpointLocator(region, visibility, endpointsFile string) EndpointLocator { 108 return NewEndpointLocator(region, visibility, endpointsFile) 109 }