当前位置: 首页>>代码示例>>Golang>>正文


Golang net.NewTLSServer函数代码示例

本文整理汇总了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
}
开发者ID:jalateras,项目名称:cli,代码行数:28,代码来源:users_test.go

示例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
}
开发者ID:nsnt,项目名称:cli,代码行数:28,代码来源:users_test.go

示例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())
}
开发者ID:nsnt,项目名称:cli,代码行数:26,代码来源:app_events_test.go

示例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
}
开发者ID:nimbus-cloud,项目名称:cli,代码行数:7,代码来源:authentication_test.go

示例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())
}
开发者ID:nsnt,项目名称:cli,代码行数:25,代码来源:curl_test.go

示例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
}
开发者ID:pmuellr,项目名称:cli,代码行数:25,代码来源:application_bits_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:28,代码来源:application_bits_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:user_provided_service_instances_test.go

示例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
}
开发者ID:nimbus-cloud,项目名称:cli,代码行数:8,代码来源:service_auth_tokens_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:buildpacks_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:app_summary_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:9,代码来源:authentication_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:10,代码来源:app_instances_test.go

示例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
}
开发者ID:nimbus-cloud,项目名称:cli,代码行数:10,代码来源:services_test.go

示例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
}
开发者ID:normalnorman,项目名称:cli,代码行数:10,代码来源:password_test.go


注:本文中的testhelpers/net.NewTLSServer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。