|
@@ -1,8 +1,6 @@
|
|
package apiserver
|
|
package apiserver
|
|
|
|
|
|
import (
|
|
import (
|
|
- "fmt"
|
|
|
|
- "os"
|
|
|
|
"testing"
|
|
"testing"
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/assert"
|
|
@@ -334,1034 +332,3 @@ type DecisionTest struct {
|
|
DelChecks []DecisionCheck
|
|
DelChecks []DecisionCheck
|
|
AuthType string
|
|
AuthType string
|
|
}
|
|
}
|
|
-
|
|
|
|
-func TestStreamDecisionStart(t *testing.T) {
|
|
|
|
- lapi := SetupLAPITest(t)
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- Create multiple alerts:
|
|
|
|
- - 3 alerts for 127.0.0.1 with ID 1/2/3 : Different duration / scenario / origin
|
|
|
|
- - 3 alerts for 127.0.0.2 with ID 4/5/6/7 : Different duration / scenario / origin
|
|
|
|
- */
|
|
|
|
- lapi.InsertAlertFromFile("./tests/alert_duplicate.json")
|
|
|
|
-
|
|
|
|
- tests := []DecisionTest{
|
|
|
|
- {
|
|
|
|
- TestName: "test startup",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with scenarios containing",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 2,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(5),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with multiple scenarios containing",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_containing=ssh_bf,test",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
-
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with unknown scenarios containing",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_containing=unknown",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
-
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with scenarios containing and not containing",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_containing=test&scenarios_not_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(1),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "59m",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with scenarios containing and not containing 2",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_containing=longest&scenarios_not_containing=ssh_bf,test",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 1,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with scenarios not containing",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_not_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
-
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with multiple scenarios not containing",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&scenarios_not_containing=ssh_bf,test",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 1,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
-
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with origins parameter",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&origins=another_origin",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 2,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
-
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(7),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "1h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with multiple origins parameter",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&origins=another_origin,test",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
-
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "test startup with unknown origins",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true&origins=unknown",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 3 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/3",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 2 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/2",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(1),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 1 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/1",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "127.0.0.1 should be in deleted now",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 2,
|
|
|
|
- LenDeleted: 1,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(1),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "-", // we check that the time is negative
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 8 (127.0.0.2) with captcha",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/8",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "127.0.0.2 with captcha should be in deleted now",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 1,
|
|
|
|
- LenDeleted: 2,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(1),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "-", // we check that the time is negative
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "-",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for _, test := range tests {
|
|
|
|
- runTest(lapi, test, t)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func TestStreamDecision(t *testing.T) {
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- Create multiple alerts:
|
|
|
|
- - 3 alerts for 127.0.0.1 with ID 1/2/3 : Different duration / scenario / origin
|
|
|
|
- - 3 alerts for 127.0.0.2 with ID 4/5/6/7 : Different duration / scenario / origin
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- // this test just init the stream with startup=true
|
|
|
|
- preTests := []DecisionTest{
|
|
|
|
- {
|
|
|
|
- TestName: "test startup",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?startup=true",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- tests := map[string][]DecisionTest{
|
|
|
|
- "Test without parameter": {
|
|
|
|
- {
|
|
|
|
- TestName: "get stream",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 3 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/3",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 2 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/2",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 1 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/1",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "127.0.0.1 should be in deleted now",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 1,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(1),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "-",
|
|
|
|
-
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- "test with scenarios containing": {
|
|
|
|
- {
|
|
|
|
- TestName: "get stream",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 2,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(5),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 3 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/3",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 2 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/2",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is deleted (decision for ssh_bf was with ID 2)",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 1,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "-",
|
|
|
|
-
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- "test with scenarios not containing": {
|
|
|
|
- {
|
|
|
|
- TestName: "get stream",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_not_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 3,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(3),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/longest",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "4h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(4),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(8),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "captcha",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 3 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/3",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_not_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 2 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/2",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not deleted",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_not_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 1 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/1",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is deleted",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?scenarios_not_containing=ssh_bf",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 1,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(1),
|
|
|
|
- Origin: "test",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "-",
|
|
|
|
-
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- "test with origins": {
|
|
|
|
- {
|
|
|
|
- TestName: "get stream",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?origins=another_origin",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 2,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "2h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- ID: int64(7),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/test",
|
|
|
|
- Value: "127.0.0.2",
|
|
|
|
- Duration: "1h59",
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 3 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/3",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is not in deleted IP",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?origins=another_origin",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "delete decisions 2 (127.0.0.1)",
|
|
|
|
- Method: "DELETE",
|
|
|
|
- Route: "/v1/decisions/2",
|
|
|
|
- CheckCodeOnly: true,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 0,
|
|
|
|
- AuthType: PASSWORD,
|
|
|
|
- DelChecks: []DecisionCheck{},
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- TestName: "check that 127.0.0.1 is deleted",
|
|
|
|
- Method: "GET",
|
|
|
|
- Route: "/v1/decisions/stream?origins=another_origin",
|
|
|
|
- CheckCodeOnly: false,
|
|
|
|
- Code: 200,
|
|
|
|
- LenNew: 0,
|
|
|
|
- LenDeleted: 1,
|
|
|
|
- AuthType: APIKEY,
|
|
|
|
- DelChecks: []DecisionCheck{
|
|
|
|
- {
|
|
|
|
- ID: int64(2),
|
|
|
|
- Origin: "another_origin",
|
|
|
|
- Scenario: "crowdsecurity/ssh_bf",
|
|
|
|
- Value: "127.0.0.1",
|
|
|
|
- Duration: "-",
|
|
|
|
-
|
|
|
|
- Type: "ban",
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- NewChecks: []DecisionCheck{},
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // run tests for the stream
|
|
|
|
- for testName, test := range tests {
|
|
|
|
-
|
|
|
|
- // init a new LAPI
|
|
|
|
- lapi := SetupLAPITest(t)
|
|
|
|
-
|
|
|
|
- // run pre-test, mostly to init the stream
|
|
|
|
- for _, test := range preTests {
|
|
|
|
- runTest(lapi, test, t)
|
|
|
|
- }
|
|
|
|
- // insert decisions now that the stream is initiated
|
|
|
|
- lapi.InsertAlertFromFile("./tests/alert_duplicate.json")
|
|
|
|
-
|
|
|
|
- for _, oneTest := range test {
|
|
|
|
- oneTest.TestName = fmt.Sprintf("%s (%s)", oneTest.TestName, testName)
|
|
|
|
- runTest(lapi, oneTest, t)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // clean the db after each test
|
|
|
|
- os.Remove(lapi.DBConfig.DbPath)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func runTest(lapi LAPI, test DecisionTest, t *testing.T) {
|
|
|
|
- w := lapi.RecordResponse(test.Method, test.Route, emptyBody, test.AuthType)
|
|
|
|
- assert.Equal(t, test.Code, w.Code)
|
|
|
|
- if test.CheckCodeOnly {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- decisions, _, err := readDecisionsStreamResp(w)
|
|
|
|
- assert.Equal(t, nil, err)
|
|
|
|
- assert.Equal(t, test.LenDeleted, len(decisions["deleted"]), fmt.Sprintf("'%s': len(deleted)", test.TestName))
|
|
|
|
- assert.Equal(t, test.LenNew, len(decisions["new"]), fmt.Sprintf("'%s': len(new)", test.TestName))
|
|
|
|
-
|
|
|
|
- for i, check := range test.NewChecks {
|
|
|
|
- assert.Equal(t, check.ID, decisions["new"][i].ID, fmt.Sprintf("'%s' (idx: %d): field: ID", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Origin, *decisions["new"][i].Origin, fmt.Sprintf("'%s' (idx: %d): field: Origin", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Scenario, *decisions["new"][i].Scenario, fmt.Sprintf("'%s' (idx: %d): field: Scenario", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Value, *decisions["new"][i].Value, fmt.Sprintf("'%s' (idx: %d): field: Value", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Type, *decisions["new"][i].Type, fmt.Sprintf("'%s' (idx: %d): field: Type", test.TestName, i))
|
|
|
|
- assert.Contains(t, *decisions["new"][i].Duration, check.Duration, fmt.Sprintf("'%s' (idx: %d): field: Duration", test.TestName, i))
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for i, check := range test.DelChecks {
|
|
|
|
- assert.Equal(t, check.ID, decisions["deleted"][i].ID, fmt.Sprintf("'%s' (idx: %d): field: ID", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Origin, *decisions["deleted"][i].Origin, fmt.Sprintf("'%s' (idx: %d): field: Origin", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Scenario, *decisions["deleted"][i].Scenario, fmt.Sprintf("'%s' (idx: %d): field: Scenario", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Value, *decisions["deleted"][i].Value, fmt.Sprintf("'%s' (idx: %d): field: Value", test.TestName, i))
|
|
|
|
- assert.Equal(t, check.Type, *decisions["deleted"][i].Type, fmt.Sprintf("'%s' (idx: %d): field: Type", test.TestName, i))
|
|
|
|
- assert.Contains(t, *decisions["deleted"][i].Duration, check.Duration, fmt.Sprintf("'%s' (idx: %d): field: Duration", test.TestName, i))
|
|
|
|
- }
|
|
|
|
-}
|
|
|