Beispiel #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, syscall.SIGHUP, syscall.SIGTERM)
	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,
	)
}
	"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.",