本文整理汇总了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()
})
示例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{
示例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"})
})