本文整理汇总了Golang中testhelpers/net.NewTLSServer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTLSServer函数的具体用法?Golang NewTLSServer怎么用?Golang NewTLSServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTLSServer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createUsersRepo
func createUsersRepo(t *testing.T, ccReqs []testnet.TestRequest, uaaReqs []testnet.TestRequest) (cc *httptest.Server,
ccHandler *testnet.TestHandler, uaa *httptest.Server, uaaHandler *testnet.TestHandler, repo UserRepository) {
ccTarget := ""
uaaTarget := ""
if len(ccReqs) > 0 {
cc, ccHandler = testnet.NewTLSServer(t, ccReqs)
ccTarget = cc.URL
}
if len(uaaReqs) > 0 {
uaa, uaaHandler = testnet.NewTLSServer(t, uaaReqs)
uaaTarget = uaa.URL
}
config := &configuration.Configuration{
AccessToken: "BEARER my_access_token",
Target: ccTarget,
Organization: cf.Organization{Guid: "some-org-guid"},
}
ccGateway := net.NewCloudControllerGateway()
uaaGateway := net.NewUAAGateway()
endpointRepo := &testapi.FakeEndpointRepo{GetEndpointEndpoints: map[cf.EndpointType]string{
cf.UaaEndpointKey: uaaTarget,
}}
repo = NewCloudControllerUserRepository(config, uaaGateway, ccGateway, endpointRepo)
return
}
示例2: createUsersRepo
func createUsersRepo(t *testing.T, ccReqs []testnet.TestRequest, uaaReqs []testnet.TestRequest) (cc *httptest.Server,
ccHandler *testnet.TestHandler, uaa *httptest.Server, uaaHandler *testnet.TestHandler, repo UserRepository) {
ccTarget := ""
uaaTarget := ""
if len(ccReqs) > 0 {
cc, ccHandler = testnet.NewTLSServer(t, ccReqs)
ccTarget = cc.URL
}
if len(uaaReqs) > 0 {
uaa, uaaHandler = testnet.NewTLSServer(t, uaaReqs)
uaaTarget = uaa.URL
}
org := cf.OrganizationFields{}
org.Guid = "some-org-guid"
config := &configuration.Configuration{
AccessToken: "BEARER my_access_token",
Target: ccTarget,
OrganizationFields: org,
}
ccGateway := net.NewCloudControllerGateway()
uaaGateway := net.NewUAAGateway()
endpointRepo := &testapi.FakeEndpointRepo{}
endpointRepo.UAAEndpointReturns.Endpoint = uaaTarget
repo = NewCloudControllerUserRepository(config, uaaGateway, ccGateway, endpointRepo)
return
}
示例3: TestListEventsWithNoEvents
func TestListEventsWithNoEvents(t *testing.T) {
emptyEventsRequest := testnet.TestRequest{
Method: "GET",
Path: "/v2/apps/my-app-guid/events",
Response: testnet.TestResponse{
Status: http.StatusOK,
Body: `{"resources": []}`},
}
listEventsServer, handler := testnet.NewTLSServer(t, []testnet.TestRequest{emptyEventsRequest})
defer listEventsServer.Close()
config := &configuration.Configuration{
Target: listEventsServer.URL,
AccessToken: "BEARER my_access_token",
}
repo := NewCloudControllerAppEventsRepository(config, net.NewCloudControllerGateway())
eventChan, apiErr := repo.ListEvents("my-app-guid")
_, ok := <-eventChan
_, open := <-apiErr
assert.False(t, ok)
assert.False(t, open)
assert.True(t, handler.AllRequestsCalled())
}
示例4: setupAuthDependencies
func setupAuthDependencies(request testnet.TestRequest) (*httptest.Server, *testnet.TestHandler, configuration.ReadWriter) {
ts, handler := testnet.NewTLSServer([]testnet.TestRequest{request})
config := testconfig.NewRepository()
config.SetAuthorizationEndpoint(ts.URL)
return ts, handler, config
}
示例5: TestCurlWithCustomHeaders
func TestCurlWithCustomHeaders(t *testing.T) {
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "POST",
Path: "/v2/endpoint",
Matcher: func(t *testing.T, req *http.Request) {
assert.Equal(t, req.Header.Get("content-type"), "ascii/cats")
assert.Equal(t, req.Header.Get("x-something-else"), "5")
},
Response: testnet.TestResponse{
Status: http.StatusOK,
Body: jsonResponse},
})
ts, handler := testnet.NewTLSServer(t, []testnet.TestRequest{req})
defer ts.Close()
deps := newCurlDependencies()
deps.config.Target = ts.URL
headers := "content-type: ascii/cats\nx-something-else:5"
repo := NewCloudControllerCurlRepository(deps.config, deps.gateway)
_, _, apiResponse := repo.Request("POST", "/v2/endpoint", headers, "")
println(apiResponse.Message)
assert.True(t, handler.AllRequestsCalled())
assert.True(t, apiResponse.IsSuccessful())
}
示例6: testUploadApp
func testUploadApp(t *testing.T, dir string, requests []testnet.TestRequest) (app cf.Application, apiResponse net.ApiResponse) {
ts, handler := testnet.NewTLSServer(t, requests)
defer ts.Close()
config := &configuration.Configuration{
AccessToken: "BEARER my_access_token",
Target: ts.URL,
}
gateway := net.NewCloudControllerGateway()
gateway.PollingThrottle = time.Duration(0)
zipper := cf.ApplicationZipper{}
repo := NewCloudControllerApplicationBitsRepository(config, gateway, zipper)
var reportedFileCount, reportedUploadSize uint64
apiResponse = repo.UploadApp("my-cool-app-guid", dir, func(uploadSize, fileCount uint64) {
reportedUploadSize = uploadSize
reportedFileCount = fileCount
})
assert.Equal(t, reportedFileCount, uint64(len(expectedApplicationContent)))
assert.Equal(t, reportedUploadSize, uint64(759))
assert.True(t, handler.AllRequestsCalled())
return
}
示例7: testUploadApp
func testUploadApp(dir string, requests []testnet.TestRequest) (app models.Application, apiResponse net.ApiResponse) {
ts, handler := testnet.NewTLSServer(requests)
defer ts.Close()
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway()
gateway.PollingThrottle = time.Duration(0)
zipper := cf.ApplicationZipper{}
repo := NewCloudControllerApplicationBitsRepository(configRepo, gateway, zipper)
var (
reportedPath string
reportedFileCount, reportedUploadSize uint64
)
apiResponse = repo.UploadApp("my-cool-app-guid", dir, func(path string, uploadSize, fileCount uint64) {
reportedPath = path
reportedUploadSize = uploadSize
reportedFileCount = fileCount
})
Expect(reportedPath).To(Equal(dir))
Expect(reportedFileCount).To(Equal(uint64(len(expectedApplicationContent))))
Expect(reportedUploadSize).To(Equal(uint64(759)))
Expect(handler.AllRequestsCalled()).To(BeTrue())
return
}
示例8: createUserProvidedServiceInstanceRepo
func createUserProvidedServiceInstanceRepo(req testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo UserProvidedServiceInstanceRepository) {
ts, handler = testnet.NewTLSServer([]testnet.TestRequest{req})
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway()
repo = NewCCUserProvidedServiceInstanceRepository(configRepo, gateway)
return
}
示例9: createServiceAuthTokenRepo
func createServiceAuthTokenRepo(request testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceAuthTokenRepository) {
ts, handler = testnet.NewTLSServer([]testnet.TestRequest{request})
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway()
repo = NewCloudControllerServiceAuthTokenRepository(configRepo, gateway)
return
}
示例10: createBuildpackRepo
func createBuildpackRepo(requests ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo BuildpackRepository) {
ts, handler = testnet.NewTLSServer(requests)
config := testconfig.NewRepositoryWithDefaults()
config.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway()
repo = NewCloudControllerBuildpackRepository(config, gateway)
return
}
示例11: createAppSummaryRepo
func createAppSummaryRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo AppSummaryRepository) {
ts, handler = testnet.NewTLSServer(requests)
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway()
repo = NewCloudControllerAppSummaryRepository(configRepo, gateway)
return
}
示例12: setupAuthDependencies
func setupAuthDependencies(request testnet.TestRequest) (deps authDependencies) {
deps.ts, deps.handler = testnet.NewTLSServer([]testnet.TestRequest{request})
deps.config = testconfig.NewRepository()
deps.config.SetAuthorizationEndpoint(deps.ts.URL)
deps.gateway = net.NewUAAGateway()
return
}
示例13: createAppInstancesRepo
func createAppInstancesRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo AppInstancesRepository) {
ts, handler = testnet.NewTLSServer(requests)
space := models.SpaceFields{}
space.Guid = "my-space-guid"
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway()
repo = NewCloudControllerAppInstancesRepository(configRepo, gateway)
return
}
示例14: createServiceRepoWithConfig
func createServiceRepoWithConfig(reqs []testnet.TestRequest, config configuration.ReadWriter) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceRepository) {
if len(reqs) > 0 {
ts, handler = testnet.NewTLSServer(reqs)
config.SetApiEndpoint(ts.URL)
}
gateway := net.NewCloudControllerGateway()
repo = NewCloudControllerServiceRepository(config, gateway)
return
}
示例15: createPasswordRepo
func createPasswordRepo(req testnet.TestRequest) (passwordServer *httptest.Server, handler *testnet.TestHandler, repo PasswordRepository) {
passwordServer, handler = testnet.NewTLSServer([]testnet.TestRequest{req})
endpointRepo := &testapi.FakeEndpointRepo{}
endpointRepo.UAAEndpointReturns.Endpoint = passwordServer.URL
configRepo := testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway()
repo = NewCloudControllerPasswordRepository(configRepo, gateway, endpointRepo)
return
}