示例#1
0
		})

		rpcService, _ := rpc.NewRpcService(nil, nil, nil, nil, api.RepositoryLocator{}, nil)
		cmdFactory := command_factory.NewFactory(ui, config, manifestRepo, repoLocator, pluginConfig, rpcService)
		cmdRunner = &FakeRunner{cmdFactory: cmdFactory}
		app = NewApp(cmdRunner, cmdFactory.CommandMetadatas()...)
	})

	Describe("trace file integration", func() {
		var (
			output *bytes.Buffer
		)

		BeforeEach(func() {
			output = bytes.NewBuffer(make([]byte, 1024))
			trace.SetStdout(output)
			trace.EnableTrace()
		})

		It("prints its version number to the trace output when constructed", func() {
			Expect(strings.Split(output.String(), "\n")).To(ContainSubstrings(
				[]string{"VERSION:"},
				[]string{cf.Version},
			))
		})
	})

	Context("when given a command name to run", func() {
		It("runs the command with that name", func() {
			for _, cmdName := range expectedCommandNames {
				app.Run([]string{"", cmdName})
示例#2
0
			})

			It("gets the access code from the token endpoint", func() {
				runCommand()

				Ω(authRepo.RefreshTokenCalled).To(BeTrue())
				Ω(fakeUAA.ReceivedRequests()).To(HaveLen(1))
				Ω(ui.Outputs).To(ContainSubstrings(
					[]string{"abc123"},
				))
			})

			It("dumps all the http requests and responses for logging", func() {
				var stdout *bytes.Buffer
				stdout = bytes.NewBuffer([]byte{})
				trace.SetStdout(stdout)

				trace.NewLogger("true")
				runCommand()

				result, err := ioutil.ReadAll(stdout)
				Expect(err).ToNot(HaveOccurred())
				Expect(result).To(ContainSubstring("REQUEST"))
				Expect(result).To(ContainSubstring("RESPONSE"))
			})

			It("returns an error when the uaa certificate is not valid and certificate validation is enabled", func() {
				configRepo.SetSSLDisabled(false)

				runCommand()