mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 04:15:54 +02:00
manage force_pull message for one blocklist (#2615)
* manage force_pull message for one blocklist * fix info message on force pull blocklist
This commit is contained in:
parent
6b0bdc5eeb
commit
7c5cbef51a
3 changed files with 98 additions and 10 deletions
|
@ -973,6 +973,37 @@ func TestAPICPullTopBLCacheForceCall(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestAPICPullBlocklistCall(t *testing.T) {
|
||||
api := getAPIC(t)
|
||||
httpmock.Activate()
|
||||
defer httpmock.DeactivateAndReset()
|
||||
|
||||
httpmock.RegisterResponder("GET", "http://api.crowdsec.net/blocklist1", func(req *http.Request) (*http.Response, error) {
|
||||
assert.Equal(t, "", req.Header.Get("If-Modified-Since"))
|
||||
return httpmock.NewStringResponse(200, "1.2.3.4"), nil
|
||||
})
|
||||
url, err := url.ParseRequestURI("http://api.crowdsec.net/")
|
||||
require.NoError(t, err)
|
||||
|
||||
apic, err := apiclient.NewDefaultClient(
|
||||
url,
|
||||
"/api",
|
||||
fmt.Sprintf("crowdsec/%s", version.String()),
|
||||
nil,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
api.apiClient = apic
|
||||
err = api.PullBlocklist(&modelscapi.BlocklistLink{
|
||||
URL: ptr.Of("http://api.crowdsec.net/blocklist1"),
|
||||
Name: ptr.Of("blocklist1"),
|
||||
Scope: ptr.Of("Ip"),
|
||||
Remediation: ptr.Of("ban"),
|
||||
Duration: ptr.Of("24h"),
|
||||
}, true)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestAPICPush(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue