var req *http.Request var err error var token *jwtg.Token var tokenString string params := url.Values{"param": []string{"value"}, "query": []string{"qvalue"}} payload := map[string]interface{}{"payload": 42} validFunc := func(token *jwtg.Token) (interface{}, error) { return signingKey, nil } BeforeEach(func() { req, err = http.NewRequest("POST", "/goo", strings.NewReader(`{"payload":42}`)) Ω(err).ShouldNot(HaveOccurred()) rw := new(TestResponseWriter) ctx = goa.NewContext(nil, goa.New("test"), req, rw, params) ctx.SetPayload(payload) spec = &jwt.Specification{ AllowParam: true, ValidationFunc: validFunc, } token = jwtg.New(jwtg.SigningMethodHS256) token.Claims["exp"] = time.Now().Add(time.Hour * 24).Unix() token.Claims["random"] = "42" tokenString, err = token.SignedString(signingKey) Ω(err).ShouldNot(HaveOccurred()) }) It("requires a jwt token be present", func() { h := func(ctx *goa.Context) error { ctx.Respond(200, "ok")