From 4223b69eb339b84aada4becd7de3c9648d143a44 Mon Sep 17 00:00:00 2001 From: Alessandro Miceli Date: Wed, 2 Jun 2021 14:49:32 +0200 Subject: [PATCH] broken token test case --- http/middleware/response_header_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/http/middleware/response_header_test.go b/http/middleware/response_header_test.go index 956e82342..e6d301012 100644 --- a/http/middleware/response_header_test.go +++ b/http/middleware/response_header_test.go @@ -30,6 +30,17 @@ func TestClientID(t *testing.T) { assert.Empty(t, rec.Header().Get(ClientIDHeaderName)) }) + t.Run("brokenToken", func(t *testing.T) { + rec := httptest.NewRecorder() + req := httptest.NewRequest(http.MethodGet, "/", nil) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %v", emptyToken+"broken")) + + h := ClientID(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + })) + h.ServeHTTP(rec, req) + assert.Empty(t, rec.Header().Get(ClientIDHeaderName)) + }) + t.Run("clientID", func(t *testing.T) { rec := httptest.NewRecorder() req := httptest.NewRequest(http.MethodGet, "/", nil)