示例#1
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	targetVerifier := target_verifier.New(receptor_client_factory.MakeReceptorClient)
	app := cli_app_factory.MakeCliApp(latticeVersion, ltcConfigRoot(), exitHandler, config, logger(), targetVerifier, os.Stdout)
	return app
}
示例#2
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	receptorClientCreator := receptor_client.ProxyAwareCreator{}

	return cli_app_factory.MakeCliApp(
		diegoVersion,
		latticeVersion,
		ltcConfigRoot(),
		exitHandler,
		config,
		logger(),
		receptorClientCreator,
		target_verifier.New(receptorClientCreator),
		os.Stdout,
	)
}
示例#3
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	targetVerifier := target_verifier.New(func(target string) receptor.Client {
		return receptor.NewClient(target)
	})

	return cli_app_factory.MakeCliApp(
		diegoVersion,
		latticeVersion,
		ltcConfigRoot(),
		exitHandler,
		config,
		logger(),
		targetVerifier,
		os.Stdout,
	)
}
	"github.com/cloudfoundry-incubator/receptor/fake_receptor"
)

var _ = Describe("TargetVerifier", func() {
	Describe("VerifyBlobTarget", func() {
		var (
			config         *config_package.Config
			fakeServer     *ghttp.Server
			targetVerifier target_verifier.TargetVerifier
			statusCode     int
			responseBody   string
		)

		BeforeEach(func() {
			targetVerifier = target_verifier.New(func(string) receptor.Client {
				return &fake_receptor.FakeClient{}
			})
			fakeServer = ghttp.NewServer()

			config = config_package.New(persister.NewMemPersister())
			proxyURL, err := url.Parse(fakeServer.URL())
			Expect(err).NotTo(HaveOccurred())
			proxyHostArr := strings.Split(proxyURL.Host, ":")
			Expect(proxyHostArr).To(HaveLen(2))
			proxyHostPort, _ := strconv.Atoi(proxyHostArr[1])
			config.SetBlobTarget(proxyHostArr[0], uint16(proxyHostPort), "V8GDQFR_VDOGM55IV8OH", "Wv_kltnl98hNWNdNwyQPYnFhK4gVPTxVS3NNMg==", "bucket")

			httpHeader := http.Header{
				"Content-Type": []string{"application/xml"},
			}
	"github.com/cloudfoundry-incubator/receptor/fake_receptor"
)

var _ = Describe("TargetVerifier", func() {
	Describe("VerifyTarget", func() {
		var (
			fakeReceptorClient        *fake_receptor.FakeClient
			fakeReceptorClientCreator *fake_receptor_client_creator.FakeCreator
			targetVerifier            target_verifier.TargetVerifier
		)

		BeforeEach(func() {
			fakeReceptorClient = &fake_receptor.FakeClient{}
			fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}
			fakeReceptorClientCreator.CreateReceptorClientReturns(fakeReceptorClient)
			targetVerifier = target_verifier.New(fakeReceptorClientCreator)
		})

		It("returns up=true, auth=true if the receptor does not return an error", func() {
			up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")
			Expect(err).NotTo(HaveOccurred())
			Expect(up).To(BeTrue())
			Expect(auth).To(BeTrue())
			Expect(fakeReceptorClientCreator.CreateReceptorClientCallCount()).To(Equal(1))
			Expect(fakeReceptorClientCreator.CreateReceptorClientArgsForCall(0)).To(Equal("http://receptor.mylattice.com"))
		})

		It("returns up=true, auth=false if the receptor returns an authorization error", func() {
			fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, receptor.Error{
				Type:    receptor.Unauthorized,
				Message: "Go home. You're not welcome here.",
var _ = Describe("TargetVerifier", func() {
	Describe("VerifyTarget", func() {
		var (
			fakeReceptorClient *fake_receptor.FakeClient
			targetVerifier     target_verifier.TargetVerifier
			targets            []string
		)

		fakeReceptorClientFactory := func(target string) receptor.Client {
			targets = append(targets, target)
			return fakeReceptorClient
		}

		BeforeEach(func() {
			fakeReceptorClient = &fake_receptor.FakeClient{}
			targetVerifier = target_verifier.New(fakeReceptorClientFactory)
			targets = []string{}
		})

		It("returns up=true, auth=true if the receptor does not return an error", func() {
			up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")

			Expect(up).To(BeTrue())
			Expect(auth).To(BeTrue())
			Expect(err).ToNot(HaveOccurred())
			Expect(targets).To(ConsistOf("http://receptor.mylattice.com"))
		})

		It("returns up=true, auth=false if the receptor returns an authorization error", func() {
			fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, receptor.Error{
				Type:    receptor.Unauthorized,