Exemplo n.º 1
0
// withPluginUser takes a request and makes the user accessible to plugin code.
func withPluginUser(next http.Handler) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		u := GetUser(r)
		plugin.SetUser(u, r)
		next.ServeHTTP(w, r)
	}
}
Exemplo n.º 2
0
func TestUserInjection(t *testing.T) {
	Convey("With a dbUser and a request", t, func() {
		u := &user.DBUser{Id: "name1"}
		r, err := http.NewRequest("GET", "/", bytes.NewBufferString("{}"))
		So(err, ShouldBeNil)

		Convey("the user should possible to set and retrieve", func() {
			plugin.SetUser(u, r)
			So(plugin.GetUser(r), ShouldResemble, u)
		})
	})
}