. "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()
	})
Example #2
0
	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{
	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"})
				})