(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestBasicAuthForProxySucceed(t *testing.T) { |
| 142 | accounts := Accounts{"admin": "password"} |
| 143 | router := New() |
| 144 | router.Use(BasicAuthForProxy(accounts, "")) |
| 145 | router.Any("/*proxyPath", func(c *Context) { |
| 146 | c.String(http.StatusOK, c.MustGet(AuthProxyUserKey).(string)) |
| 147 | }) |
| 148 | |
| 149 | w := httptest.NewRecorder() |
| 150 | req, _ := http.NewRequest(http.MethodGet, "/test", nil) |
| 151 | req.Header.Set("Proxy-Authorization", authorizationHeader("admin", "password")) |
| 152 | router.ServeHTTP(w, req) |
| 153 | |
| 154 | assert.Equal(t, http.StatusOK, w.Code) |
| 155 | assert.Equal(t, "admin", w.Body.String()) |
| 156 | } |
| 157 | |
| 158 | func TestBasicAuthForProxy407(t *testing.T) { |
| 159 | called := false |
nothing calls this directly
no test coverage detected