@@ -79,15 +79,32 @@ func TestPathAuthWithConfig(t *testing.T) {
7979 expectError string
8080 }{
8181 {
82- name : "ok, default config " ,
82+ name : "ok success " ,
8383 givenRequestFunc : func () * http.Request {
84- req := httptest .NewRequest (http .MethodPost , "/valid-key" , nil )
85- req .Header .Set (echo .HeaderContentType , echo .MIMEApplicationForm )
84+ req := httptest .NewRequest (http .MethodGet , "/valid-key" , nil )
8685 return req
8786 },
8887 expectHandlerCalled : true ,
8988 expectError : "" ,
9089 },
90+ {
91+ name : "ng user error" ,
92+ givenRequestFunc : func () * http.Request {
93+ req := httptest .NewRequest (http .MethodGet , "/error-key" , nil )
94+ return req
95+ },
96+ expectHandlerCalled : false ,
97+ expectError : "code=401, message=Unauthorized, internal=some user defined error" ,
98+ },
99+ {
100+ name : "ng no valid no error" ,
101+ givenRequestFunc : func () * http.Request {
102+ req := httptest .NewRequest (http .MethodGet , "/bad" , nil )
103+ return req
104+ },
105+ expectHandlerCalled : false ,
106+ expectError : "code=400, message=Bad Request" ,
107+ },
91108 }
92109
93110 for _ , tc := range testCases {
@@ -117,7 +134,8 @@ func TestPathAuthWithConfig(t *testing.T) {
117134 e .GET ("/:apikey" , middlewareChain )
118135 rec := httptest .NewRecorder ()
119136 c := e .NewContext (req , rec )
120- e .Router ().Find (http .MethodGet , "/valid-key" , c )
137+ // use params
138+ e .Router ().Find (http .MethodGet , req .URL .Path , c )
121139 err := middlewareChain (c )
122140
123141 assert .Equal (t , tc .expectHandlerCalled , handlerCalled )
0 commit comments