fix(proxy): honour monitoring restriction flag
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
fd6bc01b87
commit
fd88492b00
2 changed files with 6 additions and 6 deletions
|
|
@ -49,7 +49,7 @@ func TestProxy_allowHTTP_Bad(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestProxy_allowHTTP_MethodRestricted_Bad(t *testing.T) {
|
||||
func TestProxy_allowHTTP_Unrestricted_Good(t *testing.T) {
|
||||
p := &Proxy{
|
||||
config: &Config{
|
||||
HTTP: HTTPConfig{},
|
||||
|
|
@ -57,11 +57,11 @@ func TestProxy_allowHTTP_MethodRestricted_Bad(t *testing.T) {
|
|||
}
|
||||
|
||||
status, ok := p.allowMonitoringRequest(&http.Request{Method: http.MethodPost})
|
||||
if ok {
|
||||
t.Fatal("expected non-GET request to be rejected")
|
||||
if !ok {
|
||||
t.Fatalf("expected unrestricted request to pass, got status %d", status)
|
||||
}
|
||||
if status != http.StatusMethodNotAllowed {
|
||||
t.Fatalf("expected status %d, got %d", http.StatusMethodNotAllowed, status)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("expected status %d, got %d", http.StatusOK, status)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ func (p *Proxy) allowMonitoringRequest(r *http.Request) (int, bool) {
|
|||
if p == nil {
|
||||
return http.StatusServiceUnavailable, false
|
||||
}
|
||||
if r.Method != http.MethodGet {
|
||||
if p.config != nil && p.config.HTTP.Restricted && r.Method != http.MethodGet {
|
||||
return http.StatusMethodNotAllowed, false
|
||||
}
|
||||
if token := p.config.HTTP.AccessToken; token != "" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue