From bb6baa20880e31ccf5b08b65d70fe2eb74042c04 Mon Sep 17 00:00:00 2001 From: Przemek Komosa Date: Sat, 2 Jul 2016 00:27:48 +0200 Subject: [PATCH] Add JWT tests for _query_ method --- middleware/jwt_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/middleware/jwt_test.go b/middleware/jwt_test.go index 07eeaa31..904054ec 100644 --- a/middleware/jwt_test.go +++ b/middleware/jwt_test.go @@ -60,6 +60,41 @@ func TestJWT(t *testing.T) { expErrCode: http.StatusBadRequest, info: "Empty header auth field", }, + { + config: JWTConfig{ + SigningKey: validKey, + TokenLookup: "query:jwt", + }, + reqURL: "/?a=b&jwt=" + token, + info: "Valid query method", + }, + { + config: JWTConfig{ + SigningKey: validKey, + TokenLookup: "query:jwt", + }, + reqURL: "/?a=b&jwtxyz=" + token, + expErrCode: http.StatusBadRequest, + info: "Invalid query param name", + }, + { + config: JWTConfig{ + SigningKey: validKey, + TokenLookup: "query:jwt", + }, + reqURL: "/?a=b&jwt=invalid-token", + expErrCode: http.StatusUnauthorized, + info: "Invalid query param value", + }, + { + config: JWTConfig{ + SigningKey: validKey, + TokenLookup: "query:jwt", + }, + reqURL: "/?a=b", + expErrCode: http.StatusBadRequest, + info: "Empty query", + }, } { if tc.reqURL == "" {