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


Golang FakeCliConnection.AccessTokenReturns方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection.AccessTokenReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeCliConnection.AccessTokenReturns方法的具体用法?Golang FakeCliConnection.AccessTokenReturns怎么用?Golang FakeCliConnection.AccessTokenReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection的用法示例。


在下文中一共展示了FakeCliConnection.AccessTokenReturns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("DropletDownloader", func() {

	var fakeCliConnection *cliFakes.FakeCliConnection
	var downloader *CFDownloader
	var server *ghttp.Server
	tarFileContents := "This is a tar file"

	BeforeEach(func() {
		fakeCliConnection = &cliFakes.FakeCliConnection{}
		downloader = &CFDownloader{Cli: fakeCliConnection}
		server = ghttp.NewServer()
		fakeCliConnection.AccessTokenReturns("bearer 1234", nil)
		fakeCliConnection.ApiEndpointReturns(server.URL(), nil)
		fakeCliConnection.IsSSLDisabledReturns(true, nil)
		server.AppendHandlers(
			ghttp.VerifyRequest("GET", "/v2/apps/1234/droplet/download"),
			ghttp.VerifyHeader(
				http.Header{
					"Authorization": []string{"bearer 1234"},
				}),
			ghttp.RespondWith(http.StatusOK, []byte(tarFileContents)),
		)
	})

	AfterEach(func() {
		server.Close()
	})
开发者ID:krujos,项目名称:download_droplet_plugin,代码行数:31,代码来源:downloader_test.go

示例2:

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		fakeCliConnection.IsSSLDisabledReturns(true, nil)
		fakeInfoFactory = &info_fakes.FakeInfoFactory{}
	})

	JustBeforeEach(func() {
		credFactory = credential.NewCredentialFactory(fakeCliConnection, fakeInfoFactory)
	})

	Describe("AuthorizationCode", func() {
		var v2Info info.Info
		var fakeUAA *ghttp.Server

		BeforeEach(func() {
			fakeCliConnection.AccessTokenReturns("bearer client-bearer-token", nil)

			fakeUAA = ghttp.NewTLSServer()
			v2Info = info.Info{
				SSHOAuthClient: "ssh-oauth-client-id",
				TokenEndpoint:  fakeUAA.URL(),
			}
			fakeInfoFactory.GetReturns(v2Info, nil)

			fakeUAA.RouteToHandler("GET", "/oauth/authorize", ghttp.CombineHandlers(
				ghttp.VerifyRequest("GET", "/oauth/authorize"),
				ghttp.VerifyFormKV("response_type", "code"),
				ghttp.VerifyFormKV("client_id", "ssh-oauth-client-id"),
				ghttp.VerifyFormKV("grant_type", "authorization_code"),
				ghttp.VerifyHeaderKV("authorization", "bearer client-bearer-token"),
				ghttp.RespondWith(http.StatusFound, "", http.Header{
开发者ID:krishicks,项目名称:diego-ssh,代码行数:31,代码来源:credential_test.go

示例3:

	ACCESS_TOKEN = "access_token"
)

var _ = Describe("NozzlePlugin", func() {
	Describe(".Run", func() {
		var fakeCliConnection *fakes.FakeCliConnection
		var nozzlerCmd *NozzlerCmd
		var fakeFirehose *testhelpers.FakeFirehose

		BeforeEach(func() {
			fakeFirehose = testhelpers.NewFakeFirehose(ACCESS_TOKEN)
			fakeFirehose.SendLog("Log Message")
			fakeFirehose.Start()

			fakeCliConnection = &fakes.FakeCliConnection{}
			fakeCliConnection.AccessTokenReturns(ACCESS_TOKEN, nil)
			fakeCliConnection.DopplerEndpointReturns(fakeFirehose.URL(), nil)
			nozzlerCmd = &NozzlerCmd{}
		})

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

		It("works", func(done Done) {
			defer close(done)
			outputChan := make(chan []string)
			go func() {
				output := io_helpers.CaptureOutput(func() {
					nozzlerCmd.Run(fakeCliConnection, []string{"nozzle", "--debug"})
				})
开发者ID:jtuchscherer,项目名称:nozzle-plugin,代码行数:31,代码来源:nozzle_plugin_test.go


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