func NewBmpClient(username, password, url string, hClient softlayer.HttpClient, configPath string) *bmpClient { var httpClient softlayer.HttpClient useHttps := false if url != "" { useHttps, url = analyseURL(url) } if hClient == nil { httpClient = slclient.NewHttpClient(username, password, url, "", useHttps) } else { httpClient = hClient } return &bmpClient{ username: username, password: password, url: url, configPath: configPath, httpClient: httpClient, } }
var _ = Describe("A HTTP Client", func() { var ( server *ghttp.Server client *slclient.HttpClient err error slUsername, slAPIKey string port = 9999 ) Context("when the target HTTP server is stable", func() { BeforeEach(func() { server = ghttp.NewServer() fmt.Fprintf(os.Stdout, "server addr is: "+server.Addr()) slUsername = os.Getenv("SL_USERNAME") slAPIKey = os.Getenv("SL_API_KEY") client = slclient.NewHttpClient(slUsername, slAPIKey, server.Addr(), "templates", false) }) AfterEach(func() { server.Close() }) Context("#DoRawHttpRequest", func() { Context("when a successful request", func() { BeforeEach(func() { server.CloseClientConnections() server.AppendHandlers( ghttp.VerifyRequest("GET", "/test"), ghttp.VerifyBasicAuth(slUsername, slAPIKey), ) })