Пример #1
0
func (cmd *ATCCommand) constructWebHandler(
	logger lager.Logger,
	sqlDB *db.SQLDB,
	authValidator auth.Validator,
	pipelineDBFactory db.PipelineDBFactory,
	engine engine.Engine,
) (http.Handler, error) {
	webWrapper := wrappa.MultiWrappa{
		wrappa.NewWebAuthWrappa(cmd.PubliclyViewable, authValidator),
		wrappa.NewWebMetricsWrappa(logger),
	}

	clientFactory := web.NewClientFactory(
		fmt.Sprintf("http://127.0.0.1:%d", cmd.BindPort),
	)

	return webhandler.NewHandler(
		logger,
		webWrapper,
		sqlDB,
		pipelineDBFactory,
		sqlDB,
		cmd.TemplatesDir.Path(),
		cmd.PublicDir.Path(),
		engine,
		clientFactory,
	)
}
Пример #2
0
func (cmd *ATCCommand) constructWebHandler(
	logger lager.Logger,
	authValidator auth.Validator,
	userContextReader auth.UserContextReader,
	pipelineDBFactory db.PipelineDBFactory,
) (http.Handler, error) {
	webWrapper := wrappa.MultiWrappa{
		wrappa.NewWebAuthWrappa(authValidator, userContextReader),
		wrappa.NewWebMetricsWrappa(logger),
	}

	clientFactory := web.NewClientFactory(
		fmt.Sprintf("http://127.0.0.1:%d", cmd.BindPort),
	)

	return webhandler.NewHandler(
		logger,
		webWrapper,
		clientFactory,
	)
}
Пример #3
0
				web.GetJob:          inputHandlers[web.GetJob],
				web.LogIn:           inputHandlers[web.LogIn],
				web.BasicAuth: auth.WrapHandler(
					auth.CheckAuthHandler(
						inputHandlers[web.BasicAuth],
						auth.BasicAuthRejector{},
					),
					fakeValidator,
					fakeUserContextReader,
				),
			}
		})

		JustBeforeEach(func() {
			wrappedHandlers = wrappa.NewWebAuthWrappa(
				fakeValidator,
				fakeUserContextReader,
			).Wrap(inputHandlers)
		})

		It("requires validation for the basic auth route", func() {
			for name, _ := range inputHandlers {
				Expect(descriptiveRoute{
					route:   name,
					handler: wrappedHandlers[name],
				}).To(Equal(descriptiveRoute{
					route:   name,
					handler: expectedHandlers[name],
				}))
			}
		})
	})
Пример #4
0
			inputHandlers rata.Handlers

			wrappedHandlers rata.Handlers
		)

		BeforeEach(func() {
			inputHandlers = rata.Handlers{}

			for _, route := range web.Routes {
				inputHandlers[route.Name] = &stupidHandler{}
			}
		})

		JustBeforeEach(func() {
			wrappedHandlers = wrappa.NewWebAuthWrappa(
				publiclyViewable,
				fakeValidator,
			).Wrap(inputHandlers)
		})

		Context("when publicly viewable", func() {
			var expectedHandlers rata.Handlers

			BeforeEach(func() {
				publiclyViewable = true

				expectedHandlers = rata.Handlers{
					web.Index:           unauthed(inputHandlers[web.Index]),
					web.Pipeline:        unauthed(inputHandlers[web.Pipeline]),
					web.TriggerBuild:    authed(inputHandlers[web.TriggerBuild]),
					web.GetBuild:        unauthed(inputHandlers[web.GetBuild]),
					web.GetBuilds:       unauthed(inputHandlers[web.GetBuilds]),