Add authenticated user to context

This commit is contained in:
Deluan
2020-01-20 18:12:17 -05:00
parent 28cd3ec3e4
commit 2cc983638c
2 changed files with 14 additions and 8 deletions
+3 -1
View File
@@ -33,7 +33,7 @@ var _ = Describe("Middlewares", func() {
cp := checkRequiredParameters(next)
cp.ServeHTTP(w, r)
Expect(next.req.Context().Value("user")).To(Equal("user"))
Expect(next.req.Context().Value("username")).To(Equal("user"))
Expect(next.req.Context().Value("version")).To(Equal("1.15"))
Expect(next.req.Context().Value("client")).To(Equal("test"))
Expect(next.called).To(BeTrue())
@@ -83,6 +83,8 @@ var _ = Describe("Middlewares", func() {
Expect(mockedUser.token).To(Equal("token"))
Expect(mockedUser.salt).To(Equal("salt"))
Expect(next.called).To(BeTrue())
user := next.req.Context().Value("user").(*model.User)
Expect(user.UserName).To(Equal("valid"))
})
It("fails authentication with wrong password", func() {