From bbab13a9952e7846d80a873723b5d9f3798d621c Mon Sep 17 00:00:00 2001 From: Rak Alexey Date: Sun, 12 Apr 2020 18:55:55 +0000 Subject: [PATCH] Add test with many endpoints --- firewall/cmd/firewall/main_test.go | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/firewall/cmd/firewall/main_test.go b/firewall/cmd/firewall/main_test.go index e69c70c..b2b689d 100644 --- a/firewall/cmd/firewall/main_test.go +++ b/firewall/cmd/firewall/main_test.go @@ -282,6 +282,40 @@ rules: }, expected: result{code: http.StatusForbidden, body: "Forbidden"}, }, + { + name: "many-rules-forbidden", + conf: ` +rules: + - endpoint: "/list" + forbidden_response_re: + - '.*admin.*' + - endpoint: "/dump" + max_response_length_bytes: 4 +`, + service: echoService, + makeRequest: func() *resty.Request { + return c.R().SetBody(`hello`) + }, + endpoint: "/dump", + expected: result{code: http.StatusForbidden, body: "Forbidden"}, + }, + { + name: "many-rules-ok", + conf: ` +rules: + - endpoint: "/list" + forbidden_response_re: + - '.*admin.*' + - endpoint: "/dump" + max_response_length_bytes: 4 +`, + service: echoService, + makeRequest: func() *resty.Request { + return c.R().SetBody(`hello`) + }, + endpoint: "/list", + expected: result{code: http.StatusOK, body: "hello"}, + }, } { t.Run(tc.name, func(t *testing.T) { service := httptest.NewServer(tc.service)